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.
This commit is contained in:
Sylvia van Os
2022-04-14 22:25:46 +02:00
parent 665ef5f712
commit 1872bea0c3

View File

@@ -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<String, HashMap<String, Object>> loyaltyCardHashMap = new HashMap<>();
HashMap<String, HashMap<String, Object>> providers = new HashMap<>();
@@ -201,6 +204,12 @@ public class StocardImporter implements Importer {
for (HashMap<String, Object> loyaltyCardData : loyaltyCardHashMap.values()) {
String providerId = (String) loyaltyCardData.get("_providerId");
if (providerId == null) {
Log.d(TAG, "Missing providerId for card " + loyaltyCardData + ", ignoring...");
continue;
}
HashMap<String, Object> providerData = providers.get(providerId);
String store = providerData != null ? providerData.get("name").toString() : providerId;