[Android] Catch NPE in BottomSheetBehavior

Geoffrey Métais git at videolan.org
Wed Jan 9 15:47:59 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan  9 15:34:37 2019 +0100| [ef2cef8f7a845dd863bb4d30946fde9eb9d57cff] | committer: Geoffrey Métais

Catch NPE in BottomSheetBehavior

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

 .../org/videolan/vlc/gui/helpers/BottomSheetBehavior.java    | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

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 7b80eff04..f41bd55bb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java
@@ -1,11 +1,13 @@
 package org.videolan.vlc.gui.helpers;
 
 import android.content.Context;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
 import android.view.View;
 
+import androidx.annotation.NonNull;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+
 
 public class BottomSheetBehavior<V extends View> extends com.google.android.material.bottomsheet.BottomSheetBehavior<V> {
     public static final String TAG = "VLC/BottomSheetBehavior";
@@ -32,6 +34,14 @@ public class BottomSheetBehavior<V extends View> extends com.google.android.mate
         }
     }
 
+    @Override
+    public void onStopNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull V child, @NonNull View target, int type) {
+        if (lock) return;
+        try {
+            super.onStopNestedScroll(coordinatorLayout, child, target, type);
+        } catch (NullPointerException ignored) {}
+    }
+
     @Override
     public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, V child, View target) {
         if (lock) return;



More information about the Android mailing list