From 5cdcde05281b30e93755eb562f7a0631c15c55b4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Mar 2020 14:50:33 +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 --- .../ui/book/read/config/ReadStyleDialog.kt | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index ece020ffa..95b7d81e9 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -224,12 +224,12 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { } } - private fun setBg() { - bg0.setTextColor(ReadBookConfig.getConfig(0).textColor()) - bg1.setTextColor(ReadBookConfig.getConfig(1).textColor()) - bg2.setTextColor(ReadBookConfig.getConfig(2).textColor()) - bg3.setTextColor(ReadBookConfig.getConfig(3).textColor()) - bg4.setTextColor(ReadBookConfig.getConfig(4).textColor()) + private fun setBg() = ReadBookConfig.apply { + bg0.setTextColor(getConfig(0).textColor()) + bg1.setTextColor(getConfig(1).textColor()) + bg2.setTextColor(getConfig(2).textColor()) + bg3.setTextColor(getConfig(3).textColor()) + bg4.setTextColor(getConfig(4).textColor()) for (i in 0..4) { val iv = when (i) { 1 -> bg1 @@ -238,22 +238,22 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack { 4 -> bg4 else -> bg0 } - iv.setImageDrawable(ReadBookConfig.getConfig(i).bgDrawable(100, 150)) + iv.setImageDrawable(getConfig(i).bgDrawable(100, 150)) } } - private fun upBg() { - bg0.borderColor = requireContext().primaryColor - bg1.borderColor = requireContext().primaryColor - bg2.borderColor = requireContext().primaryColor - bg3.borderColor = requireContext().primaryColor - bg4.borderColor = requireContext().primaryColor + private fun upBg() = requireContext().apply { + bg0.borderColor = primaryColor + bg1.borderColor = primaryColor + bg2.borderColor = primaryColor + bg3.borderColor = primaryColor + bg4.borderColor = primaryColor when (ReadBookConfig.styleSelect) { - 1 -> bg1.borderColor = requireContext().accentColor - 2 -> bg2.borderColor = requireContext().accentColor - 3 -> bg3.borderColor = requireContext().accentColor - 4 -> bg4.borderColor = requireContext().accentColor - else -> bg0.borderColor = requireContext().accentColor + 1 -> bg1.borderColor = accentColor + 2 -> bg2.borderColor = accentColor + 3 -> bg3.borderColor = accentColor + 4 -> bg4.borderColor = accentColor + else -> bg0.borderColor = accentColor } }