[Android] Catch NPE in AppCompat

Geoffrey Métais git at videolan.org
Mon Jun 12 17:24:10 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jun 12 15:55:13 2017 +0200| [9a29f759c8fcb32fbfb4c458ccfe16ce0833d7fa] | committer: Geoffrey Métais

Catch NPE in AppCompat

> https://code.videolan.org/videolan/vlc-android/commit/9a29f759c8fcb32fbfb4c458ccfe16ce0833d7fa
---

 .../videolan/vlc/gui/helpers/BottomSheetBehavior.java | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java b/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java
index 87ceec9fe..2fda92391 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java
@@ -36,6 +36,25 @@ public class BottomSheetBehavior<V extends View> extends android.support.design.
     }
 
     @Override
+    public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) {
+        try {
+            super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
+        } catch (NullPointerException ignored) {
+            //Same crash, weakref not already set.
+        }
+    }
+
+    @Override
+    public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, V child, View target, float velocityX, float velocityY) {
+        try {
+            return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
+        } catch (NullPointerException ignored) {
+            //Same crash, weakref not already set.
+        }
+        return false;
+    }
+
+    @Override
     public boolean onTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
         try {
             return super.onTouchEvent(parent, child, event);



More information about the Android mailing list