Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluchu committed Jul 8, 2023
2 parents 7b94efd + 9087292 commit e2ea272
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 6 deletions.
2 changes: 1 addition & 1 deletion jchucomponents-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ afterEvaluate {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-core"
version = "1.7.0"
version = "1.7.1"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion jchucomponents-ktx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ afterEvaluate {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-ktx"
version = "1.7.0"
version = "1.7.1"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions jchucomponents-prefs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ afterEvaluate {
release(MavenPublication) {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-preferences"
version = "1.7.0"
artifactId = "jchucomponents-prefs"
version = "1.7.1"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.jeluchu.prefs.datastore

import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.doublePreferencesKey
import androidx.datastore.preferences.core.floatPreferencesKey
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.core.longPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey

class DataStoreService {
private val preferences by lazy { DataStoreHelpers() }

fun <T> savePreference(
tag: Preferences.Key<T>,
value: T
) = preferences.savePreference(tag, value)

fun savePreference(
tag: Preferences.Key<Int>,
value: Int
) = preferences.savePreference(tag, value)

fun savePreference(
tag: Preferences.Key<Long>,
value: Long
) = preferences.savePreference(tag, value)

fun savePreference(
tag: Preferences.Key<String>,
value: String
) = preferences.savePreference(tag, value)

fun savePreference(
tag: Preferences.Key<Boolean>,
value: Boolean
) = preferences.savePreference(tag, value)

fun <T> getPreference(
tag: Preferences.Key<T>
) = preferences.getPreference(tag)

fun getPreference(
tag: Preferences.Key<Int>,
default: Int
) = preferences.getPreference(tag, default)

fun getPreference(
tag: Preferences.Key<Long>,
default: Long
) = preferences.getPreference(tag, default)

fun getPreference(
tag: Preferences.Key<String>,
default: String
) = preferences.getPreference(tag, default)

fun getPreference(
tag: Preferences.Key<Boolean>,
default: Boolean
) = preferences.getPreference(tag, default)

companion object {
fun intPrefsKey(name: String) = intPreferencesKey(name)
fun floatPrefsKey(name: String) = floatPreferencesKey(name)
fun longPrefsKey(name: String) = longPreferencesKey(name)
fun doublePrefsKey(name: String) = doublePreferencesKey(name)
fun stringPrefsKey(name: String) = stringPreferencesKey(name)
fun booleanPrefsKey(name: String) = booleanPreferencesKey(name)
}
}
2 changes: 1 addition & 1 deletion jchucomponents-qr/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ afterEvaluate {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-qr"
version = "1.7.0"
version = "1.7.1"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion jchucomponents-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ afterEvaluate {
from components.release
groupId = "com.github.jeluchu"
artifactId = "jchucomponents-ui"
version = "1.7.0"
version = "1.7.1"
}
}
}
Expand Down

0 comments on commit e2ea272

Please sign in to comment.