Make swipes easier to trigger
This commit is contained in:
parent
87514b4107
commit
f7137e45e0
@ -251,6 +251,8 @@ public final class CoverView extends View implements Handler.Callback {
|
|||||||
velocityTracker.computeCurrentVelocity(250);
|
velocityTracker.computeCurrentVelocity(250);
|
||||||
int velocityX = (int) velocityTracker.getXVelocity();
|
int velocityX = (int) velocityTracker.getXVelocity();
|
||||||
int velocityY = (int) velocityTracker.getYVelocity();
|
int velocityY = (int) velocityTracker.getYVelocity();
|
||||||
|
int mvx = Math.abs(velocityX);
|
||||||
|
int mvy = Math.abs(velocityY);
|
||||||
|
|
||||||
int min = mSongs[0] == null ? 1 : 0;
|
int min = mSongs[0] == null ? 1 : 0;
|
||||||
int max = 2;
|
int max = 2;
|
||||||
@ -265,14 +267,18 @@ public final class CoverView extends View implements Handler.Callback {
|
|||||||
else
|
else
|
||||||
performClick();
|
performClick();
|
||||||
whichCover = 1;
|
whichCover = 1;
|
||||||
} else if (velocityX > sSnapVelocity) {
|
} else if (mvx > sSnapVelocity || mvy > sSnapVelocity) {
|
||||||
whichCover = min;
|
if (mvy > mvx) {
|
||||||
} else if (velocityX < -sSnapVelocity) {
|
if (velocityY > 0)
|
||||||
whichCover = max;
|
mCallback.downSwipe();
|
||||||
} else if (velocityY < -sSnapVelocity) {
|
else
|
||||||
mCallback.upSwipe();
|
mCallback.upSwipe();
|
||||||
} else if (velocityY > sSnapVelocity) {
|
} else {
|
||||||
mCallback.downSwipe();
|
if (velocityX > 0)
|
||||||
|
whichCover = min;
|
||||||
|
else
|
||||||
|
whichCover = max;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
int nearestCover = (scrollX + width / 2) / width;
|
int nearestCover = (scrollX + width / 2) / width;
|
||||||
whichCover = Math.max(min, Math.min(nearestCover, max));
|
whichCover = Math.max(min, Math.min(nearestCover, max));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user