feat: 优化代码

pull/103/head
kunfei 5 years ago
parent 16e7e8a4cd
commit a6891c89f5
  1. 11
      app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt

@ -78,6 +78,15 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference
}
}
override fun onAttached() {
super.onAttached()
val fragment =
getActivity()?.supportFragmentManager?.findFragmentByTag(getFragmentTag()) as IconDialog?
fragment?.onChanged = { value ->
this@IconListPreference.value = value
}
}
private fun getActivity(): FragmentActivity? {
val context = context
if (context is FragmentActivity) {
@ -91,7 +100,7 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference
return null
}
fun getFragmentTag(): String {
private fun getFragmentTag(): String {
return "icon_$key"
}

Loading…
Cancel
Save