adding a constant for empty layout ids

This commit is contained in:
HarshEvilGeek 2015-02-12 16:49:22 +05:30
parent 93c06bfa01
commit 5ced46bb56
2 changed files with 7 additions and 5 deletions

View File

@ -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) {

View File

@ -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);