[Android] Catch onInterceptTouchEvent NullPointerException
Geoffrey Métais
git at videolan.org
Tue Feb 14 18:54:38 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 14 13:33:27 2017 +0100| [766d8e8c39341b2a3f831e8e32ce7ea67960eea2] | committer: Geoffrey Métais
Catch onInterceptTouchEvent NullPointerException
Due to bug https://code.google.com/p/android/issues/detail?id=232646
Patch proposed: https://android-review.googlesource.com/#/c/338505/
revert once AppCompat fixes this
> https://code.videolan.org/videolan/vlc-android/commit/766d8e8c39341b2a3f831e8e32ce7ea67960eea2
---
vlc-android/res/layout/main.xml | 2 +-
vlc-android/res/layout/secondary.xml | 2 +-
.../vlc/gui/helpers/BottomSheetBehavior.java | 28 ++++++++++++++++++++++
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/vlc-android/res/layout/main.xml b/vlc-android/res/layout/main.xml
index 0228758..09490dd 100644
--- a/vlc-android/res/layout/main.xml
+++ b/vlc-android/res/layout/main.xml
@@ -29,7 +29,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
- app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
+ app:layout_behavior="org.videolan.vlc.gui.helpers.BottomSheetBehavior">
<android.support.v7.widget.ViewStubCompat
android:id="@+id/audio_player_stub"
android:layout_width="match_parent"
diff --git a/vlc-android/res/layout/secondary.xml b/vlc-android/res/layout/secondary.xml
index c451c41..f7a32f9 100644
--- a/vlc-android/res/layout/secondary.xml
+++ b/vlc-android/res/layout/secondary.xml
@@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
- vlc:layout_behavior="android.support.design.widget.BottomSheetBehavior">
+ vlc:layout_behavior="org.videolan.vlc.gui.helpers.BottomSheetBehavior">
<android.support.v7.widget.ViewStubCompat
android:id="@+id/audio_player_stub"
android:layout_width="match_parent"
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java b/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java
new file mode 100644
index 0000000..618d80b
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/BottomSheetBehavior.java
@@ -0,0 +1,28 @@
+package org.videolan.vlc.gui.helpers;
+
+import android.content.Context;
+import android.support.design.widget.CoordinatorLayout;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+
+
+public class BottomSheetBehavior<V extends View> extends android.support.design.widget.BottomSheetBehavior<V> {
+ public static final String TAG = "VLC/BottomSheetBehavior";
+
+ public BottomSheetBehavior() {}
+
+ public BottomSheetBehavior(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) {
+ try {
+ return super.onInterceptTouchEvent(parent, child, event);
+ } catch (NullPointerException ignored) {
+ // BottomSheetBehavior receives input events too soon and mNestedScrollingChildRef is not set yet.
+ return false;
+ }
+ }
+}
More information about the Android
mailing list