diff --git a/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java b/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java index c4d5ce1..e8d620b 100644 --- a/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java +++ b/demo/src/main/java/com/daimajia/swipedemo/MyActivity.java @@ -28,9 +28,9 @@ public class MyActivity extends Activity { sample1 = (SwipeLayout) findViewById(R.id.sample1); sample1.setShowMode(SwipeLayout.ShowMode.LayDown); - sample1.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right); + 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, -1, -1); + sample1.setBottomViewIds(R.id.bottom_wrapper, R.id.bottom_wrapper_2, R.id.starbott, -1); sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() { @Override public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) { diff --git a/demo/src/main/res/layout/sample1.xml b/demo/src/main/res/layout/sample1.xml index cc989aa..2632870 100644 --- a/demo/src/main/res/layout/sample1.xml +++ b/demo/src/main/res/layout/sample1.xml @@ -67,6 +67,26 @@ android:layout_height="match_parent" /> + + + + + + 0 && isLeftSwipeEnabled()) { mCurrentDirectionIndex = mLeftIndex; - } else if (mRightIndex != -1 && isRightSwipeEnabled()) { + } else if (mRightIndex != -1 && distanceX < 0 && isRightSwipeEnabled()) { mCurrentDirectionIndex = mRightIndex; } } else { - if (mTopIndex != -1 && distanceY < 0 && isTopSwipeEnabled()) { + if (mTopIndex != -1 && distanceY > 0 && isTopSwipeEnabled()) { mCurrentDirectionIndex = mTopIndex; - } else if (mBottomIndex != -1 && isBottomSwipeEnabled()) { + } else if (mBottomIndex != -1 && distanceY < 0 && isBottomSwipeEnabled()) { mCurrentDirectionIndex = mBottomIndex; } } @@ -1159,12 +1159,11 @@ 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) { + public void setBottomViewIds(int left, int right, int top, int bottom) { if (mDragEdges.contains(DragEdge.Left)) { if (left == -1) { mBottomViewIdsSet = false; - } - else { + } else { mBottomViewIdMap.put(DragEdge.Left, left); mBottomViewIdsSet = true; } @@ -1172,8 +1171,7 @@ public class SwipeLayout extends FrameLayout { if (mDragEdges.contains(DragEdge.Right)) { if (right == -1) { mBottomViewIdsSet = false; - } - else { + } else { mBottomViewIdMap.put(DragEdge.Right, right); mBottomViewIdsSet = true; } @@ -1181,8 +1179,7 @@ public class SwipeLayout extends FrameLayout { if (mDragEdges.contains(DragEdge.Top)) { if (top == -1) { mBottomViewIdsSet = false; - } - else { + } else { mBottomViewIdMap.put(DragEdge.Top, top); mBottomViewIdsSet = true; } @@ -1190,13 +1187,13 @@ public class SwipeLayout extends FrameLayout { if (mDragEdges.contains(DragEdge.Bottom)) { if (bottom == -1) { mBottomViewIdsSet = false; - } - else { + } else { mBottomViewIdMap.put(DragEdge.Bottom, bottom); mBottomViewIdsSet = true; } } } + public enum Status { Middle, Open, @@ -1305,7 +1302,8 @@ public class SwipeLayout extends FrameLayout { int l = getPaddingLeft(), t = getPaddingTop(); - if (xvel < 0 && mDragEdges.get(mCurrentDirectionIndex) == DragEdge.Right) l -= mDragDistance; + if (xvel < 0 && mDragEdges.get(mCurrentDirectionIndex) == DragEdge.Right) + l -= mDragDistance; if (xvel > 0 && mDragEdges.get(mCurrentDirectionIndex) == DragEdge.Left) l += mDragDistance; if (yvel > 0 && mDragEdges.get(mCurrentDirectionIndex) == DragEdge.Top) t += mDragDistance; @@ -1362,7 +1360,7 @@ public class SwipeLayout extends FrameLayout { case Bottom: mCurrentDirectionIndex = mBottomIndex; } - open (true, true); + open(true, true); } public void open(boolean smooth, DragEdge edge) { @@ -1376,9 +1374,9 @@ public class SwipeLayout extends FrameLayout { case Bottom: mCurrentDirectionIndex = mBottomIndex; } - open (smooth, true); + open(smooth, true); } - + public void open(boolean smooth, boolean notify, DragEdge edge) { switch (edge) { case Left: @@ -1390,9 +1388,9 @@ public class SwipeLayout extends FrameLayout { case Bottom: mCurrentDirectionIndex = mBottomIndex; } - open (smooth, notify); + open(smooth, notify); } - + /** * smoothly close surface. */