Skip to content

Commit e05cd3a

Browse files
authored
Merge pull request #376 from code-payments/fix/fallback-cash-bill-asset
chore(bill/cash): add fallback for loading globe/grid assets
2 parents 1c909c6 + a4f2e3f commit e05cd3a

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

  • app/src/main/java/com/getcode/view/main/bill

app/src/main/java/com/getcode/view/main/bill/CashBill.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,20 @@ object CashBillAssets {
115115
val db = ContextCompat.getDrawable(context, drawable)
116116

117117
// create bitmap from drawable
118-
val bit = BitmapFactory.decodeResource(
119-
context.resources,
120-
drawable,
121-
BitmapFactory.Options().apply {
122-
inJustDecodeBounds = false
123-
inPreferredConfig = Bitmap.Config.RGB_565
124-
}
125-
)
118+
val bit: Bitmap = runCatching {
119+
BitmapFactory.decodeResource(
120+
context.resources,
121+
drawable,
122+
BitmapFactory.Options().apply {
123+
inJustDecodeBounds = false
124+
inPreferredConfig = Bitmap.Config.RGB_565
125+
}
126+
)
127+
}.getOrElse {
128+
Bitmap.createBitmap(
129+
db!!.intrinsicWidth, db.intrinsicHeight, Bitmap.Config.RGB_565
130+
)
131+
}
126132

127133
// determine best sizing based on width and height of bitmap
128134
var width = bit.width

0 commit comments

Comments
 (0)