aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-09-23 23:49:18 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-09-23 23:49:18 +0200
commit07e8729abf448bc47589dc34cd0591bec489d161 (patch)
treecb425714f1754571dbdbd0c8a08dd9a6dd191275 /OpenKeychain/src/main/java/org
parentab4972b4282ec88948b98595de0a4020548996c4 (diff)
downloadopen-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/java/org')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java14
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);
}