Move the token update to the adapter

This commit is contained in:
Jakob Nixdorf 2017-08-23 14:03:03 +02:00
parent dd97ac87f0
commit f41eb620aa
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
2 changed files with 13 additions and 16 deletions

View file

@ -253,14 +253,7 @@ public class MainActivity extends BaseActivity
animation.setInterpolator(new LinearInterpolator());
animation.start();
boolean change = false;
for(int i =0;i < adapter.getFullItemCount(); i++){
boolean item_changed = adapter.getItem(i).updateOTP();
change = change || item_changed;
}
if (change)
adapter.notifyDataSetChanged();
adapter.updateTokens();
handler.postDelayed(this, 1000);
}

View file

@ -76,14 +76,6 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
return displayedEntries.size();
}
public int getFullItemCount() {
return entries.size();
}
public Entry getItem(int i) {
return entries.get(i);
}
public void addEntry(Entry e) {
entries.add(e);
entriesChanged();
@ -107,6 +99,18 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
entriesChanged();
}
public void updateTokens() {
boolean change = false;
for(int i =0;i < entries.size(); i++){
boolean item_changed = entries.get(i).updateOTP();
change = change || item_changed;
}
if (change)
notifyDataSetChanged();
}
@Override
public void onBindViewHolder(EntryViewHolder entryViewHolder, int i) {
Entry entry = displayedEntries.get(i);