Skip to content

Commit 614e087

Browse files
david-allisonBrayanDSO
authored andcommitted
chore: convert ForgetCardsDialog to ViewBinding
Issue 11116
1 parent ffc0395 commit 614e087

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/scheduling/ForgetCardsDialog.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import android.os.Bundle
2121
import androidx.core.content.edit
2222
import androidx.core.os.bundleOf
2323
import androidx.fragment.app.DialogFragment
24-
import com.google.android.material.checkbox.MaterialCheckBox
2524
import com.google.android.material.dialog.MaterialAlertDialogBuilder
2625
import com.google.android.material.snackbar.Snackbar
2726
import com.ichi2.anki.AnkiActivity
2827
import com.ichi2.anki.CollectionManager.TR
2928
import com.ichi2.anki.R
3029
import com.ichi2.anki.common.annotations.NeedsTest
30+
import com.ichi2.anki.databinding.DialogForgetCardsBinding
3131
import com.ichi2.anki.launchCatchingTask
3232
import com.ichi2.anki.libanki.CardId
3333
import com.ichi2.anki.libanki.sched.Scheduler
@@ -94,23 +94,23 @@ class ForgetCardsDialog : DialogFragment() {
9494
resetRepetitionAndLapseCounts = getBoolean(ARG_RESET_REPETITION, false)
9595
}
9696
}
97-
val contentView =
98-
layoutInflater.inflate(R.layout.dialog_forget_cards, null).apply {
99-
findViewById<MaterialCheckBox>(R.id.restore_original_position)!!.apply {
100-
isChecked = restoreOriginalPositionIfPossible
101-
setOnCheckedChangeListener { _, isChecked ->
102-
restoreOriginalPositionIfPossible = isChecked
103-
}
104-
text = TR.schedulingRestorePosition()
105-
}
106-
findViewById<MaterialCheckBox>(R.id.reset_lapse_counts)!!.apply {
107-
isChecked = resetRepetitionAndLapseCounts
108-
setOnCheckedChangeListener { _, isChecked ->
109-
resetRepetitionAndLapseCounts = isChecked
110-
}
111-
text = TR.schedulingResetCounts()
112-
}
97+
val binding = DialogForgetCardsBinding.inflate(layoutInflater)
98+
99+
binding.restoreOriginalPosition.apply {
100+
isChecked = restoreOriginalPositionIfPossible
101+
setOnCheckedChangeListener { _, isChecked ->
102+
restoreOriginalPositionIfPossible = isChecked
113103
}
104+
text = TR.schedulingRestorePosition()
105+
}
106+
binding.resetLapseCounts.apply {
107+
isChecked = resetRepetitionAndLapseCounts
108+
setOnCheckedChangeListener { _, isChecked ->
109+
resetRepetitionAndLapseCounts = isChecked
110+
}
111+
text = TR.schedulingResetCounts()
112+
}
113+
114114
return MaterialAlertDialogBuilder(requireContext()).create {
115115
// BUG: this is 'Reset Card'/'Forget Card' in Anki Desktop (24.04)
116116
// title(text = TR.actionsForgetCard().toSentenceCase(R.string.sentence_forget_cards))
@@ -132,7 +132,7 @@ class ForgetCardsDialog : DialogFragment() {
132132
)
133133
}
134134
negativeButton(R.string.dialog_cancel)
135-
setView(contentView)
135+
setView(binding.root)
136136
}
137137
}
138138

0 commit comments

Comments
 (0)