Skip to content

Commit

Permalink
Clicking on a note item in selection mode should toggle the checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
tuancoltech committed Nov 15, 2024
1 parent bf335b8 commit 1803fad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class NotesListAdapter(
) : RecyclerView.Adapter<NotesListAdapter.NoteViewHolder>() {
private lateinit var activity: MainActivity
private var mActionMode = false
private var checkedByItemClick = false

lateinit var observeItemSideEffect: () -> ArkMediaPlayerSideEffect
lateinit var observeItemState: () -> ArkMediaPlayerState
Expand Down Expand Up @@ -289,6 +290,11 @@ class NotesListAdapter(

private val clickNoteToEditListener =
View.OnClickListener {
if (mActionMode) {
checkedByItemClick = true
binding.cbDelete.toggle()
return@OnClickListener
}
var tag = EditTextNotesFragment.TAG
when (val selectedNote = notes[bindingAdapterPosition]) {
is TextNote -> activity.fragment = EditTextNotesFragment.newInstance(selectedNote)
Expand All @@ -307,7 +313,9 @@ class NotesListAdapter(

private val noteCheckedListener =
CompoundButton.OnCheckedChangeListener { buttonView, isChecked ->
if (!buttonView.isPressed) return@OnCheckedChangeListener
if (!buttonView.isPressed && !checkedByItemClick) return@OnCheckedChangeListener
checkedByItemClick = false

val selectedNote = notes[bindingAdapterPosition]
selectedNote.selected = isChecked
if (isChecked) {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#0C111D"
android:alpha="0.7"
android:background="#CC0C111D"
android:id="@+id/view_fab_background"
android:visibility="gone"
android:clickable="true"
Expand Down

0 comments on commit 1803fad

Please sign in to comment.