From dc51d9735610ffbad2dd634c70b72d58d14e8e08 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 23 Feb 2020 09:21:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookActivity.kt | 6 ++++ .../app/ui/book/read/config/TocRegexDialog.kt | 22 +++++++++++++ .../app/ui/book/read/page/ContentTextView.kt | 7 +++++ app/src/main/res/layout/item_toc_regex.xml | 31 +++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 app/src/main/res/layout/item_toc_regex.xml diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 021338077..5e9b4b56b 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -385,6 +385,12 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo cursor_left.x.toInt() + cursor_left.width, page_view.height - cursor_left.y.toInt() + ReadBookConfig.durConfig.textSize.dp + popup.height ) + } else { + popup.update( + cursor_left.x.toInt() + cursor_left.width, + page_view.height - cursor_left.y.toInt() + ReadBookConfig.durConfig.textSize.dp + popup.height, + ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT + ) } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index 9ff3b69fe..f0cd6b31a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.read.config +import android.content.Context import android.os.Bundle import android.util.DisplayMetrics import android.view.LayoutInflater @@ -10,7 +11,10 @@ import androidx.appcompat.widget.Toolbar import androidx.fragment.app.FragmentManager import io.legado.app.R import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.ItemViewHolder +import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.constant.Theme +import io.legado.app.data.entities.TxtTocRule import io.legado.app.utils.applyTint import kotlinx.android.synthetic.main.dialog_toc_regex.* @@ -48,10 +52,28 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { tool_bar.inflateMenu(R.menu.txt_toc_regex) tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.setOnMenuItemClickListener(this) + initView() + } + + private fun initView() { + } override fun onMenuItemClick(item: MenuItem?): Boolean { return false } + + + inner class TocRegexDialog(context: Context) : + SimpleRecyclerAdapter(context, R.layout.item_toc_regex) { + + override fun convert(holder: ItemViewHolder, item: TxtTocRule, payloads: MutableList) { + + } + + override fun registerListener(holder: ItemViewHolder) { + + } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index fe9a8998e..6267136fb 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -35,6 +35,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at //滚动参数 private val maxScrollOffset = 100f private var pageOffset = 0f + private var linePos = 0 private var isLastPage = false init { @@ -136,6 +137,12 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at } } + fun resetPageOffset() { + pageOffset = 0f + linePos = 0 + isLastPage = false + } + private fun switchToPageOffset(offset: Int) { when (offset) { 1 -> { diff --git a/app/src/main/res/layout/item_toc_regex.xml b/app/src/main/res/layout/item_toc_regex.xml new file mode 100644 index 000000000..2022bad71 --- /dev/null +++ b/app/src/main/res/layout/item_toc_regex.xml @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file