mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-23 04:31:15 +01:00
Fixed #697
This commit is contained in:
parent
bb26e3cc92
commit
2551024b20
@ -12,6 +12,7 @@ import androidx.core.view.get
|
|||||||
import com.tfcporciuncula.flow.Preference
|
import com.tfcporciuncula.flow.Preference
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.databinding.MaterialSpinnerViewBinding
|
import eu.kanade.tachiyomi.databinding.MaterialSpinnerViewBinding
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: AttributeSet?) :
|
class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: AttributeSet?) :
|
||||||
FrameLayout(context, attrs) {
|
FrameLayout(context, attrs) {
|
||||||
@ -82,10 +83,10 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
|
|||||||
}
|
}
|
||||||
|
|
||||||
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())
|
|
||||||
this.pref = pref
|
this.pref = pref
|
||||||
prefOffset = 0
|
prefOffset = 0
|
||||||
val intValues = resources.getStringArray(intValuesResource).map { it.toIntOrNull() }
|
val intValues = resources.getStringArray(intValuesResource).map { it.toIntOrNull() }
|
||||||
|
setSelection(max(0,intValues.indexOf(pref.get())))
|
||||||
popup = makeSettingsPopup(pref, intValues, block)
|
popup = makeSettingsPopup(pref, intValues, block)
|
||||||
setOnTouchListener(popup?.dragToOpenListener)
|
setOnTouchListener(popup?.dragToOpenListener)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user