[Android] Share RecycledViewPool in AudioAlbumsSongsFragment

Geoffrey Métais git at videolan.org
Wed Jan 11 14:21:12 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 11 10:33:51 2017 +0100| [5e6c1321352ebcdaf87d42a67961b2f55dda2a2f] | committer: Geoffrey Métais

Share RecycledViewPool in AudioAlbumsSongsFragment

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

 .../videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index b580fe2..0d56e14 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -72,7 +72,7 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
     private SwipeRefreshLayout mSwipeRefreshLayout;
     private ViewPager mViewPager;
     TabLayout mTabLayout;
-    private View[] mLists;
+    private ContextMenuRecyclerView[] mLists;
     private AudioBrowserAdapter mSongsAdapter;
     private AudioBrowserAdapter mAlbumsAdapter;
     private FastScroller mFastScroller;
@@ -138,8 +138,15 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
-        for (View rv : mLists)
-            ((RecyclerView) rv).setLayoutManager(new LinearLayoutManager(view.getContext()));
+        RecyclerView.RecycledViewPool rvp = new RecyclerView.RecycledViewPool();
+        for (ContextMenuRecyclerView rv : mLists) {
+            rv.setLayoutManager(new LinearLayoutManager(view.getContext()));
+            LinearLayoutManager llm = new LinearLayoutManager(getActivity());
+            llm.setRecycleChildrenOnDetach(true);
+            rv.setLayoutManager(llm);
+            rv.setRecycledViewPool(rvp);
+        }
+
         mTabLayout.addOnTabSelectedListener(this);
         updateList();
     }



More information about the Android mailing list