[Android] Audio scroll: minor performance optimization

Geoffrey Métais git at videolan.org
Mon Nov 19 17:07:09 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Nov 16 17:47:29 2018 +0100| [cef8f6be92b656e91cf61197fde4b2cdb077cbd8] | committer: Geoffrey Métais

Audio scroll: minor performance optimization

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

 .../src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java     | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 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 b9d87f467..be8c23027 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
@@ -57,8 +57,8 @@ import androidx.recyclerview.widget.RecyclerView;
 
 public abstract class BaseAudioBrowser extends MediaBrowserFragment<MLPagedModel> implements IEventsHandler, CtxActionReceiver {
 
-    public ContentActivity mActivity;
-    protected AudioBrowserAdapter[] mAdapters;
+    ContentActivity mActivity;
+    AudioBrowserAdapter[] mAdapters;
     protected AudioBrowserAdapter mAdapter;
 
     public AudioBrowserAdapter getCurrentAdapter() {
@@ -144,7 +144,7 @@ public abstract class BaseAudioBrowser extends MediaBrowserFragment<MLPagedModel
         onDestroyActionMode(getCurrentAdapter());
     }
 
-    public void onDestroyActionMode(AudioBrowserAdapter adapter) {
+    void onDestroyActionMode(AudioBrowserAdapter adapter) {
         setFabPlayVisibility(true);
         mActionMode = null;
         adapter.getMultiSelectHelper().clearSelection();
@@ -234,9 +234,13 @@ public abstract class BaseAudioBrowser extends MediaBrowserFragment<MLPagedModel
         }
     }
 
-    protected final RecyclerView.OnScrollListener mScrollListener = new RecyclerView.OnScrollListener() {
+    final RecyclerView.OnScrollListener mScrollListener = new RecyclerView.OnScrollListener() {
         @Override
         public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
+            if (newState != RecyclerView.SCROLL_STATE_IDLE) {
+                mSwipeRefreshLayout.setEnabled(false);
+                return;
+            }
             final LinearLayoutManager llm = (LinearLayoutManager)getCurrentRV().getLayoutManager();
             if (llm == null) return;
             mSwipeRefreshLayout.setEnabled(llm.findFirstVisibleItemPosition() <= 0);



More information about the Android mailing list