mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 22:59:18 +01:00
Fix crash with gestures
This commit is contained in:
parent
322f54380d
commit
72b2471619
@ -37,44 +37,52 @@ public class HorizontalViewPager extends ViewPager implements ViewPagerInterface
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
|
try {
|
||||||
if (getCurrentItem() == 0 || getCurrentItem() == getAdapter().getCount() - 1) {
|
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
|
||||||
startDragX = ev.getX();
|
if (getCurrentItem() == 0 || getCurrentItem() == getAdapter().getCount() - 1) {
|
||||||
|
startDragX = ev.getX();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return super.onInterceptTouchEvent(ev);
|
return super.onInterceptTouchEvent(ev);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent ev) {
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
if (onChapterBoundariesOutListener != null) {
|
try {
|
||||||
if (getCurrentItem() == 0) {
|
if (onChapterBoundariesOutListener != null) {
|
||||||
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
if (getCurrentItem() == 0) {
|
||||||
float displacement = ev.getX() - startDragX;
|
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
||||||
|
float displacement = ev.getX() - startDragX;
|
||||||
|
|
||||||
if (ev.getX() > startDragX && displacement > getWidth() * SWIPE_TOLERANCE) {
|
if (ev.getX() > startDragX && displacement > getWidth() * SWIPE_TOLERANCE) {
|
||||||
onChapterBoundariesOutListener.onFirstPageOutEvent();
|
onChapterBoundariesOutListener.onFirstPageOutEvent();
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
startDragX = 0;
|
||||||
}
|
}
|
||||||
|
} else if (getCurrentItem() == getAdapter().getCount() - 1) {
|
||||||
|
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
||||||
|
float displacement = startDragX - ev.getX();
|
||||||
|
|
||||||
startDragX = 0;
|
if (ev.getX() < startDragX && displacement > getWidth() * SWIPE_TOLERANCE) {
|
||||||
}
|
onChapterBoundariesOutListener.onLastPageOutEvent();
|
||||||
} else if (getCurrentItem() == getAdapter().getCount() - 1) {
|
return true;
|
||||||
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
}
|
||||||
float displacement = startDragX - ev.getX();
|
|
||||||
|
|
||||||
if (ev.getX() < startDragX && displacement > getWidth() * SWIPE_TOLERANCE) {
|
startDragX = 0;
|
||||||
onChapterBoundariesOutListener.onLastPageOutEvent();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startDragX = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return super.onTouchEvent(ev);
|
return super.onTouchEvent(ev);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,44 +36,52 @@ public class VerticalViewPager extends VerticalViewPagerImpl implements ViewPage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
|
try {
|
||||||
if (getCurrentItem() == 0 || getCurrentItem() == getAdapter().getCount() - 1) {
|
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
|
||||||
startDragY = ev.getY();
|
if (getCurrentItem() == 0 || getCurrentItem() == getAdapter().getCount() - 1) {
|
||||||
|
startDragY = ev.getY();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return super.onInterceptTouchEvent(ev);
|
return super.onInterceptTouchEvent(ev);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent ev) {
|
public boolean onTouchEvent(MotionEvent ev) {
|
||||||
if (onChapterBoundariesOutListener != null) {
|
try {
|
||||||
if (getCurrentItem() == 0) {
|
if (onChapterBoundariesOutListener != null) {
|
||||||
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
if (getCurrentItem() == 0) {
|
||||||
float displacement = ev.getY() - startDragY;
|
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
||||||
|
float displacement = ev.getY() - startDragY;
|
||||||
|
|
||||||
if (ev.getY() > startDragY && displacement > getHeight() * SWIPE_TOLERANCE) {
|
if (ev.getY() > startDragY && displacement > getHeight() * SWIPE_TOLERANCE) {
|
||||||
onChapterBoundariesOutListener.onFirstPageOutEvent();
|
onChapterBoundariesOutListener.onFirstPageOutEvent();
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
startDragY = 0;
|
||||||
}
|
}
|
||||||
|
} else if (getCurrentItem() == getAdapter().getCount() - 1) {
|
||||||
|
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
||||||
|
float displacement = startDragY - ev.getY();
|
||||||
|
|
||||||
startDragY = 0;
|
if (ev.getY() < startDragY && displacement > getHeight() * SWIPE_TOLERANCE) {
|
||||||
}
|
onChapterBoundariesOutListener.onLastPageOutEvent();
|
||||||
} else if (getCurrentItem() == getAdapter().getCount() - 1) {
|
return true;
|
||||||
if ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
}
|
||||||
float displacement = startDragY - ev.getY();
|
|
||||||
|
|
||||||
if (ev.getY() < startDragY && displacement > getHeight() * SWIPE_TOLERANCE) {
|
startDragY = 0;
|
||||||
onChapterBoundariesOutListener.onLastPageOutEvent();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startDragY = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return super.onTouchEvent(ev);
|
return super.onTouchEvent(ev);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user