Skip to content

Commit

Permalink
Refresh selected note count text when a note is deleted in action mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tuancoltech committed Nov 15, 2024
1 parent 38f1a29 commit bf335b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class NotesListAdapter(

fun removeNote(noteToRemove: Note) {
notes.remove(noteToRemove)
selectedNoteCount.postValue(notes.size)
}

fun setNotes(notes: List<Note>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,9 @@ class NotesFragment : BaseFragment() {
toggleActionMode()
}
binding.tvActionModeSelectAll.setOnClickListener {
if (selectedCountForDelete == notesAdapter?.getNotes()?.size) {
notesAdapter?.toggleSelectAllItems(selected = false)
} else {
notesAdapter?.toggleSelectAllItems(selected = true)
}
notesAdapter?.toggleSelectAllItems(
selected = selectedCountForDelete != notesAdapter?.getNotes()?.size,
)
updateSelectStateTexts(selectedCountForDelete)
}
binding.btnDelete.setOnClickListener {
Expand Down Expand Up @@ -512,11 +510,7 @@ class NotesFragment : BaseFragment() {
selectedCountForDelete = count
updateSelectStateTexts(count)

if (count > 0) {
changeDeleteButtonState(enabled = true)
} else {
changeDeleteButtonState(enabled = false)
}
changeDeleteButtonState(enabled = count > 0)
}
}

Expand Down

0 comments on commit bf335b8

Please sign in to comment.