summaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net/taler/wallet/currency/CurrencyManager.kt
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-12-04 23:40:03 -0600
committerIván Ávalos <avalos@disroot.org>2023-12-04 23:40:03 -0600
commit269688d7894429d307b8c6190e505c99e9451e0c (patch)
tree1863d9ef178e305bc3b7267333faeef7a0d878d7 /wallet/src/main/java/net/taler/wallet/currency/CurrencyManager.kt
parent50f77000e0bb7a0fdf563551eae0f23995abd258 (diff)
downloadtaler-android-dev/ivan-avalos/currencyXYZ.tar.gz
taler-android-dev/ivan-avalos/currencyXYZ.tar.bz2
taler-android-dev/ivan-avalos/currencyXYZ.zip
[wallet] Refactor balances code to make DD51 easierdev/ivan-avalos/currencyXYZ
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/currency/CurrencyManager.kt')
-rw-r--r--wallet/src/main/java/net/taler/wallet/currency/CurrencyManager.kt66
1 files changed, 0 insertions, 66 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/currency/CurrencyManager.kt b/wallet/src/main/java/net/taler/wallet/currency/CurrencyManager.kt
deleted file mode 100644
index cc4cbd6..0000000
--- a/wallet/src/main/java/net/taler/wallet/currency/CurrencyManager.kt
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * This file is part of GNU Taler
- * (C) 2023 Taler Systems S.A.
- *
- * GNU Taler is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 3, or (at your option) any later version.
- *
- * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-
-package net.taler.wallet.currency
-
-import android.util.Log
-import androidx.lifecycle.LiveData
-import androidx.lifecycle.MutableLiveData
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.launch
-import kotlinx.serialization.Serializable
-import net.taler.wallet.TAG
-import net.taler.wallet.backend.TalerErrorInfo
-import net.taler.wallet.backend.WalletBackendApi
-import net.taler.wallet.balances.ScopeInfo
-
-@Serializable
-data class GetCurrencySpecificationResponse(
- val currencySpecification: CurrencySpecification,
-)
-
-class CurrencyManager(
- private val api: WalletBackendApi,
- private val scope: CoroutineScope,
-) {
- private val mCurrencyInfo = MutableLiveData<CurrencyInfo>()
- val currencyInfo: LiveData<CurrencyInfo> get() = listCurrencies()
-
- private val mError = MutableLiveData<TalerErrorInfo>()
- val error: LiveData<TalerErrorInfo> = mError
-
- private fun listCurrencies(): LiveData<CurrencyInfo> {
- scope.launch {
- val response = api.request("listCurrencies", CurrencyInfo.serializer())
- response.onError {
- mError.value = it
- }.onSuccess {
- Log.d(TAG, "Currency info: $it")
- mCurrencyInfo.value = it
- }
- }
- return mCurrencyInfo
- }
-
- suspend fun getCurrencySpecification(scopeInfo: ScopeInfo): CurrencySpecification? {
- var spec: CurrencySpecification? = null
- api.request("getCurrencySpecification", GetCurrencySpecificationResponse.serializer())
- .onSuccess {
- spec = it.currencySpecification
- }
- return spec
- }
-} \ No newline at end of file