Skip to content

Commit

Permalink
Don't allow null values in the save function
Browse files Browse the repository at this point in the history
  • Loading branch information
muddassir235 committed Sep 7, 2020
1 parent 5972ac3 commit 50dd807
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions eprefs/src/main/java/com/muddassir/eprefs/eprefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ val Context.prefs: SharedPreferences get() = this.getSharedPreferences(
* @param key The key of the object to save
* @param value the value of the object to save
*/
fun Context.save(key: String, value: Any?) {
fun Context.save(key: String, value: Any) {
prefs.save(key, value)
}

Expand All @@ -28,7 +28,7 @@ fun Context.save(key: String, value: Any?) {
* @param key The key of the object to save
* @param value the value of the object to save
*/
fun Context.safeSave(key: String, value: Any?) {
fun Context.safeSave(key: String, value: Any) {
prefs.safeSave(key, value)
}

Expand Down Expand Up @@ -79,7 +79,7 @@ inline fun <reified T: Serializable> Context.safeDelete(key: String) {
* @param key The key of the object to save
* @param value the value of the object to save
*/
fun SharedPreferences.safeSave(key: String, value: Any?) {
fun SharedPreferences.safeSave(key: String, value: Any) {
safe { save(key, value) }
}

Expand All @@ -100,7 +100,7 @@ inline fun <reified T: Serializable> SharedPreferences.safeLoad(key: String): T?
* @param key The key of the object to save
* @param value the value of the object to save
*/
fun SharedPreferences.save(key: String, value: Any?) {
fun SharedPreferences.save(key: String, value: Any) {
with (edit()) {
when (value) {
is Boolean -> putBoolean(key, value)
Expand Down

0 comments on commit 50dd807

Please sign in to comment.