From b690838479373baca235b31e6fa856806be8e7ef Mon Sep 17 00:00:00 2001 From: Administrator <1760316362@qq.com> Date: Tue, 30 Jul 2019 12:02:10 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=B8=BB=E9=A2=98=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/theme/prefs/ATEPreferenceCategory.kt | 2 +- .../lib/theme/prefs/ATESwitchPreference.kt | 23 ++++--------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt index c2d39f3a7..7f15973ef 100644 --- a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt +++ b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt @@ -29,7 +29,7 @@ class ATEPreferenceCategory : PreferenceCategory { override fun onBindViewHolder(holder: PreferenceViewHolder?) { super.onBindViewHolder(holder) holder?.let { - val view = it.itemView + val view = it.findViewById(android.R.id.title) if (view is TextView) { view.setTextColor(ThemeStore.accentColor(view.getContext()))//设置title文本的颜色 } diff --git a/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt b/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt index 7c4b54ec8..2ff1c9c05 100644 --- a/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt +++ b/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt @@ -3,14 +3,13 @@ package io.legado.app.lib.theme.prefs import android.content.Context import android.os.Build import android.util.AttributeSet -import android.view.ViewGroup -import android.widget.Switch import androidx.annotation.RequiresApi +import androidx.appcompat.widget.SwitchCompat import androidx.preference.PreferenceViewHolder import androidx.preference.SwitchPreferenceCompat +import io.legado.app.R import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ThemeStore -import java.util.* class ATESwitchPreference : SwitchPreferenceCompat { @@ -31,21 +30,9 @@ class ATESwitchPreference : SwitchPreferenceCompat { override fun onBindViewHolder(holder: PreferenceViewHolder?) { super.onBindViewHolder(holder) holder?.let { - val view = it.itemView - if (view is ViewGroup) { - val queue = LinkedList() - queue.add(view) - while (!queue.isEmpty()) { - val current = queue.removeFirst() - for (i in 0 until current.childCount) { - if (current.getChildAt(i) is Switch) { - ATH.setTint(current.getChildAt(i), ThemeStore.accentColor(view.getContext())) - return - } else if (current.getChildAt(i) is ViewGroup) { - queue.addLast(current.getChildAt(i) as ViewGroup) - } - } - } + val view = it.findViewById(R.id.switchWidget) + if (view is SwitchCompat) { + ATH.setTint(view, ThemeStore.accentColor(view.getContext())) } } }