File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
AnkiDroid/src/main/java/com/ichi2/anki/settings Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,12 @@ object Prefs {
7575 defValue : Int ,
7676 ): Int = sharedPrefs.getInt(key(keyResId), defValue)
7777
78+ @VisibleForTesting
79+ fun putInt (
80+ @StringRes keyResId : Int ,
81+ defValue : Int ,
82+ ) = sharedPrefs.edit { putInt(key(keyResId), defValue) }
83+
7884 @VisibleForTesting
7985 fun <E > getEnum (
8086 @StringRes keyResId : Int ,
@@ -129,6 +135,26 @@ object Prefs {
129135 }
130136 }
131137
138+ @VisibleForTesting
139+ fun intPref (
140+ @StringRes keyResId : Int ,
141+ defaultValue : Int ,
142+ ): ReadWriteProperty <Any , Int > =
143+ object : ReadWriteProperty <Any ?, Int > {
144+ override fun getValue (
145+ thisRef : Any? ,
146+ property : KProperty <* >,
147+ ): Int = getInt(keyResId, defaultValue)
148+
149+ override fun setValue (
150+ thisRef : Any? ,
151+ property : KProperty <* >,
152+ value : Int ,
153+ ) {
154+ putInt(keyResId, value)
155+ }
156+ }
157+
132158 // ****************************************************************************************** //
133159 // **************************************** Settings **************************************** //
134160 // ****************************************************************************************** //
You can’t perform that action at this time.
0 commit comments