Created
June 29, 2020 09:03
-
-
Save Krosxx/c2b36b92121780c845232de4db45c482 to your computer and use it in GitHub Desktop.
PreferenceDataStore for SmartKey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.preference.PreferenceDataStore | |
import cn.vove7.smartkey.BaseConfig | |
import cn.vove7.smartkey.get | |
/** | |
* # SmartKeyDataStore | |
* | |
* Created on 2020/6/29 | |
* @author Vove | |
*/ | |
class SmartKeyDataStore( | |
private val config: BaseConfig | |
) : PreferenceDataStore() { | |
override fun getBoolean(key: String?, defValue: Boolean): Boolean { | |
return config[key!!, false, defValue] | |
} | |
override fun putLong(key: String?, value: Long) { | |
config[key!!] = value | |
} | |
override fun putInt(key: String?, value: Int) { | |
config[key!!] = value | |
} | |
override fun getInt(key: String?, defValue: Int): Int { | |
return config[key!!, defValue] | |
} | |
override fun putBoolean(key: String?, value: Boolean) { | |
config[key!!] = value | |
} | |
override fun getLong(key: String?, defValue: Long): Long { | |
return config[key!!, defValue] | |
} | |
override fun getFloat(key: String?, defValue: Float): Float { | |
return config[key!!, defValue] | |
} | |
override fun putFloat(key: String?, value: Float) { | |
config[key!!] = value | |
} | |
override fun getString(key: String?, defValue: String?): String? { | |
return config[key!!, defValue] | |
} | |
override fun putString(key: String?, value: String?) { | |
config[key!!] = value | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment