altosdroid: Don't crash when the map is touched
authorKeith Packard <keithp@keithp.com>
Fri, 13 Jun 2014 22:53:30 +0000 (15:53 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 13 Jun 2014 22:53:30 +0000 (15:53 -0700)
The map 'canScroll' method was crashing when dereferencing a null
value somewhere. Just check all of them and bail instead of crashing.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java

index ebddc2661023a1d960a90eec0b3606104bbd4652..223ae75a0e48f9e99f91f0b85a758ee260e08730 100644 (file)
@@ -34,10 +34,14 @@ public class AltosViewPager extends ViewPager {
 
     @Override
     protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
-        if(v.getClass().getPackage().getName().startsWith("maps.")){
+       if(v.getClass() != null &&
+          v.getClass().getPackage() != null &&
+          v.getClass().getPackage().getName() != null &&
+          v.getClass().getPackage().getName().startsWith("maps."))
+       {
             return true;
         }
         return super.canScroll(v, checkV, dx, x, y);
     }
 
-}
\ No newline at end of file
+}