mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-26 00:48:51 -05:00
fix nullpointer in previous swipetorefresh fix
This commit is contained in:
parent
ab4972b428
commit
07e8729abf
@ -88,12 +88,16 @@ public class ListAwareSwipeRefreshLayout extends NoScrollableSwipeRefreshLayout
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
float ratioX = event.getX() / event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax();
|
// The device may be null. This actually happens
|
||||||
float ratioY = event.getY() / event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax();
|
if (event.getDevice() != null) {
|
||||||
|
// MotionEvent.AXIS_X is api level 12, for some reason, so we use a constant 0 here
|
||||||
|
float ratioX = event.getX() / event.getDevice().getMotionRange(0).getMax();
|
||||||
|
float ratioY = event.getY() / event.getDevice().getMotionRange(1).getMax();
|
||||||
// if this is the upper right corner, don't handle as pull to refresh event
|
// if this is the upper right corner, don't handle as pull to refresh event
|
||||||
if (ratioX > 0.85f && ratioY < 0.15f) {
|
if (ratioX > 0.85f && ratioY < 0.15f) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return super.onTouchEvent(event);
|
return super.onTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user