diff --git a/safedepositbox/build.gradle b/safedepositbox/build.gradle index 9e2b6e7..336cbfb 100644 --- a/safedepositbox/build.gradle +++ b/safedepositbox/build.gradle @@ -9,8 +9,8 @@ android { defaultConfig { minSdkVersion 21 targetSdkVersion 29 - versionCode 2 - versionName "1.1" + versionCode 3 + versionName "0.3" consumerProguardFiles 'consumer-rules.pro' } diff --git a/safedepositbox/src/main/java/id/codepresso/safedepositbox/SafeDepositBox.kt b/safedepositbox/src/main/java/id/codepresso/safedepositbox/SafeDepositBox.kt index 7f299a9..50afb3c 100644 --- a/safedepositbox/src/main/java/id/codepresso/safedepositbox/SafeDepositBox.kt +++ b/safedepositbox/src/main/java/id/codepresso/safedepositbox/SafeDepositBox.kt @@ -60,7 +60,7 @@ class SafeDepositBox(private val context: Context, private val prefName: String) * @param key SharedPreferences key * @param value String value to be stored */ - fun storeString(key: String, value: String) { + fun storeString(key: String, value: String?) { sharedPrefsEditor.putString(key, value).apply() } @@ -340,14 +340,14 @@ class SafeDepositBox(private val context: Context, private val prefName: String) /** * Get List value from SharedPreferences at 'key'. * @param key SharedPreferences key - * @return List value at 'key' + * @return List value at 'key' or NPE if value not found */ inline fun getListObject(key: String): List { val objectStrings = getListString(key) val objects = mutableListOf() objectStrings.forEach { objectString -> - val value = gson.fromJson(objectString, T::class.java) + val value = gson.fromJson(objectString, T::class.java) ?: throw NullPointerException() objects.add(value) }