From 1872bea0c305b189ed5aacc4dd60b1fbdd36d6a3 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Thu, 14 Apr 2022 22:25:46 +0200 Subject: [PATCH] Stocard: Ignore cards with missing card data Stocard appears to keep images for deleted cards, which causes some cards to have only images and no data, making them impossible to import. This is most likely a bug on Stocard's side. As a workaround, we ignore cards with no data file. --- .../card_locker/importexport/StocardImporter.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/protect/card_locker/importexport/StocardImporter.java b/app/src/main/java/protect/card_locker/importexport/StocardImporter.java index a1507df96..74ccc1c5a 100644 --- a/app/src/main/java/protect/card_locker/importexport/StocardImporter.java +++ b/app/src/main/java/protect/card_locker/importexport/StocardImporter.java @@ -3,6 +3,7 @@ package protect.card_locker.importexport; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; +import android.util.Log; import com.google.zxing.BarcodeFormat; @@ -39,6 +40,8 @@ import protect.card_locker.ZipUtils; * A header is expected for the each table showing the names of the columns. */ public class StocardImporter implements Importer { + private static final String TAG = "Catima"; + public void importData(Context context, SQLiteDatabase database, InputStream input, char[] password) throws IOException, FormatException, JSONException, ParseException { HashMap> loyaltyCardHashMap = new HashMap<>(); HashMap> providers = new HashMap<>(); @@ -201,6 +204,12 @@ public class StocardImporter implements Importer { for (HashMap loyaltyCardData : loyaltyCardHashMap.values()) { String providerId = (String) loyaltyCardData.get("_providerId"); + + if (providerId == null) { + Log.d(TAG, "Missing providerId for card " + loyaltyCardData + ", ignoring..."); + continue; + } + HashMap providerData = providers.get(providerId); String store = providerData != null ? providerData.get("name").toString() : providerId;