File tree Expand file tree Collapse file tree
app/src/main/java/com/getcode/view/main/bill Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments