Updated on 2026-08-14
This commit is contained in:
parent
1a12b1bdf9
commit
2f7ed460ff
19 changed files with 160 additions and 252 deletions
|
|
@ -3,7 +3,7 @@ package com.tangem.tap.persistence
|
|||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import com.tangem.common.json.MoshiJsonConverter
|
||||
import com.tangem.network.api.tangemTech.Coins
|
||||
import com.tangem.network.api.tangemTech.CurrenciesResponse
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -21,14 +21,14 @@ class FiatCurrenciesPrefStorage(
|
|||
}
|
||||
}
|
||||
|
||||
fun save(currencies: List<Coins.CurrenciesResponse.Currency>) {
|
||||
fun save(currencies: List<CurrenciesResponse.Currency>) {
|
||||
val json: String = converter.toJson(currencies)
|
||||
return preferences.edit().putString(FIAT_CURRENCIES_KEY, json).apply()
|
||||
}
|
||||
|
||||
fun restore(): List<Coins.CurrenciesResponse.Currency> {
|
||||
fun restore(): List<CurrenciesResponse.Currency> {
|
||||
val json = preferences.getString(FIAT_CURRENCIES_KEY, "")
|
||||
val type = converter.typedList(Coins.CurrenciesResponse.Currency::class.java)
|
||||
val type = converter.typedList(CurrenciesResponse.Currency::class.java)
|
||||
if (json.isNullOrBlank()) return emptyList()
|
||||
|
||||
return converter.fromJson(json, type) ?: emptyList()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue