0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-19 19:42:17 +02:00

NF: toggleStickyButton is non null

This commit is contained in:
Arthur Milchior 2024-08-29 01:13:51 +02:00 committed by Mike Hardy
parent 1b09ab915a
commit 1fe3e46150

View File

@ -1917,14 +1917,14 @@ class NoteEditor : AnkiFragment(R.layout.note_editor), DeckSelectionListener, Su
}
@NeedsTest("If a field is sticky after synchronization, the toggleStickyButton should be activated.")
private fun setToggleStickyButtonListener(toggleStickyButton: ImageButton?, index: Int) {
private fun setToggleStickyButtonListener(toggleStickyButton: ImageButton, index: Int) {
if (currentFields.getJSONObject(index).getBoolean("sticky")) {
toggleStickyText.getOrPut(index) { "" }
}
if (toggleStickyText[index] == null) {
toggleStickyButton!!.background.alpha = 64
toggleStickyButton.background.alpha = 64
} else {
toggleStickyButton!!.background.alpha = 255
toggleStickyButton.background.alpha = 255
}
toggleStickyButton.setOnClickListener {
onToggleStickyText(
@ -1934,15 +1934,15 @@ class NoteEditor : AnkiFragment(R.layout.note_editor), DeckSelectionListener, Su
}
}
private fun onToggleStickyText(toggleStickyButton: ImageButton?, index: Int) {
private fun onToggleStickyText(toggleStickyButton: ImageButton, index: Int) {
val text = editFields!![index].fieldText
if (toggleStickyText[index] == null) {
toggleStickyText[index] = text
toggleStickyButton!!.background.alpha = 255
toggleStickyButton.background.alpha = 255
Timber.d("Saved Text:: %s", toggleStickyText[index])
} else {
toggleStickyText.remove(index)
toggleStickyButton!!.background.alpha = 64
toggleStickyButton.background.alpha = 64
}
}