feat: 优化代码

pull/141/head
kunfei 5 years ago
parent e256189b06
commit 9a46411a37
  1. 7
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 11
      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. 9
      app/src/main/res/layout/dialog_read_padding.xml

@ -251,6 +251,12 @@ object ReadBookConfig {
if (shareLayout) shareConfig.footerPaddingTop = value
else durConfig.footerPaddingTop = value
var showHeaderLine: Boolean
get() = if (shareLayout) shareConfig.showHeaderLine else durConfig.showHeaderLine
set(value) =
if (shareLayout) shareConfig.showHeaderLine = value
else durConfig.showHeaderLine = value
var showFooterLine: Boolean
get() = if (shareLayout) shareConfig.showFooterLine else durConfig.showFooterLine
set(value) =
@ -288,6 +294,7 @@ object ReadBookConfig {
var footerPaddingLeft: Int = 16,
var footerPaddingRight: Int = 16,
var footerPaddingTop: Int = 6,
var showHeaderLine: Boolean = false,
var showFooterLine: Boolean = true
) {
fun setBg(bgType: Int, bg: String) {

@ -76,7 +76,8 @@ class PaddingConfigDialog : DialogFragment() {
dsb_footer_padding_bottom.progress = footerPaddingBottom
dsb_footer_padding_left.progress = footerPaddingLeft
dsb_footer_padding_right.progress = footerPaddingRight
cb_show_line.isChecked = showFooterLine
cb_show_top_line.isChecked = showHeaderLine
cb_show_bottom_line.isChecked = showFooterLine
}
private fun initView() = with(ReadBookConfig) {
@ -131,7 +132,13 @@ class PaddingConfigDialog : DialogFragment() {
footerPaddingRight = it
postEvent(EventBus.UP_CONFIG, true)
}
cb_show_line.onCheckedChangeListener = { cb, isChecked ->
cb_show_top_line.onCheckedChangeListener = { cb, isChecked ->
if (cb.isPressed) {
showHeaderLine = isChecked
postEvent(EventBus.UP_CONFIG, true)
}
}
cb_show_bottom_line.onCheckedChangeListener = { cb, isChecked ->
if (cb.isPressed) {
showFooterLine = isChecked
postEvent(EventBus.UP_CONFIG, true)

@ -61,6 +61,7 @@ class ContentView(context: Context) : FrameLayout(context) {
footerPaddingRight.dp,
footerPaddingBottom.dp
)
vw_top_divider.visible(showHeaderLine)
vw_bottom_divider.visible(showFooterLine)
content_text_view.upVisibleRect()
durConfig.textColor().let {

@ -11,19 +11,20 @@
android:id="@+id/ll_header_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<io.legado.app.ui.widget.text.AccentTextView
android:id="@+id/tv_header_padding"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:layout_weight="1"
android:textSize="18sp"
android:text="@string/header" />
@ -128,7 +129,7 @@
android:text="@string/showLine" />
<io.legado.app.ui.widget.checkbox.SmoothCheckBox
android:id="@+id/cb_show_line"
android:id="@+id/cb_show_bottom_line"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_margin="6dp" />

Loading…
Cancel
Save