From da16dd528ca0f1d99c5d86518ad2fd4e3f2d9970 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 30 Aug 2019 19:05:15 +0800 Subject: [PATCH] up --- .../app/ui/readbook/config/ReadStyleDialog.kt | 71 ++++++------------- 1 file changed, 20 insertions(+), 51 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt index efc603a13..8c44a480c 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt @@ -200,64 +200,33 @@ class ReadStyleDialog : DialogFragment() { } } } - tv_bg0.onClick { - ReadBookConfig.styleSelect = 0 - ReadBookConfig.upBg() - upBg() - postEvent(Bus.UP_CONFIG, true) - } - tv_bg0.onLongClick { - showBgTextConfig() - false - } - tv_bg1.onClick { - ReadBookConfig.styleSelect = 1 - ReadBookConfig.upBg() - upBg() - postEvent(Bus.UP_CONFIG, true) - } - tv_bg1.onLongClick { - showBgTextConfig() - false - } - tv_bg2.onClick { - ReadBookConfig.styleSelect = 2 - ReadBookConfig.upBg() - upBg() - postEvent(Bus.UP_CONFIG, true) - } - tv_bg2.onLongClick { - showBgTextConfig() - false - } - tv_bg3.onClick { - ReadBookConfig.styleSelect = 3 - ReadBookConfig.upBg() - upBg() - postEvent(Bus.UP_CONFIG, true) - } - tv_bg3.onLongClick { - showBgTextConfig() - false - } - tv_bg4.onClick { - ReadBookConfig.styleSelect = 4 - ReadBookConfig.upBg() - upBg() - postEvent(Bus.UP_CONFIG, true) - } - tv_bg4.onLongClick { - showBgTextConfig() - false - } + tv_bg0.onClick { changeBg(0) } + tv_bg0.onLongClick { showBgTextConfig(0) } + tv_bg1.onClick { changeBg(1) } + tv_bg1.onLongClick { showBgTextConfig(1) } + tv_bg2.onClick { changeBg(2) } + tv_bg2.onLongClick { showBgTextConfig(2) } + tv_bg3.onClick { changeBg(3) } + tv_bg3.onLongClick { showBgTextConfig(3) } + tv_bg4.onClick { changeBg(4) } + tv_bg4.onLongClick { showBgTextConfig(4) } + } + + private fun changeBg(index: Int) { + ReadBookConfig.styleSelect = index + ReadBookConfig.upBg() + upBg() + postEvent(Bus.UP_CONFIG, true) } - private fun showBgTextConfig() { + private fun showBgTextConfig(index: Int): Boolean { dismiss() + changeBg(index) val activity = activity if (activity is ReadBookActivity) { activity.showBgTextConfig() } + return true } private fun setBg() {