Merge branch 'feature/webtoon-margins' of git://github.com/jleehey/tachiyomi into jleehey-feature/webtoon-margins
# Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt # app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt # app/src/main/java/eu/kanade/tachiyomi/util/preference/PreferenceDSL.kt # app/src/main/res/values/strings.xmlpull/2859/head
commit
145a744ce0
@ -0,0 +1,26 @@
|
|||||||
|
package eu.kanade.tachiyomi.widget.preference
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import androidx.preference.ListPreference
|
||||||
|
|
||||||
|
class FloatListPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
|
ListPreference(context, attrs) {
|
||||||
|
|
||||||
|
override fun persistString(value: String?): Boolean {
|
||||||
|
return value != null && persistFloat(value.toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getPersistedString(defaultReturnValue: String?): String? {
|
||||||
|
// When the underlying preference is using a PreferenceDataStore, there's no way (for now)
|
||||||
|
// to check if a value is in the store, so we use a most likely unused value as workaround
|
||||||
|
val defaultIntValue = Float.NEGATIVE_INFINITY
|
||||||
|
|
||||||
|
val value = getPersistedFloat(defaultIntValue)
|
||||||
|
return if (value != defaultIntValue) {
|
||||||
|
value.toString()
|
||||||
|
} else {
|
||||||
|
defaultReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue