Skip to content

Commit

Permalink
- bump version
Browse files Browse the repository at this point in the history
- support null string on storeString
  • Loading branch information
RazibKani committed Jul 19, 2020
1 parent f7cb21d commit 0dabf77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions safedepositbox/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 2
versionName "1.1"
versionCode 3
versionName "0.3"
consumerProguardFiles 'consumer-rules.pro'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -340,14 +340,14 @@ class SafeDepositBox(private val context: Context, private val prefName: String)
/**
* Get List<T> value from SharedPreferences at 'key'.
* @param key SharedPreferences key
* @return List<T> value at 'key'
* @return List<T> value at 'key' or NPE if value not found
*/
inline fun <reified T : Any> getListObject(key: String): List<T> {
val objectStrings = getListString(key)
val objects = mutableListOf<T>()

objectStrings.forEach { objectString ->
val value = gson.fromJson(objectString, T::class.java)
val value = gson.fromJson(objectString, T::class.java) ?: throw NullPointerException()
objects.add(value)
}

Expand Down

0 comments on commit 0dabf77

Please sign in to comment.