feat: 优化代码

pull/106/head
kunfei 5 years ago
parent 2b1de39c1c
commit 43004c8fad
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 7
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt

@ -35,6 +35,7 @@ import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR
import io.legado.app.ui.book.read.page.ChapterProvider
import io.legado.app.ui.book.read.page.PageView
import io.legado.app.ui.book.read.page.delegate.PageDelegate
import io.legado.app.ui.book.read.page.entities.TextChar
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.changesource.ChangeSourceDialog
import io.legado.app.ui.chapterlist.ChapterListActivity
@ -389,6 +390,11 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
}
}
override fun selectText(textChar: TextChar) {
cursor_left
cursor_right
}
override fun showReadAloudDialog() {
ReadAloudDialog().show(supportFragmentManager, "readAloud")
}

@ -11,6 +11,7 @@ import io.legado.app.help.ReadBookConfig
import io.legado.app.service.help.ReadBook
import io.legado.app.ui.book.read.page.delegate.*
import io.legado.app.ui.book.read.page.entities.TextChapter
import io.legado.app.ui.book.read.page.entities.TextChar
import io.legado.app.utils.activity
import io.legado.app.utils.getPrefInt
@ -241,6 +242,8 @@ class PageView(context: Context, attrs: AttributeSet) :
interface CallBack {
val isInitFinish: Boolean
/**
* 保存页数
*/
@ -251,8 +254,8 @@ class PageView(context: Context, attrs: AttributeSet) :
*/
fun clickCenter()
val isInitFinish: Boolean
fun screenOffTimerStart()
fun selectText(textChar: TextChar)
}
}

@ -268,6 +268,9 @@ abstract class PageDelegate(protected val pageView: PageView) :
override fun onLongPress(e: MotionEvent) {
val textChar = curPage.selectText(e)
textChar?.let {
pageView.callBack?.selectText(it)
}
}
/**

Loading…
Cancel
Save