From b6fd6862850287f4374307883966a8c616ae1772 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 14 Sep 2019 13:44:43 +0800 Subject: [PATCH] up --- .../book/read/config/PaddingConfigDialog.kt | 40 ++++++------------- .../io/legado/app/utils/ViewExtensions.kt | 10 ++--- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt index 3c172cea2..43aeaad2d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt @@ -12,6 +12,7 @@ import io.legado.app.constant.Bus import io.legado.app.help.ReadBookConfig import io.legado.app.ui.book.read.Help import io.legado.app.utils.postEvent +import io.legado.app.utils.progressAdd import kotlinx.android.synthetic.main.dialog_read_padding.* import org.jetbrains.anko.sdk27.listeners.onClick @@ -61,52 +62,35 @@ class PaddingConfigDialog : DialogFragment() { private fun initView() = with(ReadBookConfig.getConfig()) { iv_padding_top_add.onClick { - paddingTop++ - if (paddingTop > 100) paddingTop = 100 - seek_padding_top.progress = paddingTop - tv_padding_top.text = paddingTop.toString() + seek_padding_top.progressAdd(1) postEvent(Bus.UP_CONFIG, true) } iv_padding_top_remove.onClick { - paddingTop-- - if (paddingTop < 0) paddingTop = 0 - seek_padding_top.progress = paddingTop - tv_padding_top.text = paddingTop.toString() + seek_padding_top.progressAdd(-1) postEvent(Bus.UP_CONFIG, true) } iv_padding_bottom_add.onClick { - paddingBottom++ - if (paddingBottom > 100) paddingBottom = 100 - seek_padding_bottom.progress = paddingBottom - tv_padding_bottom.text = paddingBottom.toString() + seek_padding_bottom.progressAdd(1) postEvent(Bus.UP_CONFIG, true) } iv_padding_bottom_remove.onClick { - paddingBottom-- - if (paddingBottom < 0) paddingBottom = 0 - seek_padding_bottom.progress = paddingBottom - tv_padding_bottom.text = paddingBottom.toString() + seek_padding_bottom.progressAdd(-1) postEvent(Bus.UP_CONFIG, true) } iv_padding_left_add.onClick { - paddingLeft++ - if (paddingLeft > 100) paddingLeft = 100 - seek_padding_left.progress = paddingLeft - tv_padding_left.text = paddingLeft.toString() + seek_padding_left.progressAdd(1) postEvent(Bus.UP_CONFIG, true) } iv_padding_left_remove.onClick { - paddingLeft++ - if (paddingLeft < 0) paddingLeft = 0 - seek_padding_left.progress = paddingLeft - tv_padding_left.text = paddingLeft.toString() + seek_padding_left.progressAdd(-1) postEvent(Bus.UP_CONFIG, true) } iv_padding_right_add.onClick { - paddingRight++ - if (paddingRight > 100) paddingRight = 100 - seek_padding_right.progress = paddingRight - tv_padding_right.text = paddingRight.toString() + seek_padding_right.progressAdd(1) + postEvent(Bus.UP_CONFIG, true) + } + iv_padding_right_remove.onClick { + seek_padding_right.progressAdd(-1) postEvent(Bus.UP_CONFIG, true) } diff --git a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt index 1c7fb29c3..81cdafe81 100644 --- a/app/src/main/java/io/legado/app/utils/ViewExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ViewExtensions.kt @@ -3,17 +3,13 @@ package io.legado.app.utils import android.content.Context import android.graphics.Bitmap import android.graphics.Canvas -import android.graphics.Rect import android.os.Build -import android.os.Handler -import android.view.PixelCopy import android.view.View import android.view.View.* import android.view.inputmethod.InputMethodManager +import android.widget.SeekBar import androidx.appcompat.app.AppCompatActivity import io.legado.app.App -import android.opengl.ETC1.getHeight -import android.opengl.ETC1.getWidth private tailrec fun getCompatActivity(context: Context?): AppCompatActivity? { @@ -61,4 +57,8 @@ fun View.screenshot(): Bitmap? { draw(c) screenshot }.getOrNull() +} + +fun SeekBar.progressAdd(int: Int) { + progress += int } \ No newline at end of file