Fix crash when trying to load an invalid icon

This commit is contained in:
Suphon Thanakornpakapong committed 2021-10-30 07:30:35 +07:00
1 parent 07f18261ad
commit fa3e5db7ea
1 file changed
+5 -1
@@ -58,7 +58,11 @@ class IconPack(
fun getIcon(iconEntry: IconEntry, iconDpi: Int): Drawable? {
val id = getDrawableId(iconEntry.name)
if (id == 0) return null
return packResources.getDrawableForDensity(id, iconDpi, null)
return try {
packResources.getDrawableForDensity(id, iconDpi, null)
} catch (e: Resources.NotFoundException) {
null
}
}
private fun getDrawableId(name: String) = idCache.getOrPut(name) {