From a6891c89f5fe8dd46f95e7c850d4e21d81a52a56 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 13 Feb 2020 14:25:35 +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 --- .../legado/app/ui/widget/prefs/IconListPreference.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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" }