mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-29 13:27:46 +00:00
Fix filtering when loosening query
This commit is contained in:
parent
df1109cde5
commit
ac57d0d6d4
@ -129,13 +129,15 @@ public class PasswordFragment extends Fragment{
|
||||
public void filterAdapter(String filter) {
|
||||
if (filter.isEmpty()) {
|
||||
updateAdapter();
|
||||
return;
|
||||
}
|
||||
for (int i=0; i<recyclerAdapter.getItemCount(); i++) {
|
||||
PasswordItem item = recyclerAdapter.getValues().get(i);
|
||||
boolean matches = item.getName().toLowerCase().contains(filter);
|
||||
if (!matches) {
|
||||
recyclerAdapter.remove(i);
|
||||
} else {
|
||||
for (PasswordItem item : PasswordRepository.getPasswords()) {
|
||||
boolean matches = item.getName().toLowerCase().contains(filter);
|
||||
boolean inAdapter = recyclerAdapter.getValues().contains(item);
|
||||
if (matches && !inAdapter) {
|
||||
recyclerAdapter.add(item);
|
||||
} else if (!matches && inAdapter) {
|
||||
recyclerAdapter.remove(recyclerAdapter.getValues().indexOf(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user