Merge pull request #2223 from CatimaLoyalty/fix/crashOnInvalidPkpassFile

Fix crash when trying to load invalid pkpass file
This commit is contained in:
Sylvia van Os
2024-12-12 17:24:08 +01:00
committed by GitHub

View File

@@ -180,10 +180,17 @@ public class Utils {
if (uri == null) {
Log.e(TAG, "Pkpass did not contain any data");
Toast.makeText(context, R.string.errorReadingFile, Toast.LENGTH_LONG).show();
return null;
return new ArrayList<>();
}
PkpassParser pkpassParser = new PkpassParser(context, uri);
PkpassParser pkpassParser;
try {
pkpassParser = new PkpassParser(context, uri);
} catch (Exception e) {
Log.e(TAG, "Error reading pkpass file", e);
Toast.makeText(context, R.string.errorReadingFile, Toast.LENGTH_LONG).show();
return new ArrayList<>();
}
List<String> locales = pkpassParser.listLocales();
if (locales.isEmpty()) {