Skip to content

Commit 5ced46b

Browse files
committed
adding a constant for empty layout ids
1 parent 93c06bf commit 5ced46b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

demo/src/main/java/com/daimajia/swipedemo/MyActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected void onCreate(Bundle savedInstanceState) {
3030
sample1.setShowMode(SwipeLayout.ShowMode.LayDown);
3131
sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top);
3232
// When using multiple drag edges it's a good idea to pass the ids of the views that you're using for the left, right, top bottom views (-1 if you're not using a particular view)
33-
sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, -1);
33+
sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, SwipeLayout.EMPTY_LAYOUT);
3434
sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {
3535
@Override
3636
public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {

library/src/main/java/com/daimajia/swipe/SwipeLayout.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
public class SwipeLayout extends FrameLayout {
2727

28+
public static final int EMPTY_LAYOUT = -1;
29+
2830
private static final int DRAG_LEFT = 1;
2931
private static final int DRAG_RIGHT = 2;
3032
private static final int DRAG_TOP = 4;
@@ -1161,31 +1163,31 @@ public List<ViewGroup> getBottomViews() {
11611163
// Pass the id of the view if set, otherwise pass -1
11621164
public void setBottomViewIds(int left, int right, int top, int bottom) {
11631165
if (mDragEdges.contains(DragEdge.Left)) {
1164-
if (left == -1) {
1166+
if (left == EMPTY_LAYOUT) {
11651167
mBottomViewIdsSet = false;
11661168
} else {
11671169
mBottomViewIdMap.put(DragEdge.Left, left);
11681170
mBottomViewIdsSet = true;
11691171
}
11701172
}
11711173
if (mDragEdges.contains(DragEdge.Right)) {
1172-
if (right == -1) {
1174+
if (right == EMPTY_LAYOUT) {
11731175
mBottomViewIdsSet = false;
11741176
} else {
11751177
mBottomViewIdMap.put(DragEdge.Right, right);
11761178
mBottomViewIdsSet = true;
11771179
}
11781180
}
11791181
if (mDragEdges.contains(DragEdge.Top)) {
1180-
if (top == -1) {
1182+
if (top == EMPTY_LAYOUT) {
11811183
mBottomViewIdsSet = false;
11821184
} else {
11831185
mBottomViewIdMap.put(DragEdge.Top, top);
11841186
mBottomViewIdsSet = true;
11851187
}
11861188
}
11871189
if (mDragEdges.contains(DragEdge.Bottom)) {
1188-
if (bottom == -1) {
1190+
if (bottom == EMPTY_LAYOUT) {
11891191
mBottomViewIdsSet = false;
11901192
} else {
11911193
mBottomViewIdMap.put(DragEdge.Bottom, bottom);

0 commit comments

Comments
 (0)