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 449daf2f0..5b015150e 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 @@ -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" }