优化
This commit is contained in:
@@ -51,7 +51,6 @@ import io.legado.app.ui.book.read.config.TipConfigDialog.Companion.TIP_COLOR
|
|||||||
import io.legado.app.ui.book.read.page.ContentTextView
|
import io.legado.app.ui.book.read.page.ContentTextView
|
||||||
import io.legado.app.ui.book.read.page.ReadView
|
import io.legado.app.ui.book.read.page.ReadView
|
||||||
import io.legado.app.ui.book.read.page.entities.PageDirection
|
import io.legado.app.ui.book.read.page.entities.PageDirection
|
||||||
import io.legado.app.ui.book.read.page.provider.ImageProvider
|
|
||||||
import io.legado.app.ui.book.read.page.provider.TextPageFactory
|
import io.legado.app.ui.book.read.page.provider.TextPageFactory
|
||||||
import io.legado.app.ui.book.searchContent.SearchContentActivity
|
import io.legado.app.ui.book.searchContent.SearchContentActivity
|
||||||
import io.legado.app.ui.book.searchContent.SearchResult
|
import io.legado.app.ui.book.searchContent.SearchResult
|
||||||
@@ -137,7 +136,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
val textActionMenu: TextActionMenu by lazy {
|
val textActionMenu: TextActionMenu by lazy {
|
||||||
TextActionMenu(this, this)
|
TextActionMenu(this, this)
|
||||||
}
|
}
|
||||||
private val imagePopupAction: PopupAction by lazy {
|
private val popupAction: PopupAction by lazy {
|
||||||
PopupAction(this)
|
PopupAction(this)
|
||||||
}
|
}
|
||||||
override val isInitFinish: Boolean get() = viewModel.isInitFinish
|
override val isInitFinish: Boolean get() = viewModel.isInitFinish
|
||||||
@@ -961,26 +960,23 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
*/
|
*/
|
||||||
@SuppressLint("RtlHardcoded")
|
@SuppressLint("RtlHardcoded")
|
||||||
override fun onImageLongPress(x: Float, y: Float, src: String) {
|
override fun onImageLongPress(x: Float, y: Float, src: String) {
|
||||||
imagePopupAction.setItems(
|
popupAction.setItems(
|
||||||
listOf(
|
listOf(
|
||||||
SelectItem(getString(R.string.show), "show"),
|
SelectItem(getString(R.string.show), "show"),
|
||||||
SelectItem(getString(R.string.refresh), "refresh")
|
SelectItem(getString(R.string.refresh), "refresh")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
imagePopupAction.onActionClick = {
|
popupAction.onActionClick = {
|
||||||
when (it) {
|
when (it) {
|
||||||
"show" -> showDialogFragment(PhotoDialog(src))
|
"show" -> showDialogFragment(PhotoDialog(src))
|
||||||
"refresh" -> {
|
"refresh" -> viewModel.refreshImage(src)
|
||||||
ImageProvider.bitmapLruCache.remove(src)
|
|
||||||
ReadBook.loadContent(false)
|
|
||||||
}
|
}
|
||||||
}
|
popupAction.dismiss()
|
||||||
imagePopupAction.dismiss()
|
|
||||||
}
|
}
|
||||||
val navigationBarHeight =
|
val navigationBarHeight =
|
||||||
if (!ReadBookConfig.hideNavigationBar && navigationBarGravity == Gravity.BOTTOM)
|
if (!ReadBookConfig.hideNavigationBar && navigationBarGravity == Gravity.BOTTOM)
|
||||||
navigationBarHeight else 0
|
navigationBarHeight else 0
|
||||||
imagePopupAction.showAtLocation(
|
popupAction.showAtLocation(
|
||||||
binding.readView, Gravity.BOTTOM or Gravity.LEFT, x.toInt(),
|
binding.readView, Gravity.BOTTOM or Gravity.LEFT, x.toInt(),
|
||||||
binding.root.height + navigationBarHeight - y.toInt()
|
binding.root.height + navigationBarHeight - y.toInt()
|
||||||
)
|
)
|
||||||
@@ -1104,7 +1100,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
textActionMenu.dismiss()
|
textActionMenu.dismiss()
|
||||||
imagePopupAction.dismiss()
|
popupAction.dismiss()
|
||||||
binding.readView.onDestroy()
|
binding.readView.onDestroy()
|
||||||
ReadBook.msg = null
|
ReadBook.msg = null
|
||||||
ReadBook.callBack = null
|
ReadBook.callBack = null
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import io.legado.app.model.localBook.LocalBook
|
|||||||
import io.legado.app.model.webBook.WebBook
|
import io.legado.app.model.webBook.WebBook
|
||||||
import io.legado.app.service.BaseReadAloudService
|
import io.legado.app.service.BaseReadAloudService
|
||||||
import io.legado.app.ui.book.read.page.entities.TextChapter
|
import io.legado.app.ui.book.read.page.entities.TextChapter
|
||||||
|
import io.legado.app.ui.book.read.page.provider.ImageProvider
|
||||||
import io.legado.app.ui.book.searchContent.SearchResult
|
import io.legado.app.ui.book.searchContent.SearchResult
|
||||||
import io.legado.app.utils.msg
|
import io.legado.app.utils.msg
|
||||||
import io.legado.app.utils.postEvent
|
import io.legado.app.utils.postEvent
|
||||||
@@ -398,6 +399,17 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
|||||||
return arrayOf(pageIndex, lineIndex, charIndex, addLine, charIndex2)
|
return arrayOf(pageIndex, lineIndex, charIndex, addLine, charIndex2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun refreshImage(src: String) {
|
||||||
|
execute {
|
||||||
|
ImageProvider.bitmapLruCache.remove(src)
|
||||||
|
ReadBook.book?.let { book ->
|
||||||
|
BookHelp.getImage(book, src).delete()
|
||||||
|
}
|
||||||
|
}.onFinally {
|
||||||
|
ReadBook.loadContent(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换规则变化
|
* 替换规则变化
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user