From 616ca77c398d41962677c0e27881bbec0e4ac912 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Mon, 20 Sep 2021 22:58:37 +0200 Subject: [PATCH] Fix possible crash I don't think this should ever happen, unless someone manually edited their import or DB, but this crash was logged in Google Play Console anyway so... --- app/src/main/java/protect/card_locker/CatimaBarcode.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/protect/card_locker/CatimaBarcode.java b/app/src/main/java/protect/card_locker/CatimaBarcode.java index 91301353d..59a1d5305 100644 --- a/app/src/main/java/protect/card_locker/CatimaBarcode.java +++ b/app/src/main/java/protect/card_locker/CatimaBarcode.java @@ -72,6 +72,12 @@ public class CatimaBarcode { } public String prettyName() { - return barcodePrettyNames.get(barcodeFormats.indexOf(mBarcodeFormat)); + int index = barcodeFormats.indexOf(mBarcodeFormat); + + if (index == -1 || index >= barcodePrettyNames.size()) { + return mBarcodeFormat.name(); + } + + return barcodePrettyNames.get(index); } }