[Android] prevent NPE

Geoffrey Métais git at videolan.org
Thu Jul 27 09:30:15 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jul 27 09:27:13 2017 +0200| [aab156eb6c2643f23932b02ce9c2c7d89ef28274] | committer: Geoffrey Métais

prevent NPE

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

 .../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java       | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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 a0cb0db5b..7fce72aed 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -108,7 +108,7 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
     protected boolean goBack = false;
     private final boolean mShowHiddenFiles;
 
-    private SimpleArrayMap<MediaLibraryItem, ArrayList<MediaLibraryItem>> mFoldersContentLists = new SimpleArrayMap<>();
+    private SimpleArrayMap<MediaLibraryItem, ArrayList<MediaLibraryItem>> mFoldersContentLists;
     public int mCurrentParsedPosition = 0;
 
     protected abstract Fragment createFragment();
@@ -140,6 +140,8 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
         if (bundle != null) {
             if (VLCApplication.hasData(KEY_CONTENT_LIST))
                 mFoldersContentLists = (SimpleArrayMap<MediaLibraryItem, ArrayList<MediaLibraryItem>>) VLCApplication.getData(KEY_CONTENT_LIST);
+            if (mFoldersContentLists == null)
+                mFoldersContentLists = new SimpleArrayMap<>();
             mCurrentMedia = bundle.getParcelable(KEY_MEDIA);
             if (mCurrentMedia != null)
                 mMrl = mCurrentMedia.getLocation();
@@ -281,7 +283,7 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
         FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
         Fragment next = createFragment();
         Bundle args = new Bundle();
-        ArrayList<MediaLibraryItem> list = mFoldersContentLists != null ? mFoldersContentLists.get(media) : null;
+        ArrayList<MediaLibraryItem> list = mFoldersContentLists.get(media);
         if (!Util.isListEmpty(list) && !(this instanceof StorageBrowserFragment))
             VLCApplication.storeData(KEY_MEDIA_LIST+media.getLocation(), list);
         args.putParcelable(KEY_MEDIA, media);



More information about the Android mailing list