From e01954c90fa4276e1ce28f1f95855595072f4c9b Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 17 Feb 2020 09:18:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/widget/prefs/IconListPreference.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt index ecad8d5c1..ff3fa801c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt +++ b/app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt @@ -26,7 +26,7 @@ import org.jetbrains.anko.sdk27.listeners.onClick class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference(context, attrs) { private var iconNames: Array - private val mEntryDrawables = arrayListOf() + private val mEntryDrawables = arrayListOf() init { widgetLayoutResource = R.layout.view_icon @@ -42,8 +42,11 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference for (iconName in iconNames) { val resId = context.resources .getIdentifier(iconName.toString(), "mipmap", context.packageName) - val d = context.getCompatDrawable(resId) - mEntryDrawables.add(d!!) + var d: Drawable? = null + kotlin.runCatching { + d = context.getCompatDrawable(resId) + } + mEntryDrawables.add(d) } }