[Android] Fix Select subtitles crash

Alexandre Perraud git at videolan.org
Mon Dec 12 11:22:21 CET 2016


vlc-android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Thu Dec  8 16:50:59 2016 +0100| [ad258a412b97d10b236e8d04ef1a3a1e939e9946] | committer: Alexandre Perraud

Fix Select subtitles crash

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

 .../vlc/gui/browser/MediaBrowserFragment.java      | 27 +++++++++++++---------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
index 76064f6..baffa5a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
@@ -77,21 +77,25 @@ public abstract class MediaBrowserFragment extends PlaybackServiceFragment imple
             activity.getSupportActionBar().setSubtitle(getSubTitle());
             getActivity().supportInvalidateOptionsMenu();
         }
-        mFabPlay = (FloatingActionButton)getActivity().findViewById(R.id.fab);
-        setFabPlayVisibility(false);
-        mFabPlay.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                onFabPlayClick(v);
-            }
-        });
+        mFabPlay = (FloatingActionButton) getActivity().findViewById(R.id.fab);
+        if (mFabPlay != null) {
+            setFabPlayVisibility(false);
+            mFabPlay.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    onFabPlayClick(v);
+                }
+            });
+        }
     }
 
     @Override
     public void onStop() {
         super.onStop();
-        mFabPlay.setOnClickListener(null);
-        setFabPlayVisibility(false);
+        if (mFabPlay != null) {
+            mFabPlay.setOnClickListener(null);
+            setFabPlayVisibility(false);
+        }
     }
 
     @Override
@@ -101,7 +105,8 @@ public abstract class MediaBrowserFragment extends PlaybackServiceFragment imple
     }
 
     public void setFabPlayVisibility(boolean enable) {
-        mFabPlay.setVisibility(enable ? View.VISIBLE : View.INVISIBLE);
+        if (mFabPlay != null)
+            mFabPlay.setVisibility(enable ? View.VISIBLE : View.INVISIBLE);
     }
 
     public void onFabPlayClick(View view) {}



More information about the Android mailing list