Updated on 2026-08-14

This commit is contained in:
Tangem 2022-12-30 11:18:15 +03:00
parent 1474d83756
commit 725705ecf2
9 changed files with 64 additions and 36 deletions

View file

@ -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.datasource.api.tangemTech.CurrenciesResponse
import com.tangem.datasource.api.tangemTech.models.Currency
import com.tangem.tap.common.entities.FiatCurrency
/**
@ -32,14 +32,14 @@ class FiatCurrenciesPrefStorage(
preferences.edit { putString(APP_CURRENCY_KEY, json) }
}
fun save(currencies: List<CurrenciesResponse.Currency>) {
fun save(currencies: List<Currency>) {
val json: String = converter.toJson(currencies)
return preferences.edit().putString(FIAT_CURRENCIES_KEY, json).apply()
}
fun restore(): List<CurrenciesResponse.Currency> {
fun restore(): List<Currency> {
val json = preferences.getString(FIAT_CURRENCIES_KEY, "")
val type = converter.typedList(CurrenciesResponse.Currency::class.java)
val type = converter.typedList(Currency::class.java)
if (json.isNullOrBlank()) return emptyList()
return converter.fromJson(json, type) ?: emptyList()