Skip to content

Commit

Permalink
Merge pull request #3741 from nightscout/dev
Browse files Browse the repository at this point in the history
3.3.1.2
  • Loading branch information
MilosKozak authored Jan 14, 2025
2 parents 4beab94 + 7c4d4ae commit 70e376f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 44 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget

object Versions {

const val appVersion = "3.3.1.1"
const val appVersion = "3.3.1.2"
const val versionCode = 1500

const val ndkVersion = "21.1.6352462"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,67 +107,57 @@ class SPImpl @Inject constructor(
override fun getStringOrNull(key: String, defaultValue: String?): String? =
sharedPreferences.getString(key, defaultValue)

override fun getBoolean(resourceID: Int, defaultValue: Boolean): Boolean {
return try {
sharedPreferences.getBoolean(context.getString(resourceID), defaultValue)
} catch (e: Exception) {
defaultValue
}
}
override fun getBoolean(resourceID: Int, defaultValue: Boolean): Boolean =
sharedPreferences.getBoolean(context.getString(resourceID), defaultValue)

override fun getBoolean(key: String, defaultValue: Boolean): Boolean {
return try {
override fun getBoolean(key: String, defaultValue: Boolean): Boolean =
try {
sharedPreferences.getBoolean(key, defaultValue)
} catch (e: Exception) {
} catch (_: Exception) {
defaultValue
}
}

override fun getDouble(resourceID: Int, defaultValue: Double): Double =
SafeParse.stringToDouble(sharedPreferences.getString(context.getString(resourceID), defaultValue.toString()), defaultValue)
try {
sharedPreferences.getFloat(context.getString(resourceID), defaultValue.toFloat()).toDouble()
} catch (_: Exception) {
SafeParse.stringToDouble(sharedPreferences.getString(context.getString(resourceID), defaultValue.toString()), defaultValue)
}

override fun getDouble(key: String, defaultValue: Double): Double =
SafeParse.stringToDouble(sharedPreferences.getString(key, defaultValue.toString()), defaultValue)
try {
sharedPreferences.getFloat(key, defaultValue.toFloat()).toDouble()
} catch (_: Exception) {
SafeParse.stringToDouble(sharedPreferences.getString(key, defaultValue.toString()), defaultValue)
}

override fun getInt(resourceID: Int, defaultValue: Int): Int {
return try {
override fun getInt(resourceID: Int, defaultValue: Int): Int =
try {
sharedPreferences.getInt(context.getString(resourceID), defaultValue)
} catch (e: Exception) {
} catch (_: Exception) {
SafeParse.stringToInt(sharedPreferences.getString(context.getString(resourceID), defaultValue.toString()), defaultValue)
}
}

override fun getInt(key: String, defaultValue: Int): Int {
return try {
override fun getInt(key: String, defaultValue: Int): Int =
try {
sharedPreferences.getInt(key, defaultValue)
} catch (e: Exception) {
} catch (_: Exception) {
SafeParse.stringToInt(sharedPreferences.getString(key, defaultValue.toString()), defaultValue)
}
}

override fun getLong(resourceID: Int, defaultValue: Long): Long {
return try {
override fun getLong(resourceID: Int, defaultValue: Long): Long =
try {
sharedPreferences.getLong(context.getString(resourceID), defaultValue)
} catch (e: Exception) {
try {
SafeParse.stringToLong(sharedPreferences.getString(context.getString(resourceID), defaultValue.toString()), defaultValue)
} catch (e1: Exception) {
return defaultValue
}
} catch (_: Exception) {
SafeParse.stringToLong(sharedPreferences.getString(context.getString(resourceID), defaultValue.toString()), defaultValue)
}
}

override fun getLong(key: String, defaultValue: Long): Long {
return try {
override fun getLong(key: String, defaultValue: Long): Long =
try {
sharedPreferences.getLong(key, defaultValue)
} catch (e: Exception) {
try {
SafeParse.stringToLong(sharedPreferences.getString(key, defaultValue.toString()), defaultValue)
} catch (e1: Exception) {
return defaultValue
}
} catch (_: Exception) {
SafeParse.stringToLong(sharedPreferences.getString(key, defaultValue.toString()), defaultValue)
}
}

override fun incLong(resourceID: Int) {
val value = getLong(resourceID, 0) + 1L
Expand All @@ -180,11 +170,10 @@ class SPImpl @Inject constructor(
sharedPreferences.edit().putBoolean(context.getString(resourceID), value).apply()

override fun putDouble(key: String, value: Double) =
sharedPreferences.edit().putString(key, value.toString()).apply()
sharedPreferences.edit().putFloat(key, value.toFloat()).apply()

override fun putDouble(resourceID: Int, value: Double) {
sharedPreferences.edit().putString(context.getString(resourceID), value.toString()).apply()
}
override fun putDouble(resourceID: Int, value: Double) =
sharedPreferences.edit().putFloat(context.getString(resourceID), value.toFloat()).apply()

override fun putLong(key: String, value: Long) =
sharedPreferences.edit().putLong(key, value).apply()
Expand Down

0 comments on commit 70e376f

Please sign in to comment.