aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt
diff options
context:
space:
mode:
authorAllan Wang <allanwang@google.com>2019-07-27 17:46:04 -0700
committerAllan Wang <allanwang@google.com>2019-07-27 17:46:04 -0700
commit50c8012e2fe88d6b275d1a3269033590962caa7f (patch)
tree65ebb32525be83441e6caac8362e3e9ae022bfd1 /core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt
parent01058912580a3ecfe77eaf6af209e1c46a97f2d7 (diff)
parentd94017e6f6df67e80604111028ea16f6c7f4e077 (diff)
downloadkau-50c8012e2fe88d6b275d1a3269033590962caa7f.tar.gz
kau-50c8012e2fe88d6b275d1a3269033590962caa7f.tar.bz2
kau-50c8012e2fe88d6b275d1a3269033590962caa7f.zip
Fix initial conflicts
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt
index 7a6330f..fc7a76a 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt
@@ -36,14 +36,18 @@ import ca.allanwang.kau.logging.KL
* You may optionally override [deleteKeys]. This will be called on initialization
* And delete all keys returned from that method
*/
-open class KPref {
+open class KPref(builder: KPrefBuilder = KPrefBuilderAndroid) : KPrefBuilder by builder {
lateinit var PREFERENCE_NAME: String
lateinit var sp: SharedPreferences
- fun initialize(c: Context, preferenceName: String) {
+ fun initialize(
+ c: Context,
+ preferenceName: String,
+ sharedPrefs: SharedPreferences = c.applicationContext.getSharedPreferences(preferenceName, Context.MODE_PRIVATE)
+ ) {
PREFERENCE_NAME = preferenceName
- sp = c.applicationContext.getSharedPreferences(preferenceName, Context.MODE_PRIVATE)
+ sp = sharedPrefs
KL.d { "Shared Preference $preferenceName has been initialized" }
val toDelete = deleteKeys()
if (toDelete.isNotEmpty()) {