diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-03-20 00:08:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-20 00:08:04 +0100 |
commit | 53f68ca260c509fa5d81352f9f66ba0407a2a8a2 (patch) | |
tree | 432a46d383aba9a4b7ad59611145b082e88f6c57 | |
parent | 55845c46a1f25fd72de4ffc8ab73368d844375f9 (diff) | |
download | AntennaPod-53f68ca260c509fa5d81352f9f66ba0407a2a8a2.zip |
Make swipe gestures less slippery (#7003)
The sine function made the item move faster than the finger.
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java index bc8cd75c4..28320099a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java @@ -178,14 +178,12 @@ public class SwipeActions extends ItemTouchHelper.SimpleCallback implements Life float sign = dx > 0 ? 1 : -1; float limitMovement = Math.min(maxMovement, sign * dx); float displacementPercentage = limitMovement / maxMovement; + boolean swipeThresholdReached = displacementPercentage >= 0.85; if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE && wontLeave) { swipeOutEnabled = false; - - boolean swipeThresholdReached = displacementPercentage == 1; - // Move slower when getting near the maxMovement - dx = sign * maxMovement * (float) Math.sin((Math.PI / 2) * displacementPercentage); + dx = sign * maxMovement * 0.7f * (float) Math.sin((Math.PI / 2) * displacementPercentage); if (isCurrentlyActive) { int dir = dx > 0 ? ItemTouchHelper.RIGHT : ItemTouchHelper.LEFT; @@ -206,13 +204,10 @@ public class SwipeActions extends ItemTouchHelper.SimpleCallback implements Life .addSwipeLeftActionIcon(left.getActionIcon()) .addSwipeRightBackgroundColor(ThemeUtils.getColorFromAttr(context, R.attr.background_elevated)) .addSwipeLeftBackgroundColor(ThemeUtils.getColorFromAttr(context, R.attr.background_elevated)) - .setActionIconTint( - ColorUtils.blendARGB(themeColor, - actionColor, - Math.max(0.5f, displacementPercentage))); + .setActionIconTint(ColorUtils.blendARGB(themeColor, actionColor, + (!wontLeave || swipeThresholdReached) ? 1.0f : 0.7f)); builder.create().decorate(); - super.onChildDraw(c, recyclerView, viewHolder, dx, dy, actionState, isCurrentlyActive); } |