aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJohannes Baiter <johannes.baiter@gmail.com>2014-10-29 02:55:26 +0100
committerJohannes Baiter <johannes.baiter@gmail.com>2014-10-29 02:55:26 +0100
commitac57d0d6d43a5029aa010c4fee11c4df93fb092e (patch)
treeeeaf4724fb3a851dcd5b7ce64441c18e11d64eae /app
parentdf1109cde56acb8538256bdeccbc47664aea4f4a (diff)
Fix filtering when loosening query
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
index 4d433013..6058d169 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
@@ -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));
+ }
}
}
}