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() {
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)
}
}

Loading…
Cancel
Save