[Android] Prevent NPE

Geoffrey Métais git at videolan.org
Mon Aug 28 09:43:03 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Aug 28 09:39:47 2017 +0200| [2dbb3bd08ca192e9c56f767a3cd939e4dfdd3122] | committer: Geoffrey Métais

Prevent NPE

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

 vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java      | 4 +++-
 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 3 ++-
 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java     | 3 ++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java b/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
index 10aa5e994..b6f3ed193 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
@@ -189,7 +189,9 @@ public abstract class BaseAudioBrowser extends SortableFragment<AudioBrowserAdap
     public void onUpdateFinished(RecyclerView.Adapter adapter) {}
 
     public void restoreList() {
-        getCurrentAdapter().restoreList();
+        final AudioBrowserAdapter adapter = getCurrentAdapter();
+        if (adapter != null)
+            adapter.restoreList();
     }
 
     @Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index ae6af2c11..94ef519c5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -768,7 +768,8 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
     }
 
     public void restoreList() {
-        mAdapter.restoreList();
+        if (mAdapter != null)
+            mAdapter.restoreList();
     }
     public void setSearchVisibility(boolean visible) {
         UiTools.setViewVisibility(mSearchButtonView, visible ? View.VISIBLE : View.GONE);
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index b187bc5ed..ffe9c8674 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -438,7 +438,8 @@ public class VideoGridFragment extends SortableFragment<VideoListAdapter> implem
 
     @Override
     public void restoreList() {
-        mAdapter.restoreList();
+        if (mAdapter != null)
+            mAdapter.restoreList();
     }
 
     @Override



More information about the Android mailing list