diff options
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt')
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt b/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt index 87b6387..289f0d7 100644 --- a/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt +++ b/wallet/src/main/java/net/taler/wallet/payment/ProductAdapter.kt @@ -67,21 +67,25 @@ internal class ProductAdapter(private val listener: ProductImageClickListener) : fun bind(product: ContractProduct) { quantity.text = product.quantity.toString() - if (product.image == null) { + val productImage = product.image + if (productImage == null) { image.visibility = GONE - } else { - image.visibility = VISIBLE - // product.image was validated before, so non-null below - val match = REGEX_PRODUCT_IMAGE.matchEntire(product.image!!)!! - val decodedString = Base64.decode(match.groups[2]!!.value, Base64.DEFAULT) - val bitmap = decodeByteArray(decodedString, 0, decodedString.size) - image.setImageBitmap(bitmap) - image.setOnClickListener { - listener.onImageClick(bitmap) + } else REGEX_PRODUCT_IMAGE.matchEntire(productImage)?.let { match -> + match.groups[2]?.value?.let { group -> + image.visibility = VISIBLE + val decodedString = Base64.decode(group, Base64.DEFAULT) + val bitmap = decodeByteArray(decodedString, 0, decodedString.size) + image.setImageBitmap(bitmap) + image.setOnClickListener { + listener.onImageClick(bitmap) + } } } name.text = product.description - price.text = product.totalPrice.toString() + price.visibility = product.totalPrice?.let { + price.text = it.toString() + VISIBLE + } ?: GONE } } |