[Android] BottomSheetBehavior: Catch wild NPE

Geoffrey Métais git at videolan.org
Wed Jan 23 15:35:13 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 23 15:30:11 2019 +0100| [8c653b5be93b72a6958c87efe643b5e11c9543cb] | committer: Geoffrey Métais

BottomSheetBehavior: Catch wild NPE

> https://code.videolan.org/videolan/vlc-android/commit/8c653b5be93b72a6958c87efe643b5e11c9543cb
---

 .../src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java  | 10 ++++++++++
 1 file changed, 10 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 94c1ffbc5..fc1445b12 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java
@@ -68,6 +68,16 @@ public class BottomSheetBehavior<V extends View> extends com.google.android.mate
         }
     }
 
+    @Override
+    public void onNestedPreScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull V child, @NonNull View target, int dx, int dy, @NonNull int[] consumed, int type) {
+        if (lock) return;
+        try {
+            super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type);
+        } catch (NullPointerException ignored) {
+            //Same crash, weakref not already set.
+        }
+    }
+
     @Override
     public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, V child, View target, int dx, int dy, int[] consumed) {
         if (lock) return;



More information about the Android mailing list