feat: 优化代码

pull/115/head
kunfei 5 years ago
parent 4873fbf57d
commit dc51d97356
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 22
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  3. 7
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  4. 31
      app/src/main/res/layout/item_toc_regex.xml

@ -385,6 +385,12 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(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
)
}
}
}

@ -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<TxtTocRule>(context, R.layout.item_toc_regex) {
override fun convert(holder: ItemViewHolder, item: TxtTocRule, payloads: MutableList<Any>) {
}
override fun registerListener(holder: ItemViewHolder) {
}
}
}

@ -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 -> {

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:padding="8dp"
android:orientation="horizontal">
<io.legado.app.lib.theme.view.ATERadioButton
android:id="@+id/rb_regex_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/tv_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:padding="8dp"
android:text="@string/edit" />
<TextView
android:id="@+id/tv_del"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:padding="8dp"
android:text="@string/delete" />
</LinearLayout>
Loading…
Cancel
Save