From 8cae14ca1f37ebeed3fd51fb319d594aba5a7c86 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Mon, 21 Sep 2015 17:56:28 +0300 Subject: [PATCH] Swipe right reimplemented --- OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java | 7 +------ .../net/osmand/plus/widgets/InterceptorFrameLayout.java | 5 +---- .../plus/widgets/tools/SwipeDismissTouchListener.java | 4 ++-- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java index 5d582069a1..10a634a6b5 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashBaseFragment.java @@ -20,9 +20,6 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.widgets.InterceptorFrameLayout; import net.osmand.plus.widgets.tools.SwipeDismissTouchListener; -/** - * Created by Denis on 24.11.2014. - */ public abstract class DashBaseFragment extends Fragment { protected DashboardOnMap dashboard; @@ -72,9 +69,7 @@ public abstract class DashBaseFragment extends Fragment { @Override public void onDismiss(View view, Object token, boolean isSwipeRight) { - if (isSwipeRight) { - getDismissCallback().onDismiss(); - } + getDismissCallback().onDismiss(); } }); frameLayout.setOnTouchListener(listener); diff --git a/OsmAnd/src/net/osmand/plus/widgets/InterceptorFrameLayout.java b/OsmAnd/src/net/osmand/plus/widgets/InterceptorFrameLayout.java index d8e490223f..2229b3163d 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/InterceptorFrameLayout.java +++ b/OsmAnd/src/net/osmand/plus/widgets/InterceptorFrameLayout.java @@ -11,9 +11,6 @@ import android.widget.FrameLayout; import net.osmand.plus.widgets.tools.SwipeDismissTouchListener; -/** - * Created by GaidamakUA on 8/5/15. - */ public class InterceptorFrameLayout extends FrameLayout { private int mTouchSlop; private boolean mIsScrolling; @@ -67,7 +64,7 @@ public class InterceptorFrameLayout extends FrameLayout { } final int xDiff = calculateDistanceX(ev); - if (xDiff > mTouchSlop) { + if (Math.abs(xDiff) > mTouchSlop) { mIsScrolling = true; return true; } diff --git a/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java b/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java index d0b50e20e8..cb3b1910b8 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java +++ b/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java @@ -143,7 +143,7 @@ public class SwipeDismissTouchListener implements View.OnTouchListener { dismiss = (velocityX < 0) == (deltaX < 0); dismissRight = mVelocityTracker.getXVelocity() > 0; } - if (dismiss && dismissRight) { + if (dismiss) { // dismiss final boolean finalDismissRight = dismissRight; ViewCompat.animate(mView) @@ -210,7 +210,7 @@ public class SwipeDismissTouchListener implements View.OnTouchListener { mVelocityTracker.addMovement(motionEvent); float deltaX = motionEvent.getRawX() - mDownX; float deltaY = motionEvent.getRawY() - mDownY; - if (deltaX > mSlop && Math.abs(deltaY) < deltaX / 2) { + if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) { mSwiping = true; mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop); mView.getParent().requestDisallowInterceptTouchEvent(true);