[Android] [PATCH 2/3] Clear list filter on small search query string

Romain Vimont rom at rom1v.com
Tue Nov 7 18:34:46 CET 2017


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).
---
 vlc-android/src/org/videolan/vlc/gui/ContentActivity.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 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..ccefd9771 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();
         if (current instanceof Filterable) {
-            ((Filterable) current).getFilter().filter(filterQueryString);
+            Filterable filterable = (Filterable) current;
+            if (filterQueryString.length() < 3)
+                filterable.restoreList();
+            else
+                filterable.getFilter().filter(filterQueryString);
             return true;
         }
         return false;
-- 
2.11.0



More information about the Android mailing list