Android: Unset STRIKE_THRU_TEXT_FLAG for editable settings

Because SettingViewHolder is used in RecyclerViews, we have to
explicitly unset STRIKE_THRU_TEXT_FLAG when we don't want it, otherwise
it might be left over from when the SettingViewHolder was representing
a different setting.
This commit is contained in:
JosJuice 2024-04-05 20:12:10 +02:00
parent 4312840a4b
commit eef71d50c3
1 changed files with 7 additions and 2 deletions

View File

@ -28,8 +28,13 @@ abstract class SettingViewHolder(itemView: View, protected val adapter: Settings
val overridden = settingsItem.isOverridden
textView.setTypeface(null, if (overridden) Typeface.BOLD else Typeface.NORMAL)
if (!settingsItem.isEditable) textView.paintFlags =
textView.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
if (settingsItem.isEditable) {
textView.paintFlags =
textView.paintFlags and Paint.STRIKE_THRU_TEXT_FLAG.inv()
} else {
textView.paintFlags =
textView.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
}
}
/**