diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-09-23 23:49:18 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-09-23 23:49:18 +0200 |
commit | 07e8729abf448bc47589dc34cd0591bec489d161 (patch) | |
tree | cb425714f1754571dbdbd0c8a08dd9a6dd191275 /OpenKeychain/src/main | |
parent | ab4972b4282ec88948b98595de0a4020548996c4 (diff) | |
download | open-keychain-07e8729abf448bc47589dc34cd0591bec489d161.tar.gz open-keychain-07e8729abf448bc47589dc34cd0591bec489d161.tar.bz2 open-keychain-07e8729abf448bc47589dc34cd0591bec489d161.zip |
fix nullpointer in previous swipetorefresh fix
Diffstat (limited to 'OpenKeychain/src/main')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java index 818d92390..b3c3eb417 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java @@ -88,11 +88,15 @@ public class ListAwareSwipeRefreshLayout extends NoScrollableSwipeRefreshLayout */ @Override public boolean onTouchEvent(MotionEvent event) { - float ratioX = event.getX() / event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax(); - float ratioY = event.getY() / event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax(); - // if this is the upper right corner, don't handle as pull to refresh event - if (ratioX > 0.85f && ratioY < 0.15f) { - return false; + // The device may be null. This actually happens + 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 (ratioX > 0.85f && ratioY < 0.15f) { + return false; + } } return super.onTouchEvent(event); } |