Skip to content

Commit

Permalink
project.properties missing. New OnOpen and OnCloseListeners
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeinstein10 committed Jul 26, 2012
1 parent 45516d7 commit a6ced13
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions library/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

android.library=true
# Project target.
target=Google Inc.:Google APIs:14
33 changes: 33 additions & 0 deletions library/src/com/slidingmenu/lib/SlidingMenu.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.slidingmenu.lib;

import com.slidingmenu.lib.CustomViewAbove.OnPageChangeListener;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
Expand All @@ -22,6 +24,17 @@ public class SlidingMenu extends RelativeLayout {

private CustomViewAbove mViewAbove;
private CustomViewBehind mViewBehind;

private OnOpenListener mOpenListener;
private OnCloseListener mCloseListener;

public interface OnOpenListener {
public void onOpen();
}

public interface OnCloseListener {
public void onClose();
}

public SlidingMenu(Context context) {
this(context, null);
Expand All @@ -42,6 +55,18 @@ public SlidingMenu(Context context, AttributeSet attrs, int defStyle) {
addView(mViewAbove, aboveParams);
// register the CustomViewBehind2 with the CustomViewAbove
mViewAbove.setCustomViewBehind2(mViewBehind);
mViewAbove.setOnPageChangeListener(new OnPageChangeListener() {
public void onPageScrolled(int position, float positionOffset,
int positionOffsetPixels) { }
public void onPageScrollStateChanged(int state) { }
public void onPageSelected(int position) {
if (position == 0 && mOpenListener != null) {
mOpenListener.onOpen();
} else if (position == 1 && mCloseListener != null) {
mCloseListener.onClose();
}
}
});

// now style everything!
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingMenu);
Expand Down Expand Up @@ -236,6 +261,14 @@ public void setFadeEnabled(boolean b) {
public void setFadeDegree(float f) {
mViewAbove.setBehindFadeDegree(f);
}

public void setOnOpenListener(OnOpenListener listener) {
mOpenListener = listener;
}

public void setOnCloseListener(OnCloseListener listener) {
mCloseListener = listener;
}

public static class SavedState extends BaseSavedState {
boolean mBehindShowing;
Expand Down

1 comment on commit a6ced13

@iPaulPro
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I was just going to add this in. Perhaps it's more practical to have one Interface with both methods?

Please sign in to comment.