[Android] Clear list filter on small search query string

Romain Vimont git at videolan.org
Thu Nov 9 16:59:17 CET 2017


vlc-android | branch: 2.5.x | Romain Vimont <rom at rom1v.com> | Tue Nov  7 18:34:46 2017 +0100| [a87c06b147fe1afb0687d196047fcd96543a6154] | committer: Geoffrey Métais

Clear list filter on small search query string

When a query having less than 3 chars was requested, it did nothing.

As a consequence, searching "xy" did not always give the same filtering:

   query   filter applied
   -----   ----------------
      ""   none (full list)
    "xy"   none (full list)
   "xyz"   "xyz"
    "xy"   "xyz"            <= unexpected

For consistency, always display the full list when the search query is
small.

This paves the way to keep the filter after an activity is destroyed
then re-created (e.g. on screen rotation).

Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>
(cherry picked from commit 947cbaaebd5444ffa424bbfd5383d9784f1e07de)

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

 vlc-android/src/org/videolan/vlc/gui/ContentActivity.java | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java b/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java
index 0ae211eab..8c7023201 100644
--- a/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java
@@ -84,11 +84,13 @@ public class ContentActivity extends AudioPlayerContainerActivity implements Sea
 
     @Override
     public boolean onQueryTextChange(String filterQueryString) {
-        if (filterQueryString.length() < 3)
-            return false;
-        Fragment current = getCurrentFragment();
+        final Fragment current = getCurrentFragment();
         if (current instanceof Filterable) {
-            ((Filterable) current).getFilter().filter(filterQueryString);
+            final Filterable filterable = (Filterable) current;
+            if (filterQueryString.length() < 3)
+                filterable.restoreList();
+            else
+                filterable.getFilter().filter(filterQueryString);
             return true;
         }
         return false;



More information about the Android mailing list