Make Delegate private interface

This commit is contained in:
tarsin committed 2023-06-02 15:13:37 +08:00
1 parent c4a15f8e00
commit 8fc411a30b
1 file changed
+5 -5
@@ -182,6 +182,11 @@ object Settings : DefaultPreferences() {
var dohUrl by stringPref("doh_url", "")
var lastDawnDay by longPref("last_dawn_day", 0)
private interface Delegate<R> {
operator fun getValue(thisRef: Any?, prop: KProperty<*>?): R
operator fun setValue(thisRef: Any?, prop: KProperty<*>?, value: R)
}
private fun intFromStrPref(key: String, defValue: Int) = object : Delegate<Int> {
private var _value by stringPref(key, defValue.toString())
override fun getValue(thisRef: Any?, prop: KProperty<*>?) = _value.toIntOrNull() ?: defValue
@@ -206,8 +211,3 @@ object Settings : DefaultPreferences() {
}
}
}
interface Delegate<R> {
operator fun getValue(thisRef: Any?, prop: KProperty<*>?): R
operator fun setValue(thisRef: Any?, prop: KProperty<*>?, value: R)
}