From 2b5d0bd18e6c0dff3e9c72793b1c3f330747ab41 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 24 Apr 2020 20:50:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/read/config/TipConfigDialog.kt | 168 ++++++++++++++++-- 1 file changed, 156 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt index cb9cfa594..2635b70b2 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt @@ -60,43 +60,187 @@ class TipConfigDialog : BaseDialogFragment() { private fun initEvent() { tv_header_left.onClick { selector(items = ReadTipConfig.tipArray.toList()) { _, i -> - ReadTipConfig.tipHeaderLeft = i - tv_header_left.text = ReadTipConfig.tipArray[i] + ReadTipConfig.apply { + if (i != none) { + if (tipHeaderMiddle == i) { + tipHeaderMiddle = none + tv_header_middle.text = tipArray[none] + } + if (tipHeaderRight == i) { + tipHeaderRight = none + tv_header_right.text = tipArray[none] + } + if (tipFooterLeft == i) { + tipFooterLeft = none + tv_footer_left.text = tipArray[none] + } + if (tipFooterMiddle == i) { + tipFooterMiddle = none + tv_footer_middle.text = tipArray[none] + } + if (tipFooterRight == i) { + tipFooterRight = none + tv_footer_right.text = tipArray[none] + } + } + tipHeaderLeft = i + tv_header_left.text = tipArray[i] + } postEvent(EventBus.UP_CONFIG, true) } } tv_header_middle.onClick { selector(items = ReadTipConfig.tipArray.toList()) { _, i -> - ReadTipConfig.tipHeaderMiddle = i - tv_header_middle.text = ReadTipConfig.tipArray[i] + ReadTipConfig.apply { + if (i != none) { + if (tipHeaderLeft == i) { + tipHeaderLeft = none + tv_header_left.text = tipArray[none] + } + if (tipHeaderRight == i) { + tipHeaderRight = none + tv_header_right.text = tipArray[none] + } + if (tipFooterLeft == i) { + tipFooterLeft = none + tv_footer_left.text = tipArray[none] + } + if (tipFooterMiddle == i) { + tipFooterMiddle = none + tv_footer_middle.text = tipArray[none] + } + if (tipFooterRight == i) { + tipFooterRight = none + tv_footer_right.text = tipArray[none] + } + } + tipHeaderMiddle = i + tv_header_middle.text = tipArray[i] + } postEvent(EventBus.UP_CONFIG, true) } } tv_header_right.onClick { selector(items = ReadTipConfig.tipArray.toList()) { _, i -> - ReadTipConfig.tipHeaderRight = i - tv_header_right.text = ReadTipConfig.tipArray[i] + ReadTipConfig.apply { + if (i != none) { + if (tipHeaderLeft == i) { + tipHeaderLeft = none + tv_header_left.text = tipArray[none] + } + if (tipHeaderMiddle == i) { + tipHeaderMiddle = none + tv_header_middle.text = tipArray[none] + } + if (tipFooterLeft == i) { + tipFooterLeft = none + tv_footer_left.text = tipArray[none] + } + if (tipFooterMiddle == i) { + tipFooterMiddle = none + tv_footer_middle.text = tipArray[none] + } + if (tipFooterRight == i) { + tipFooterRight = none + tv_footer_right.text = tipArray[none] + } + } + tipHeaderRight = i + tv_header_right.text = tipArray[i] + } postEvent(EventBus.UP_CONFIG, true) } } tv_footer_left.onClick { selector(items = ReadTipConfig.tipArray.toList()) { _, i -> - ReadTipConfig.tipFooterLeft = i - tv_footer_left.text = ReadTipConfig.tipArray[i] + ReadTipConfig.apply { + if (i != none) { + if (tipHeaderLeft == i) { + tipHeaderLeft = none + tv_header_left.text = tipArray[none] + } + if (tipHeaderMiddle == i) { + tipHeaderMiddle = none + tv_header_middle.text = tipArray[none] + } + if (tipHeaderRight == i) { + tipHeaderRight = none + tv_header_right.text = tipArray[none] + } + if (tipFooterMiddle == i) { + tipFooterMiddle = none + tv_footer_middle.text = tipArray[none] + } + if (tipFooterRight == i) { + tipFooterRight = none + tv_footer_right.text = tipArray[none] + } + } + tipFooterLeft = i + tv_footer_left.text = tipArray[i] + } postEvent(EventBus.UP_CONFIG, true) } } tv_footer_middle.onClick { selector(items = ReadTipConfig.tipArray.toList()) { _, i -> - ReadTipConfig.tipFooterMiddle = i - tv_footer_middle.text = ReadTipConfig.tipArray[i] + ReadTipConfig.apply { + if (i != none) { + if (tipHeaderLeft == i) { + tipHeaderLeft = none + tv_header_left.text = tipArray[none] + } + if (tipHeaderMiddle == i) { + tipHeaderMiddle = none + tv_header_middle.text = tipArray[none] + } + if (tipHeaderRight == i) { + tipHeaderRight = none + tv_header_right.text = tipArray[none] + } + if (tipFooterLeft == i) { + tipFooterLeft = none + tv_footer_left.text = tipArray[none] + } + if (tipFooterRight == i) { + tipFooterRight = none + tv_footer_right.text = tipArray[none] + } + } + tipFooterMiddle = i + tv_footer_middle.text = tipArray[i] + } postEvent(EventBus.UP_CONFIG, true) } } tv_footer_right.onClick { selector(items = ReadTipConfig.tipArray.toList()) { _, i -> - ReadTipConfig.tipFooterRight = i - tv_footer_right.text = ReadTipConfig.tipArray[i] + ReadTipConfig.apply { + if (i != none) { + if (tipHeaderLeft == i) { + tipHeaderLeft = none + tv_header_left.text = tipArray[none] + } + if (tipHeaderMiddle == i) { + tipHeaderMiddle = none + tv_header_middle.text = tipArray[none] + } + if (tipHeaderRight == i) { + tipHeaderRight = none + tv_header_right.text = tipArray[none] + } + if (tipFooterLeft == i) { + tipFooterLeft = none + tv_footer_left.text = tipArray[none] + } + if (tipFooterMiddle == i) { + tipFooterMiddle = none + tv_footer_middle.text = tipArray[none] + } + } + tipFooterRight = i + tv_footer_right.text = tipArray[i] + } postEvent(EventBus.UP_CONFIG, true) } }