feat: 优化代码

pull/134/head^2
kunfei 5 years ago
parent c7f7e48998
commit 113ba477db
  1. 17
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 9
      app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  4. 1
      app/src/main/res/layout/dialog_read_padding.xml

@ -170,6 +170,17 @@ object ReadBookConfig {
set(value) = set(value) =
if (shareLayout) shareConfig.titleMode = value else durConfig.titleMode = value if (shareLayout) shareConfig.titleMode = value else durConfig.titleMode = value
var titleTopSpacing: Int
get() = if (shareLayout) shareConfig.titleTopSpacing else durConfig.titleTopSpacing
set(value) =
if (shareLayout) shareConfig.titleTopSpacing = value
else durConfig.titleTopSpacing = value
var titleBottomSpacing: Int
get() = if (shareLayout) shareConfig.titleBottomSpacing else durConfig.titleBottomSpacing
set(value) =
if (shareLayout) shareConfig.titleBottomSpacing = value
else durConfig.titleBottomSpacing = value
var paddingBottom: Int var paddingBottom: Int
get() = if (shareLayout) shareConfig.paddingBottom else durConfig.paddingBottom get() = if (shareLayout) shareConfig.paddingBottom else durConfig.paddingBottom
set(value) = set(value) =
@ -238,6 +249,12 @@ object ReadBookConfig {
if (shareLayout) shareConfig.footerPaddingTop = value if (shareLayout) shareConfig.footerPaddingTop = value
else durConfig.footerPaddingTop = value else durConfig.footerPaddingTop = value
var showFooterLine: Boolean
get() = if (shareLayout) shareConfig.showFooterLine else durConfig.showFooterLine
set(value) =
if (shareLayout) shareConfig.showFooterLine = value
else durConfig.showFooterLine = value
@Keep @Keep
class Config( class Config(
private var bgStr: String = "#EEEEEE",//白天背景 private var bgStr: String = "#EEEEEE",//白天背景

@ -52,7 +52,7 @@ class PaddingConfigDialog : DialogFragment() {
ReadBookConfig.save() ReadBookConfig.save()
} }
private fun initData() = with(ReadBookConfig) { private fun initData() = ReadBookConfig.apply {
if (hideStatusBar) { if (hideStatusBar) {
ll_header_padding.visible() ll_header_padding.visible()
tv_body_padding.setPadding(0, 10.dp, 0, 10.dp) tv_body_padding.setPadding(0, 10.dp, 0, 10.dp)
@ -75,6 +75,7 @@ class PaddingConfigDialog : DialogFragment() {
dsb_footer_padding_bottom.progress = footerPaddingBottom dsb_footer_padding_bottom.progress = footerPaddingBottom
dsb_footer_padding_left.progress = footerPaddingLeft dsb_footer_padding_left.progress = footerPaddingLeft
dsb_footer_padding_right.progress = footerPaddingRight dsb_footer_padding_right.progress = footerPaddingRight
cb_show_line.isChecked = showFooterLine
} }
private fun initView() = with(ReadBookConfig) { private fun initView() = with(ReadBookConfig) {
@ -129,6 +130,12 @@ class PaddingConfigDialog : DialogFragment() {
footerPaddingRight = it footerPaddingRight = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
cb_show_line.onCheckedChangeListener = { cb, isChecked ->
if (cb.isPressed) {
showFooterLine = isChecked
postEvent(EventBus.UP_CONFIG, true)
}
}
} }
} }

@ -60,6 +60,7 @@ class ContentView(context: Context) : FrameLayout(context) {
footerPaddingRight.dp, footerPaddingRight.dp,
footerPaddingBottom.dp footerPaddingBottom.dp
) )
vw_bottom_divider.visible(showFooterLine)
content_text_view.upVisibleRect() content_text_view.upVisibleRect()
durConfig.textColor().let { durConfig.textColor().let {
tv_top_left.setTextColor(it) tv_top_left.setTextColor(it)

@ -109,6 +109,7 @@
android:text="@string/showLine" /> android:text="@string/showLine" />
<io.legado.app.ui.widget.checkbox.SmoothCheckBox <io.legado.app.ui.widget.checkbox.SmoothCheckBox
android:id="@+id/cb_show_line"
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_margin="6dp" /> android:layout_margin="6dp" />

Loading…
Cancel
Save