feat: 优化代码

pull/121/head
kunfei 5 years ago
parent acc9b0738e
commit 46081225e9
  1. 10
      app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt

@ -167,8 +167,14 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference
dialogIconNames?.let {
val resId = context.resources
.getIdentifier(it[index].toString(), "mipmap", context.packageName)
val d = context.getCompatDrawable(resId)
icon.setImageDrawable(d)
val d = try {
context.getCompatDrawable(resId)
} catch (e: Exception) {
null
}
d?.let {
icon.setImageDrawable(d)
}
}
label.isChecked = item.toString() == dialogValue
onClick {

Loading…
Cancel
Save