taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

commit fe694e7c69ca48ad73fa889420b056dadfebb88b
parent 9207f8d19a62b9a544a5934b4dbed691ab2d10fe
Author: Iván Ávalos <avalos@disroot.org>
Date:   Tue, 29 Aug 2023 12:01:31 -0600

[wallet] Fixed serialization error in contract terms

Diffstat:
Mmerchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt | 2+-
Mtaler-kotlin-android/src/main/java/net/taler/common/ContractTerms.kt | 8++++----
Mwallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt | 5++++-
3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt b/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt @@ -80,7 +80,7 @@ class MerchantApiTest { { "product_id": "${product.productId}", "description": "${product.description}", - "price": "${product.price.toJSONString()}", + "price": "${product.price!!.toJSONString()}", "quantity": ${product.quantity} } ] diff --git a/taler-kotlin-android/src/main/java/net/taler/common/ContractTerms.kt b/taler-kotlin-android/src/main/java/net/taler/common/ContractTerms.kt @@ -42,7 +42,7 @@ abstract class Product { abstract val productId: String? abstract val description: String abstract val descriptionI18n: Map<String, String>? - abstract val price: Amount + abstract val price: Amount? abstract val location: String? abstract val image: String? val localizedDescription: String @@ -60,14 +60,14 @@ data class ContractProduct( override val description: String, @SerialName("description_i18n") override val descriptionI18n: Map<String, String>? = null, - override val price: Amount, + override val price: Amount? = null, @SerialName("delivery_location") override val location: String? = null, override val image: String? = null, val quantity: Int ) : Product() { - val totalPrice: Amount by lazy { - price * quantity + val totalPrice: Amount? by lazy { + price?.let { price * quantity } } } diff --git a/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt b/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt @@ -81,7 +81,10 @@ internal class ProductAdapter(private val listener: ProductImageClickListener) : } } name.text = product.description - price.text = product.totalPrice.toString() + price.visibility = product.totalPrice?.let { + price.text = it.toString() + VISIBLE + } ?: GONE } }