[Android] Fix browsers content prefetch
Geoffrey Métais
git at videolan.org
Wed Sep 20 11:22:10 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Sep 20 11:20:47 2017 +0200| [2fdb3c4ad49203736b14b856c164d153128429c4] | committer: Geoffrey Métais
Fix browsers content prefetch
Close #366
> https://code.videolan.org/videolan/vlc-android/commit/2fdb3c4ad49203736b14b856c164d153128429c4
---
.../vlc/gui/browser/BaseBrowserFragment.java | 31 +++++++++++++---------
1 file changed, 19 insertions(+), 12 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 a9069fba9..6c3a9d672 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -189,12 +189,17 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
mRecyclerView.setAdapter(mAdapter);
registerForContextMenu(mRecyclerView);
mSwipeRefreshLayout.setOnRefreshListener(this);
- if (savedInstanceState != null) {
- @SuppressWarnings("unchecked")
- final ArrayList<MediaLibraryItem> mediaList = (ArrayList<MediaLibraryItem>) VLCApplication.getData(KEY_MEDIA_LIST+mMrl);
- if (!Util.isListEmpty(mediaList))
- mAdapter.update(mediaList);
- } else
+
+ VLCApplication.storeData(KEY_CONTENT_LIST+mMrl, mFoldersContentLists);
+ @SuppressWarnings("unchecked")
+ final SimpleArrayMap<MediaLibraryItem, ArrayList<MediaLibraryItem>> content = (SimpleArrayMap<MediaLibraryItem, ArrayList<MediaLibraryItem>>) VLCApplication.getData(KEY_CONTENT_LIST + mMrl);
+ if (content != null)
+ mFoldersContentLists = content;
+ @SuppressWarnings("unchecked")
+ final ArrayList<MediaLibraryItem> mediaList = (ArrayList<MediaLibraryItem>) VLCApplication.getData(KEY_MEDIA_LIST + mMrl);
+ if (!Util.isListEmpty(mediaList))
+ mAdapter.update(mediaList);
+ else
refresh();
}
@@ -236,7 +241,7 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
outState.putString(KEY_MRL, mMrl);
outState.putParcelable(KEY_MEDIA, mCurrentMedia);
VLCApplication.storeData(KEY_MEDIA_LIST+mMrl, mAdapter.getAll());
- VLCApplication.storeData(KEY_CONTENT_LIST, mFoldersContentLists);
+ VLCApplication.storeData(KEY_CONTENT_LIST+mMrl, mFoldersContentLists);
if (mRecyclerView != null)
outState.putInt(KEY_POSITION, mLayoutManager.findFirstCompletelyVisibleItemPosition());
super.onSaveInstanceState(outState);
@@ -276,12 +281,14 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
public void browse(MediaWrapper media, int position, boolean save) {
mBrowserHandler.removeCallbacksAndMessages(null);
- FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
- Fragment next = createFragment();
- Bundle args = new Bundle();
- ArrayList<MediaLibraryItem> list = mFoldersContentLists.get(media);
+ final FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
+ final Fragment next = createFragment();
+ final Bundle args = new Bundle();
+ VLCApplication.storeData(KEY_MEDIA_LIST+mMrl, mAdapter.getAll());
+ VLCApplication.storeData(KEY_CONTENT_LIST+ mMrl, mFoldersContentLists);
+ final ArrayList<MediaLibraryItem> list = mFoldersContentLists.get(media);
if (!Util.isListEmpty(list) && !(this instanceof StorageBrowserFragment))
- VLCApplication.storeData(KEY_MEDIA_LIST+media.getLocation(), list);
+ VLCApplication.storeData(KEY_MEDIA_LIST+ media.getLocation(), list);
args.putParcelable(KEY_MEDIA, media);
next.setArguments(args);
if (isRootDirectory())
More information about the Android
mailing list