From d567ba1c38700479c5d2d2b5b596709c9d03a8aa Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Mon, 4 Apr 2016 15:30:17 +0300 Subject: [PATCH] Fix swipe --- .../src/net/osmand/plus/dashboard/DashboardOnMap.java | 7 ------- .../controls/SwipeDismissListViewTouchListener.java | 11 ++++++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 0f8e10e4e9..fdcbc4a1dc 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -1413,9 +1413,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis @Override public void onItemSwapping(int position) { - if (swipeDismissListener != null) { - swipeDismissListener.setEnabled(false); - } } @SuppressWarnings("unchecked") @@ -1452,10 +1449,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis getMyApplication().getMapMarkersHelper().saveMapMarkers(markers, null); reloadAdapter(); } - - if (swipeDismissListener != null) { - swipeDismissListener.setEnabled(true); - } } }, 50); } diff --git a/OsmAnd/src/net/osmand/plus/views/controls/SwipeDismissListViewTouchListener.java b/OsmAnd/src/net/osmand/plus/views/controls/SwipeDismissListViewTouchListener.java index ecc0171748..5853342fa3 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/SwipeDismissListViewTouchListener.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/SwipeDismissListViewTouchListener.java @@ -108,6 +108,7 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener { private int mDownPosition; private View mSwipeDownView; private boolean mSwipePaused; + private boolean mSwipeCanceled; private PopupWindow mUndoPopup; private int mValidDelayedMsgId; @@ -635,6 +636,7 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener { mSwipeDownView = mSwipeDownChild = null; mDownPosition = ListView.INVALID_POSITION; mSwiping = false; + mSwipeCanceled = false; break; } @@ -677,17 +679,24 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener { mSwipeDownChild = null; mDownPosition = AbsListView.INVALID_POSITION; mSwiping = false; + mSwipeCanceled = false; break; } case MotionEvent.ACTION_MOVE: { - if (mVelocityTracker == null || mSwipePaused) { + if (mVelocityTracker == null || mSwipePaused || mSwipeCanceled) { break; } mVelocityTracker.addMovement(ev); float deltaX = ev.getRawX() - mDownX; float deltaY = ev.getRawY() - mDownY; + + if (!mSwiping && Math.abs(deltaY) > mSlop * 2) { + mSwipeCanceled = true; + break; + } + // Only start swipe in correct direction if (isSwipeDirectionValid(deltaX)) { ViewParent parent = mListView.getParent();