diff --git a/app/src/main/java/eu/faircode/email/AdapterFolder.java b/app/src/main/java/eu/faircode/email/AdapterFolder.java index 747d9d7253..73bfcee6a9 100644 --- a/app/src/main/java/eu/faircode/email/AdapterFolder.java +++ b/app/src/main/java/eu/faircode/email/AdapterFolder.java @@ -101,9 +101,10 @@ public class AdapterFolder extends RecyclerView.Adapter disabledIds = new ArrayList<>(); private List all = new ArrayList<>(); - private List items = new ArrayList<>(); + private List selected = new ArrayList<>(); private NumberFormat NF = NumberFormat.getNumberInstance(); @@ -393,7 +394,7 @@ public class AdapterFolder extends RecyclerView.Adapter folders) { - Log.i("Set folders=" + folders.size()); + Log.i("Set folders=" + folders.size() + " search=" + search); all = folders; List hierarchical; @@ -1237,9 +1238,20 @@ public class AdapterFolder extends RecyclerView.Adapter items; + if (TextUtils.isEmpty(search)) + items = hierarchical; + else { + items = new ArrayList<>(); + String query = search.toLowerCase().trim(); + for (TupleFolderEx item : hierarchical) + if (item.getDisplayName(context).toLowerCase().contains(query)) + items.add(item); + } + + DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(selected, items), false); - items = hierarchical; + selected = items; diff.dispatchUpdatesTo(new ListUpdateCallback() { @Override @@ -1265,6 +1277,12 @@ public class AdapterFolder extends RecyclerView.Adapter