Skip to content

Commit

Permalink
fix: add radio button to RadioListItem click listener
Browse files Browse the repository at this point in the history
While testing this out I noticed I could get into a state where multiple radio buttons were selected. It turns out that:

1. I was not using the setClickListener from RadioListItem
2. The RadioListItem does not listen to clicks specifically from the RadioButton

I therefore added click listening to the RadioButton so that we can't get into that weird state.
  • Loading branch information
mikescamell committed Sep 3, 2024
1 parent 6d47de2 commit 3ac59e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ class ShowOnAppLaunchActivity : DuckDuckGoActivity() {
}

private fun configureUiEventHandlers() {
binding.lastOpenedTabCheckListItem.setOnClickListener {
binding.lastOpenedTabCheckListItem.setClickListener {
viewModel.onShowOnAppLaunchOptionChanged(LastOpenedTab)
}

binding.newTabCheckListItem.setOnClickListener {
binding.newTabCheckListItem.setClickListener {
viewModel.onShowOnAppLaunchOptionChanged(NewTabPage)
}

binding.specificPageCheckListItem.setOnClickListener {
binding.specificPageCheckListItem.setClickListener {
viewModel.onShowOnAppLaunchOptionChanged(SpecificPage(binding.specificPageUrlInput.text))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class RadioListItem @JvmOverloads constructor(
}

fun setClickListener(onClick: () -> Unit) {
binding.radioButton.setOnClickListener { onClick() }
binding.itemContainer.setOnClickListener { onClick() }
}

Expand Down

0 comments on commit 3ac59e0

Please sign in to comment.