Skip to content

Commit

Permalink
Fix a couple of entry equality checks in the adapter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexbakker committed Nov 15, 2024
1 parent 8eabef2 commit 337d2c3
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position)
int index = _entryList.translateEntryPosToIndex(position);
VaultEntry entry = _entryList.getShownEntries().get(index);

boolean hidden = _tapToReveal && entry != _focusedEntry;
boolean paused = _pauseFocused && entry == _focusedEntry;
boolean dimmed = (_highlightEntry || _tempHighlightEntry) && _focusedEntry != null && _focusedEntry != entry;
boolean hidden = _tapToReveal && !entry.equals(_focusedEntry);
boolean paused = _pauseFocused && entry.equals(_focusedEntry);
boolean dimmed = (_highlightEntry || _tempHighlightEntry) && _focusedEntry != null && !_focusedEntry.equals(entry);
boolean showProgress = entry.getInfo() instanceof TotpInfo && ((TotpInfo) entry.getInfo()).getPeriod() != getMostFrequentPeriod();
boolean showAccountName = true;
if (_onlyShowNecessaryAccountNames) {
Expand All @@ -461,7 +461,7 @@ public void onClick(View v) {

if (_selectedEntries.isEmpty()) {
if (_highlightEntry || _tempHighlightEntry || _tapToReveal) {
if (_focusedEntry == entry) {
if (_focusedEntry != null && _focusedEntry.equals(entry)) {
resetFocus();
} else {
focusEntry(entry, _tapToRevealTime);
Expand Down Expand Up @@ -628,7 +628,7 @@ public void focusEntry(VaultEntry entry, int secondsToFocus) {
_dimHandler.removeCallbacksAndMessages(null);

for (EntryHolder holder : _holders) {
if (holder.getEntry() != _focusedEntry) {
if (!holder.getEntry().equals(_focusedEntry)) {
if (_highlightEntry || _tempHighlightEntry) {
holder.dim();
}
Expand Down Expand Up @@ -703,7 +703,7 @@ public List<VaultEntry> selectAllEntries() {

for (VaultEntry entry: _entryList.getShownEntries()) {
for (EntryHolder holder: _holders) {
if (holder.getEntry() == entry) {
if (holder.getEntry().equals(entry)) {
holder.setFocused(true);
}
}
Expand All @@ -718,7 +718,7 @@ public List<VaultEntry> selectAllEntries() {
public void deselectAllEntries() {
for (VaultEntry entry: _selectedEntries) {
for (EntryHolder holder : _holders) {
if (holder.getEntry() == entry) {
if (holder.getEntry().equals(entry)) {
holder.setFocusedAndAnimate(false);
break;
}
Expand Down

0 comments on commit 337d2c3

Please sign in to comment.