From 0437703cbf128b6d638c5acff511c8a961fa8fc6 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 28 Mar 2021 17:06:56 -0400 Subject: [PATCH] Fix binding of intarray preferences (maybe fixes #4728) --- .../tachiyomi/ui/reader/setting/SpinnerPreference.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/SpinnerPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/SpinnerPreference.kt index 28b7b99d1..c0183075c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/SpinnerPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/SpinnerPreference.kt @@ -16,7 +16,6 @@ class SpinnerPreference @JvmOverloads constructor(context: Context, attrs: Attri FrameLayout(context, attrs) { private var entries = emptyList() - private var prefOffset = 0 private var popup: PopupMenu? = null var onItemSelectedListener: ((Int) -> Unit)? = null @@ -54,9 +53,8 @@ class SpinnerPreference @JvmOverloads constructor(context: Context, attrs: Attri fun bindToPreference(pref: Preference, offset: Int = 0, block: ((Int) -> Unit)? = null) { setSelection(pref.get() - offset) - prefOffset = offset - popup = makeSettingsPopup(pref, prefOffset, block) + popup = makeSettingsPopup(pref, offset, block) setOnTouchListener(popup?.dragToOpenListener) setOnClickListener { popup?.show() @@ -75,9 +73,8 @@ class SpinnerPreference @JvmOverloads constructor(context: Context, attrs: Attri } fun bindToIntPreference(pref: Preference, @ArrayRes intValuesResource: Int, block: ((Int) -> Unit)? = null) { - setSelection(pref.get()) - prefOffset = 0 val intValues = resources.getStringArray(intValuesResource).map { it.toIntOrNull() } + setSelection(intValues.indexOf(pref.get())) popup = makeSettingsPopup(pref, intValues, block) setOnTouchListener(popup?.dragToOpenListener)