# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1628893185 0 # Node ID 28ca1e59e76f2713ce3ba25e526f19a7548a58f2 # Parent 3edc64443b7126dd72055337495812485d3144b9 Android: Catch NotFoundException when loading resource... This allows HandyFTP to start up on Android now, with missing resources. APIs should return null on failure not throw an exception. diff -r 3edc64443b71 -r 28ca1e59e76f android/DWindows.kt --- a/android/DWindows.kt Fri Aug 13 21:50:47 2021 +0000 +++ b/android/DWindows.kt Fri Aug 13 22:19:45 2021 +0000 @@ -9,6 +9,7 @@ import android.content.* import android.content.pm.ActivityInfo import android.content.res.Configuration +import android.content.res.Resources import android.database.Cursor import android.graphics.* import android.graphics.drawable.BitmapDrawable @@ -2853,7 +2854,10 @@ waitOnUiThread { if(resID != 0) { - icon = ResourcesCompat.getDrawable(resources, resID, null) + try { + icon = ResourcesCompat.getDrawable(resources, resID, null) + } catch(e: Resources.NotFoundException) { + } } else if(filename != null) { val exts = arrayOf("", ".png", ".webp", ".jpg", ".jpeg", ".gif") @@ -2867,7 +2871,6 @@ if(icon != null) { break } - } } else if(data != null) { icon = BitmapDrawable(resources, BitmapFactory.decodeByteArray(data, 0, length))