Skip to content

Commit d30de3f

Browse files
author
jfeinstein10
committed
xml defined touch modes
1 parent 37b341f commit d30de3f

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

library/res/values/attrs.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@
2121
<attr name="viewBehind" format="reference" />
2222
<attr name="behindOffset" format="dimension" />
2323
<attr name="behindScrollScale" format="float" />
24-
<attr name="behindSide">
25-
<enum name="left" value="0" />
26-
<enum name="right" value="1" />
24+
<attr name="aboveTouchMode">
25+
<enum name="margin" value="0" />
26+
<enum name="fullscreen" value="1" />
27+
</attr>
28+
<attr name="behindTouchMode">
29+
<enum name="margin" value="0" />
30+
<enum name="fullscreen" value="1" />
2731
</attr>
2832
</declare-styleable>
2933

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
public class SlidingMenu extends RelativeLayout {
1111

12-
public static final int TOUCHMODE_FULLSCREEN = 0;
13-
public static final int TOUCHMODE_MARGIN = 1;
12+
public static final int TOUCHMODE_MARGIN = 0;
13+
public static final int TOUCHMODE_FULLSCREEN = 1;
1414

1515
private CustomViewAbove mViewAbove;
1616
private CustomViewBehind mViewBehind;
@@ -48,6 +48,10 @@ public SlidingMenu(Context context, AttributeSet attrs, int defStyle) {
4848
View v = LayoutInflater.from(context).inflate(viewBehind, null);
4949
setViewBehind(v);
5050
}
51+
int touchModeAbove = ta.getInt(R.styleable.SlidingMenu_aboveTouchMode, TOUCHMODE_MARGIN);
52+
setTouchModeAbove(touchModeAbove);
53+
int touchModeBehind = ta.getInt(R.styleable.SlidingMenu_behindTouchMode, TOUCHMODE_MARGIN);
54+
setTouchModeBehind(touchModeBehind);
5155
// set the offset and scroll scale if defined in xml
5256
int offsetBehind = (int) ta.getDimension(R.styleable.SlidingMenu_behindOffset, 0);
5357
setBehindOffset(offsetBehind);
@@ -166,23 +170,23 @@ public void setBehindScrollScale(float f) {
166170
mViewAbove.setScrollScale(f);
167171
}
168172

169-
public int getAboveTouchMode() {
173+
public int getTouchModeAbove() {
170174
return mViewAbove.getAboveTouchMode();
171175
}
172176

173-
public void setAboveTouchMode(int i) {
177+
public void setTouchModeAbove(int i) {
174178
if (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN) {
175179
throw new IllegalStateException("TouchMode must be set to either" +
176180
"TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN.");
177181
}
178182
mViewAbove.setAboveTouchMode(i);
179183
}
180184

181-
public int getBehindTouchMode() {
185+
public int getTouchModeBehind() {
182186
return mViewAbove.getBehindTouchMode();
183187
}
184188

185-
public void setBehindTouchMode(int i) {
189+
public void setTouchModeBehind(int i) {
186190
if (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN) {
187191
throw new IllegalStateException("TouchMode must be set to either" +
188192
"TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN.");

0 commit comments

Comments
 (0)