From 5ced46bb56869ea17113cf99735cca4c547e5871 Mon Sep 17 00:00:00 2001 From: HarshEvilGeek Date: Thu, 12 Feb 2015 16:49:22 +0530 Subject: [PATCH] adding a constant for empty layout ids --- .../main/java/com/daimajia/swipedemo/MyActivity.java | 2 +- .../src/main/java/com/daimajia/swipe/SwipeLayout.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java b/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java index e8d620b..11a5812 100644 --- a/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java +++ b/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java @@ -30,7 +30,7 @@ public class MyActivity extends Activity { sample1.setShowMode(SwipeLayout.ShowMode.LayDown); sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right, SwipeLayout.DragEdge.Top); // 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) - sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, -1); + sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, SwipeLayout.EMPTY_LAYOUT); sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() { @Override public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) { diff --git a/library/src/main/java/com/daimajia/swipe/SwipeLayout.java b/library/src/main/java/com/daimajia/swipe/SwipeLayout.java index c2e5a40..8568aad 100644 --- a/library/src/main/java/com/daimajia/swipe/SwipeLayout.java +++ b/library/src/main/java/com/daimajia/swipe/SwipeLayout.java @@ -25,6 +25,8 @@ import java.util.Map; public class SwipeLayout extends FrameLayout { + public static final int EMPTY_LAYOUT = -1; + private static final int DRAG_LEFT = 1; private static final int DRAG_RIGHT = 2; private static final int DRAG_TOP = 4; @@ -1161,7 +1163,7 @@ public class SwipeLayout extends FrameLayout { // Pass the id of the view if set, otherwise pass -1 public void setBottomViewIds(int left, int right, int top, int bottom) { if (mDragEdges.contains(DragEdge.Left)) { - if (left == -1) { + if (left == EMPTY_LAYOUT) { mBottomViewIdsSet = false; } else { mBottomViewIdMap.put(DragEdge.Left, left); @@ -1169,7 +1171,7 @@ public class SwipeLayout extends FrameLayout { } } if (mDragEdges.contains(DragEdge.Right)) { - if (right == -1) { + if (right == EMPTY_LAYOUT) { mBottomViewIdsSet = false; } else { mBottomViewIdMap.put(DragEdge.Right, right); @@ -1177,7 +1179,7 @@ public class SwipeLayout extends FrameLayout { } } if (mDragEdges.contains(DragEdge.Top)) { - if (top == -1) { + if (top == EMPTY_LAYOUT) { mBottomViewIdsSet = false; } else { mBottomViewIdMap.put(DragEdge.Top, top); @@ -1185,7 +1187,7 @@ public class SwipeLayout extends FrameLayout { } } if (mDragEdges.contains(DragEdge.Bottom)) { - if (bottom == -1) { + if (bottom == EMPTY_LAYOUT) { mBottomViewIdsSet = false; } else { mBottomViewIdMap.put(DragEdge.Bottom, bottom);