gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-android] 05/08: [wallet] Fix NullPointerException in base64


From: gnunet
Subject: [taler-taler-android] 05/08: [wallet] Fix NullPointerException in base64 decoding of product image
Date: Wed, 06 Mar 2024 18:38:07 +0100

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository taler-android.

commit da3d59bcabc0195f09f1259ded4058b6e9b5c385
Author: Iván Ávalos <avalos@disroot.org>
AuthorDate: Mon Mar 4 15:34:46 2024 -0600

        [wallet] Fix NullPointerException in base64 decoding of product image
    
        bug 0008505
---
 .../java/net/taler/wallet/payment/ProductAdapter.kt | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 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 35ec18b..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,17 +67,18 @@ 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

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]