Fix a couple of entry equality checks in the adapter

With the introduction of DiffUtil, an entry might not be the same
instance in the in-memory vault as in the shown entry list of the
adapter.
This commit is contained in:
Alexander Bakker 2024-11-15 15:24:03 +01:00
parent 8eabef2050
commit 337d2c3507

View file

@ -433,9 +433,9 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
int index = _entryList.translateEntryPosToIndex(position); int index = _entryList.translateEntryPosToIndex(position);
VaultEntry entry = _entryList.getShownEntries().get(index); VaultEntry entry = _entryList.getShownEntries().get(index);
boolean hidden = _tapToReveal && entry != _focusedEntry; boolean hidden = _tapToReveal && !entry.equals(_focusedEntry);
boolean paused = _pauseFocused && entry == _focusedEntry; boolean paused = _pauseFocused && entry.equals(_focusedEntry);
boolean dimmed = (_highlightEntry || _tempHighlightEntry) && _focusedEntry != null && _focusedEntry != entry; boolean dimmed = (_highlightEntry || _tempHighlightEntry) && _focusedEntry != null && !_focusedEntry.equals(entry);
boolean showProgress = entry.getInfo() instanceof TotpInfo && ((TotpInfo) entry.getInfo()).getPeriod() != getMostFrequentPeriod(); boolean showProgress = entry.getInfo() instanceof TotpInfo && ((TotpInfo) entry.getInfo()).getPeriod() != getMostFrequentPeriod();
boolean showAccountName = true; boolean showAccountName = true;
if (_onlyShowNecessaryAccountNames) { if (_onlyShowNecessaryAccountNames) {
@ -461,7 +461,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
if (_selectedEntries.isEmpty()) { if (_selectedEntries.isEmpty()) {
if (_highlightEntry || _tempHighlightEntry || _tapToReveal) { if (_highlightEntry || _tempHighlightEntry || _tapToReveal) {
if (_focusedEntry == entry) { if (_focusedEntry != null && _focusedEntry.equals(entry)) {
resetFocus(); resetFocus();
} else { } else {
focusEntry(entry, _tapToRevealTime); focusEntry(entry, _tapToRevealTime);
@ -628,7 +628,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
_dimHandler.removeCallbacksAndMessages(null); _dimHandler.removeCallbacksAndMessages(null);
for (EntryHolder holder : _holders) { for (EntryHolder holder : _holders) {
if (holder.getEntry() != _focusedEntry) { if (!holder.getEntry().equals(_focusedEntry)) {
if (_highlightEntry || _tempHighlightEntry) { if (_highlightEntry || _tempHighlightEntry) {
holder.dim(); holder.dim();
} }
@ -703,7 +703,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
for (VaultEntry entry: _entryList.getShownEntries()) { for (VaultEntry entry: _entryList.getShownEntries()) {
for (EntryHolder holder: _holders) { for (EntryHolder holder: _holders) {
if (holder.getEntry() == entry) { if (holder.getEntry().equals(entry)) {
holder.setFocused(true); holder.setFocused(true);
} }
} }
@ -718,7 +718,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
public void deselectAllEntries() { public void deselectAllEntries() {
for (VaultEntry entry: _selectedEntries) { for (VaultEntry entry: _selectedEntries) {
for (EntryHolder holder : _holders) { for (EntryHolder holder : _holders) {
if (holder.getEntry() == entry) { if (holder.getEntry().equals(entry)) {
holder.setFocusedAndAnimate(false); holder.setFocusedAndAnimate(false);
break; break;
} }