mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 00:01:54 +01:00
Fix binding of intarray preferences (maybe fixes #4728)
This commit is contained in:
parent
71aa592111
commit
0437703cbf
@ -16,7 +16,6 @@ class SpinnerPreference @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
FrameLayout(context, attrs) {
|
FrameLayout(context, attrs) {
|
||||||
|
|
||||||
private var entries = emptyList<String>()
|
private var entries = emptyList<String>()
|
||||||
private var prefOffset = 0
|
|
||||||
private var popup: PopupMenu? = null
|
private var popup: PopupMenu? = null
|
||||||
|
|
||||||
var onItemSelectedListener: ((Int) -> Unit)? = null
|
var onItemSelectedListener: ((Int) -> Unit)? = null
|
||||||
@ -54,9 +53,8 @@ class SpinnerPreference @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
|
|
||||||
fun bindToPreference(pref: Preference<Int>, offset: Int = 0, block: ((Int) -> Unit)? = null) {
|
fun bindToPreference(pref: Preference<Int>, offset: Int = 0, block: ((Int) -> Unit)? = null) {
|
||||||
setSelection(pref.get() - offset)
|
setSelection(pref.get() - offset)
|
||||||
prefOffset = offset
|
|
||||||
|
|
||||||
popup = makeSettingsPopup(pref, prefOffset, block)
|
popup = makeSettingsPopup(pref, offset, block)
|
||||||
setOnTouchListener(popup?.dragToOpenListener)
|
setOnTouchListener(popup?.dragToOpenListener)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
popup?.show()
|
popup?.show()
|
||||||
@ -75,9 +73,8 @@ class SpinnerPreference @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun bindToIntPreference(pref: Preference<Int>, @ArrayRes intValuesResource: Int, block: ((Int) -> Unit)? = null) {
|
fun bindToIntPreference(pref: Preference<Int>, @ArrayRes intValuesResource: Int, block: ((Int) -> Unit)? = null) {
|
||||||
setSelection(pref.get())
|
|
||||||
prefOffset = 0
|
|
||||||
val intValues = resources.getStringArray(intValuesResource).map { it.toIntOrNull() }
|
val intValues = resources.getStringArray(intValuesResource).map { it.toIntOrNull() }
|
||||||
|
setSelection(intValues.indexOf(pref.get()))
|
||||||
|
|
||||||
popup = makeSettingsPopup(pref, intValues, block)
|
popup = makeSettingsPopup(pref, intValues, block)
|
||||||
setOnTouchListener(popup?.dragToOpenListener)
|
setOnTouchListener(popup?.dragToOpenListener)
|
||||||
|
Loading…
Reference in New Issue
Block a user