# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1631694981 0 # Node ID 5b63a3ed8e109783f9b3c3ff53b318ab83c217d5 # Parent fe186c9318cc36f826141e85ecabc2c110ee0c6a Android: Code path cleanup, basically only try one image load... the only exception being android native resources... try those first and then load any other possible paths. diff -r fe186c9318cc -r 5b63a3ed8e10 android/DWindows.kt --- a/android/DWindows.kt Wed Sep 15 08:05:39 2021 +0000 +++ b/android/DWindows.kt Wed Sep 15 08:36:21 2021 +0000 @@ -3015,7 +3015,8 @@ imageview.setImageResource(resID) } - } else if(data != null) { + } + if(data != null) { val b = BitmapFactory.decodeByteArray(data, 0, length) if (window is ImageButton) { @@ -3036,11 +3037,22 @@ var icon: Drawable? = null waitOnUiThread { - var filename: String? = file + var filename: String? = null // Handle Dynamic Windows resource IDs if(resID > 0 && resID < 65536) { filename = resID.toString() + // Handle Android resource IDs + } else if(resID != 0) { + try { + icon = ResourcesCompat.getDrawable(resources, resID, null) + } catch (e: Resources.NotFoundException) { + } + // Handle bitmap data + } else if(data != null) { + icon = BitmapDrawable(resources, BitmapFactory.decodeByteArray(data, 0, length)) + } else { + filename = file } // Handle filename or DW resource IDs // these will be located in the assets folder @@ -3058,15 +3070,6 @@ break } } - // Handle Android resource IDs - } else if(resID != 0) { - try { - icon = ResourcesCompat.getDrawable(resources, resID, null) - } catch (e: Resources.NotFoundException) { - } - // Handle bitmap data - } else if(data != null) { - icon = BitmapDrawable(resources, BitmapFactory.decodeByteArray(data, 0, length)) } } return icon @@ -3077,7 +3080,7 @@ var pixmap: Bitmap? = null waitOnUiThread { - var filename: String? = file + var filename: String? = null if(width > 0 && height > 0) { pixmap = Bitmap.createBitmap(null, width, height, Bitmap.Config.ARGB_8888) @@ -3085,6 +3088,10 @@ filename = resID.toString() } else if(resID != 0) { pixmap = BitmapFactory.decodeResource(resources, resID) + } else if(data != null) { + pixmap = BitmapFactory.decodeByteArray(data, 0, length) + } else { + filename = file } if(filename != null) { val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif") @@ -3100,8 +3107,6 @@ break } } - } else if(data != null) { - pixmap = BitmapFactory.decodeByteArray(data, 0, length) } } return pixmap