feat: 优化

pull/201/head
kunfei 5 years ago
parent 68bdd2d025
commit 2b5d0bd18e
  1. 168
      app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt

@ -60,43 +60,187 @@ class TipConfigDialog : BaseDialogFragment() {
private fun initEvent() { private fun initEvent() {
tv_header_left.onClick { tv_header_left.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i -> selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipHeaderLeft = i ReadTipConfig.apply {
tv_header_left.text = ReadTipConfig.tipArray[i] 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) postEvent(EventBus.UP_CONFIG, true)
} }
} }
tv_header_middle.onClick { tv_header_middle.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i -> selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipHeaderMiddle = i ReadTipConfig.apply {
tv_header_middle.text = ReadTipConfig.tipArray[i] 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) postEvent(EventBus.UP_CONFIG, true)
} }
} }
tv_header_right.onClick { tv_header_right.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i -> selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipHeaderRight = i ReadTipConfig.apply {
tv_header_right.text = ReadTipConfig.tipArray[i] 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) postEvent(EventBus.UP_CONFIG, true)
} }
} }
tv_footer_left.onClick { tv_footer_left.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i -> selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipFooterLeft = i ReadTipConfig.apply {
tv_footer_left.text = ReadTipConfig.tipArray[i] 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) postEvent(EventBus.UP_CONFIG, true)
} }
} }
tv_footer_middle.onClick { tv_footer_middle.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i -> selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipFooterMiddle = i ReadTipConfig.apply {
tv_footer_middle.text = ReadTipConfig.tipArray[i] 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) postEvent(EventBus.UP_CONFIG, true)
} }
} }
tv_footer_right.onClick { tv_footer_right.onClick {
selector(items = ReadTipConfig.tipArray.toList()) { _, i -> selector(items = ReadTipConfig.tipArray.toList()) { _, i ->
ReadTipConfig.tipFooterRight = i ReadTipConfig.apply {
tv_footer_right.text = ReadTipConfig.tipArray[i] 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) postEvent(EventBus.UP_CONFIG, true)
} }
} }

Loading…
Cancel
Save