feat: 优化代码

pull/111/head
kunfei 5 years ago
parent cf8c7f216b
commit 793d13e9dd
  1. 21
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt

@ -385,8 +385,14 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
} }
} }
/**
* 当前选择的文本
*/
override val selectedText: String get() = page_view.curPage.selectedText override val selectedText: String get() = page_view.curPage.selectedText
/**
* 文本选择菜单操作
*/
override fun onMenuItemSelected(item: MenuItemImpl): Boolean { override fun onMenuItemSelected(item: MenuItemImpl): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_replace -> ReplaceEditDialog R.id.menu_replace -> ReplaceEditDialog
@ -395,6 +401,9 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
return false return false
} }
/**
* 文本选择菜单操作完成
*/
override fun onMenuActionFinally() { override fun onMenuActionFinally() {
textActionMenu?.dismiss() textActionMenu?.dismiss()
page_view.pageDelegate?.isTextSelected = false page_view.pageDelegate?.isTextSelected = false
@ -431,12 +440,18 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
} }
} }
/**
* 更新内容
*/
override fun upContent(position: Int) { override fun upContent(position: Int) {
launch { launch {
page_view.upContent(position) page_view.upContent(position)
} }
} }
/**
* 更新视图
*/
override fun upView() { override fun upView() {
launch { launch {
ReadBook.curTextChapter?.let { ReadBook.curTextChapter?.let {
@ -454,12 +469,18 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
} }
} }
/**
* 更新进度条
*/
override fun upPageProgress() { override fun upPageProgress() {
launch { launch {
seek_read_page.progress = ReadBook.durPageIndex seek_read_page.progress = ReadBook.durPageIndex
} }
} }
/**
* 显示菜单
*/
override fun showMenuBar() { override fun showMenuBar() {
read_menu.runMenuIn() read_menu.runMenuIn()
} }

Loading…
Cancel
Save