-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc156ec
commit 1576943
Showing
15 changed files
with
192 additions
and
114 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
/captures | ||
.externalNativeBuild | ||
.cxx | ||
/app/google-services.json |
This file contains 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
This file contains 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
32 changes: 32 additions & 0 deletions
32
OmetriaSDK/src/main/java/com/android/ometriasdk/core/LocalCacheExtension.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.android.ometriasdk.core | ||
|
||
import android.content.SharedPreferences | ||
|
||
internal fun SharedPreferences.copyTo(dest: SharedPreferences) { | ||
for (entry in all.entries) { | ||
val key = entry.key | ||
val value: Any? = entry.value | ||
dest.set(key, value) | ||
} | ||
} | ||
|
||
internal inline fun SharedPreferences.edit(operation: (SharedPreferences.Editor) -> Unit) { | ||
val editor = this.edit() | ||
operation(editor) | ||
editor.apply() | ||
} | ||
|
||
internal fun SharedPreferences.set(key: String, value: Any?) { | ||
when (value) { | ||
is String? -> edit { it.putString(key, value) } | ||
is Int -> edit { it.putInt(key, value.toInt()) } | ||
is Boolean -> edit { it.putBoolean(key, value) } | ||
is Float -> edit { it.putFloat(key, value.toFloat()) } | ||
is Long -> edit { it.putLong(key, value.toLong()) } | ||
else -> Unit | ||
} | ||
} | ||
|
||
internal fun SharedPreferences.clear() { | ||
edit { it.clear() } | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.