[Android] Prevent searchview to be used during scroll

Nicolas Pomepuy git at videolan.org
Tue Feb 26 16:10:38 CET 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Feb 26 16:10:37 2019 +0100| [b30889c25aaf2e000e780465493c5e9cc3c421ee] | committer: Geoffrey Métais

Prevent searchview to be used during scroll

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

 vlc-android/src/org/videolan/vlc/gui/MainActivity.java           | 9 +++++++++
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java     | 5 +++++
 .../src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java   | 5 +++++
 vlc-android/src/org/videolan/vlc/interfaces/Filterable.java      | 2 ++
 4 files changed, 21 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 543875f29..a9c44709f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -55,6 +55,7 @@ import org.videolan.vlc.gui.preferences.PreferencesActivity;
 import org.videolan.vlc.gui.preferences.PreferencesFragment;
 import org.videolan.vlc.gui.video.VideoGridFragment;
 import org.videolan.vlc.gui.view.HackyDrawerLayout;
+import org.videolan.vlc.interfaces.Filterable;
 import org.videolan.vlc.interfaces.IRefreshable;
 import org.videolan.vlc.media.MediaUtils;
 import org.videolan.vlc.util.Constants;
@@ -319,6 +320,14 @@ public class MainActivity extends ContentActivity implements ExtensionManagerSer
         }
     }
 
+    @Override
+    public boolean onMenuItemActionExpand(MenuItem item) {
+        if (getCurrentFragment() instanceof Filterable) {
+            return ((Filterable) getCurrentFragment()).allowedToExpand();
+        }
+        return false;
+    }
+
     public void forceRefresh() {
         forceRefresh(getCurrentFragment());
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index e56e246dc..65efcdff6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -391,4 +391,9 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
             return false;
         }
     };
+
+    @Override
+    public boolean allowedToExpand() {
+        return getCurrentRV().getScrollState() == RecyclerView.SCROLL_STATE_IDLE;
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
index a83830d7f..bcb08a196 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
@@ -371,4 +371,9 @@ public abstract class MediaBrowserFragment<T extends SortableModel> extends Frag
             cs.applyTo(cl);
         } else UiTools.setViewVisibility(mSearchButtonView, visible ? View.VISIBLE : View.GONE);
     }
+
+    @Override
+    public boolean allowedToExpand() {
+        return true;
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/interfaces/Filterable.java b/vlc-android/src/org/videolan/vlc/interfaces/Filterable.java
index a3689e792..ad37c6e99 100644
--- a/vlc-android/src/org/videolan/vlc/interfaces/Filterable.java
+++ b/vlc-android/src/org/videolan/vlc/interfaces/Filterable.java
@@ -7,4 +7,6 @@ public interface Filterable {
     void restoreList();
     void setSearchVisibility(boolean visible);
     String getFilterQuery();
+
+    boolean allowedToExpand();
 }



More information about the Android mailing list