mirror of https://github.com/M66B/FairEmail.git
Scroll instead of fling
This commit is contained in:
parent
5f652f6dda
commit
d46d4cf6b4
|
@ -36,7 +36,7 @@ public class SwipeListener implements View.OnTouchListener {
|
||||||
|
|
||||||
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onFling(MotionEvent me1, MotionEvent me2, float vx, float vy) {
|
public boolean onScroll(MotionEvent me1, MotionEvent me2, float distanceX, float distanceY) {
|
||||||
if (me1 == null || me2 == null)
|
if (me1 == null || me2 == null)
|
||||||
return false;
|
return false;
|
||||||
if (me1.getPointerCount() > 1 || me2.getPointerCount() > 1)
|
if (me1.getPointerCount() > 1 || me2.getPointerCount() > 1)
|
||||||
|
@ -45,8 +45,11 @@ public class SwipeListener implements View.OnTouchListener {
|
||||||
boolean consumed = false;
|
boolean consumed = false;
|
||||||
int dx = Math.round(me2.getX() - me1.getX());
|
int dx = Math.round(me2.getX() - me1.getX());
|
||||||
int dy = Math.round(me2.getY() - me1.getY());
|
int dy = Math.round(me2.getY() - me1.getY());
|
||||||
|
long dt = me2.getEventTime() - me1.getEventTime();
|
||||||
|
long vx = dx * 1000 / dt;
|
||||||
if (Math.abs(dx) > Math.abs(dy)) {
|
if (Math.abs(dx) > Math.abs(dy)) {
|
||||||
Log.i("Swipe dx=" + dx + "/" + MOVE_THRESHOLD + " vx=" + vx + "/" + SPEED_THRESHOLD);
|
Log.i("Swipe dx=" + dx + "/" + MOVE_THRESHOLD +
|
||||||
|
" dt=" + dt + " vx=" + vx + "/" + SPEED_THRESHOLD);
|
||||||
if (Math.abs(dx) > MOVE_THRESHOLD && Math.abs(vx) > SPEED_THRESHOLD)
|
if (Math.abs(dx) > MOVE_THRESHOLD && Math.abs(vx) > SPEED_THRESHOLD)
|
||||||
try {
|
try {
|
||||||
if (dx > 0)
|
if (dx > 0)
|
||||||
|
|
Loading…
Reference in New Issue