feat: 优化代码

pull/106/head
kunfei 5 years ago
parent 714dcdac23
commit f7b434f4b7
  1. 11
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -6,20 +6,17 @@ import android.graphics.Paint
import android.util.AttributeSet import android.util.AttributeSet
import android.view.View import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.PreferKey
import io.legado.app.help.ReadBookConfig import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.book.read.page.entities.TextPage import io.legado.app.ui.book.read.page.entities.TextPage
import io.legado.app.utils.getCompatColor import io.legado.app.utils.getCompatColor
import io.legado.app.utils.getPrefBoolean
class ContentTextView : View { class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, attrs) {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
: super(context, attrs, defStyleAttr)
var selectAble = context.getPrefBoolean(PreferKey.textSelectAble)
private val selectedPaint by lazy { private val selectedPaint by lazy {
Paint().apply { Paint().apply {
color = context.getCompatColor(R.color.btn_bg_press) color = context.getCompatColor(R.color.btn_bg_press)

@ -105,12 +105,8 @@ class ContentView : FrameLayout {
} }
} }
fun isTextSelected(): Boolean { fun upSelectAble(selectAble: Boolean) {
return false content_text_view.selectAble = selectAble
}
fun contentTextView(): ContentTextView? {
return content_text_view
} }
fun scrollTo(pos: Int?) { fun scrollTo(pos: Int?) {

@ -153,6 +153,7 @@ class PageView(context: Context, attrs: AttributeSet) :
fun upSelectAble(selectAble: Boolean) { fun upSelectAble(selectAble: Boolean) {
pageDelegate?.upSelectAble(selectAble) pageDelegate?.upSelectAble(selectAble)
curPage.upSelectAble(selectAble)
} }
fun upStyle() { fun upStyle() {

Loading…
Cancel
Save