Updated on 2026-08-14
This commit is contained in:
parent
d4c34f6af9
commit
c70f4c5192
5 changed files with 69 additions and 29 deletions
|
|
@ -4,7 +4,7 @@ import android.app.Application
|
|||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import com.tangem.common.json.MoshiJsonConverter
|
||||
import com.tangem.network.common.MoshiConverter
|
||||
import java.util.*
|
||||
|
||||
class PreferencesStorage(applicationContext: Application) {
|
||||
|
|
@ -21,12 +21,12 @@ class PreferencesStorage(applicationContext: Application) {
|
|||
init {
|
||||
incrementLaunchCounter()
|
||||
appRatingLaunchObserver = AppRatingLaunchObserver(preferences, getCountOfLaunches())
|
||||
usedCardsPrefStorage = UsedCardsPrefStorage(preferences, MoshiJsonConverter.INSTANCE)
|
||||
usedCardsPrefStorage = UsedCardsPrefStorage(preferences, MoshiConverter.INSTANCE)
|
||||
usedCardsPrefStorage.migrate()
|
||||
fiatCurrenciesPrefStorage = FiatCurrenciesPrefStorage(preferences, MoshiJsonConverter.INSTANCE)
|
||||
fiatCurrenciesPrefStorage = FiatCurrenciesPrefStorage(preferences, MoshiConverter.INSTANCE)
|
||||
fiatCurrenciesPrefStorage.migrate()
|
||||
disclaimerPrefStorage = DisclaimerPrefStorage(preferences)
|
||||
toppedUpWalletStorage = ToppedUpWalletStorage(preferences, MoshiJsonConverter.INSTANCE)
|
||||
toppedUpWalletStorage = ToppedUpWalletStorage(preferences, MoshiConverter.INSTANCE)
|
||||
}
|
||||
|
||||
var chatFirstLaunchTime: Long?
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ package com.tangem.tap.persistence
|
|||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.ToJson
|
||||
import com.tangem.common.json.MoshiJsonConverter
|
||||
import com.tangem.tap.common.analytics.events.AnalyticsParam
|
||||
import com.tangem.tap.common.analytics.filters.BasicTopUpFilter
|
||||
import timber.log.Timber
|
||||
|
||||
|
|
@ -44,7 +47,9 @@ class ToppedUpWalletStorage(
|
|||
private fun restore(): MutableSet<BasicTopUpFilter.Data> {
|
||||
val json = preferences.getString(KEY, null) ?: return mutableSetOf()
|
||||
return try {
|
||||
jsonConverter.fromJson(json, jsonConverter.typedList(BasicTopUpFilter.Data::class.java))!!
|
||||
val typedList = jsonConverter.typedList(BasicTopUpFilter.Data::class.java)
|
||||
val listData = jsonConverter.fromJson<List<BasicTopUpFilter.Data>>(json, typedList)!!
|
||||
listData.toMutableSet()
|
||||
} catch (ex: Exception) {
|
||||
preferences.edit(true) { remove(KEY) }
|
||||
mutableSetOf()
|
||||
|
|
@ -54,4 +59,18 @@ class ToppedUpWalletStorage(
|
|||
companion object {
|
||||
private const val KEY = "userWalletsInfo"
|
||||
}
|
||||
}
|
||||
|
||||
class CardBalanceStateAdapter {
|
||||
@ToJson
|
||||
fun toJson(src: AnalyticsParam.CardBalanceState): String = src.value
|
||||
|
||||
@FromJson
|
||||
fun fromJson(json: String): AnalyticsParam.CardBalanceState {
|
||||
return when (json) {
|
||||
AnalyticsParam.CardBalanceState.Empty.value -> AnalyticsParam.CardBalanceState.Empty
|
||||
AnalyticsParam.CardBalanceState.Full.value -> AnalyticsParam.CardBalanceState.Full
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue