mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-05-14 19:46:31 -04:00
Support pkpass files without any extra data
Previously, the code assumed one of "boardingPass", "coupon", "eventTicket", "generic" existed and refused to pass a pkpass file without any of them
This commit is contained in:
@@ -296,30 +296,22 @@ class PkpassParser(context: Context, uri: Uri?) {
|
||||
}
|
||||
|
||||
// Append type-specific info to the pass
|
||||
noteText.append("\n\n")
|
||||
|
||||
// Find the relevant pass type and parse it
|
||||
var hasPassData = false
|
||||
for (passType in listOf("boardingPass", "coupon", "eventTicket", "generic")) {
|
||||
try {
|
||||
noteText.append(
|
||||
parsePassJSONPassFields(
|
||||
jsonObject.getJSONObject(passType),
|
||||
locale
|
||||
)
|
||||
var extraText = parsePassJSONPassFields(
|
||||
jsonObject.getJSONObject(passType),
|
||||
locale
|
||||
)
|
||||
|
||||
hasPassData = true
|
||||
noteText.append("\n\n")
|
||||
noteText.append(extraText)
|
||||
|
||||
break
|
||||
} catch (ignored: JSONException) {}
|
||||
}
|
||||
|
||||
// Failed to parse anything, error out
|
||||
if (!hasPassData) {
|
||||
throw FormatException(mContext.getString(R.string.errorReadingFile))
|
||||
}
|
||||
|
||||
note = noteText.toString()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user