Add flip limit

pull/590/head
FongMi 10 months ago
parent a6ff92e061
commit eea47626a3
  1. 7
      app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownLive.java
  2. 7
      app/src/mobile/java/com/fongmi/android/tv/ui/custom/CustomKeyDownVod.java

@ -27,6 +27,7 @@ public class CustomKeyDownLive extends GestureDetector.SimpleOnGestureListener {
private boolean changeVolume;
private boolean changeSpeed;
private boolean changeTime;
private boolean animating;
private boolean center;
private boolean touch;
private boolean lock;
@ -111,7 +112,7 @@ public class CustomKeyDownLive extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, @NonNull MotionEvent e2, float velocityX, float velocityY) {
if (isEdge(e1) || !center) return true;
if (isEdge(e1) || !center || animating) return true;
checkFunc(e1, e2, velocityX, velocityY);
return true;
}
@ -136,9 +137,9 @@ public class CustomKeyDownLive extends GestureDetector.SimpleOnGestureListener {
} else if (e2.getX() - e1.getX() > DISTANCE && Math.abs(velocityX) > VELOCITY) {
listener.onFlingRight();
} else if (e1.getY() - e2.getY() > DISTANCE && Math.abs(velocityY) > VELOCITY) {
videoView.animate().translationYBy(-80).setDuration(150).withEndAction(() -> videoView.animate().translationY(0).setDuration(100).withEndAction(listener::onFlingUp).start()).start();
videoView.animate().translationYBy(-ResUtil.dp2px(24)).setDuration(150).withStartAction(() -> animating = true).withEndAction(() -> videoView.animate().translationY(0).setDuration(100).withStartAction(listener::onFlingUp).withEndAction(() -> animating = false).start()).start();
} else if (e2.getY() - e1.getY() > DISTANCE && Math.abs(velocityY) > VELOCITY) {
videoView.animate().translationYBy(80).setDuration(150).withEndAction(() -> videoView.animate().translationY(0).setDuration(100).withEndAction(listener::onFlingDown).start()).start();
videoView.animate().translationYBy(ResUtil.dp2px(24)).setDuration(150).withStartAction(() -> animating = true).withEndAction(() -> videoView.animate().translationY(0).setDuration(100).withStartAction(listener::onFlingDown).withEndAction(() -> animating = false).start()).start();
}
}

@ -27,6 +27,7 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
private boolean changeVolume;
private boolean changeSpeed;
private boolean changeTime;
private boolean animating;
private boolean center;
private boolean touch;
private boolean lock;
@ -109,7 +110,7 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, @NonNull MotionEvent e2, float velocityX, float velocityY) {
if (isEdge(e1) || !center) return true;
if (isEdge(e1) || !center || animating) return true;
checkFunc(e1, e2, velocityY);
return true;
}
@ -130,9 +131,9 @@ public class CustomKeyDownVod extends GestureDetector.SimpleOnGestureListener {
private void checkFunc(MotionEvent e1, MotionEvent e2, float velocityY) {
if (e1.getY() - e2.getY() > DISTANCE && Math.abs(velocityY) > VELOCITY) {
videoView.animate().translationYBy(-80).setDuration(150).withEndAction(() -> videoView.animate().translationY(0).setDuration(100).withEndAction(listener::onFlingUp).start()).start();
videoView.animate().translationYBy(-ResUtil.dp2px(24)).setDuration(150).withStartAction(() -> animating = true).withEndAction(() -> videoView.animate().translationY(0).setDuration(100).withStartAction(listener::onFlingUp).withEndAction(() -> animating = false).start()).start();
} else if (e2.getY() - e1.getY() > DISTANCE && Math.abs(velocityY) > VELOCITY) {
videoView.animate().translationYBy(80).setDuration(150).withEndAction(() -> videoView.animate().translationY(0).setDuration(100).withEndAction(listener::onFlingDown).start()).start();
videoView.animate().translationYBy(ResUtil.dp2px(24)).setDuration(150).withStartAction(() -> animating = true).withEndAction(() -> videoView.animate().translationY(0).setDuration(100).withStartAction(listener::onFlingDown).withEndAction(() -> animating = false).start()).start();
}
}

Loading…
Cancel
Save