Skip to content

Commit a6ced13

Browse files
author
jfeinstein10
committed
project.properties missing. New OnOpen and OnCloseListeners
1 parent 45516d7 commit a6ced13

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

library/project.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system use,
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
10+
android.library=true
11+
# Project target.
12+
target=Google Inc.:Google APIs:14

library/src/com/slidingmenu/lib/SlidingMenu.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.slidingmenu.lib;
22

3+
import com.slidingmenu.lib.CustomViewAbove.OnPageChangeListener;
4+
35
import android.annotation.SuppressLint;
46
import android.content.Context;
57
import android.content.res.TypedArray;
@@ -22,6 +24,17 @@ public class SlidingMenu extends RelativeLayout {
2224

2325
private CustomViewAbove mViewAbove;
2426
private CustomViewBehind mViewBehind;
27+
28+
private OnOpenListener mOpenListener;
29+
private OnCloseListener mCloseListener;
30+
31+
public interface OnOpenListener {
32+
public void onOpen();
33+
}
34+
35+
public interface OnCloseListener {
36+
public void onClose();
37+
}
2538

2639
public SlidingMenu(Context context) {
2740
this(context, null);
@@ -42,6 +55,18 @@ public SlidingMenu(Context context, AttributeSet attrs, int defStyle) {
4255
addView(mViewAbove, aboveParams);
4356
// register the CustomViewBehind2 with the CustomViewAbove
4457
mViewAbove.setCustomViewBehind2(mViewBehind);
58+
mViewAbove.setOnPageChangeListener(new OnPageChangeListener() {
59+
public void onPageScrolled(int position, float positionOffset,
60+
int positionOffsetPixels) { }
61+
public void onPageScrollStateChanged(int state) { }
62+
public void onPageSelected(int position) {
63+
if (position == 0 && mOpenListener != null) {
64+
mOpenListener.onOpen();
65+
} else if (position == 1 && mCloseListener != null) {
66+
mCloseListener.onClose();
67+
}
68+
}
69+
});
4570

4671
// now style everything!
4772
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingMenu);
@@ -236,6 +261,14 @@ public void setFadeEnabled(boolean b) {
236261
public void setFadeDegree(float f) {
237262
mViewAbove.setBehindFadeDegree(f);
238263
}
264+
265+
public void setOnOpenListener(OnOpenListener listener) {
266+
mOpenListener = listener;
267+
}
268+
269+
public void setOnCloseListener(OnCloseListener listener) {
270+
mCloseListener = listener;
271+
}
239272

240273
public static class SavedState extends BaseSavedState {
241274
boolean mBehindShowing;

0 commit comments

Comments
 (0)