mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
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.ReadView
|
||||
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.searchContent.SearchContentActivity
|
||||
import io.legado.app.ui.book.searchContent.SearchResult
|
||||
@@ -137,7 +136,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
val textActionMenu: TextActionMenu by lazy {
|
||||
TextActionMenu(this, this)
|
||||
}
|
||||
private val imagePopupAction: PopupAction by lazy {
|
||||
private val popupAction: PopupAction by lazy {
|
||||
PopupAction(this)
|
||||
}
|
||||
override val isInitFinish: Boolean get() = viewModel.isInitFinish
|
||||
@@ -961,26 +960,23 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
*/
|
||||
@SuppressLint("RtlHardcoded")
|
||||
override fun onImageLongPress(x: Float, y: Float, src: String) {
|
||||
imagePopupAction.setItems(
|
||||
popupAction.setItems(
|
||||
listOf(
|
||||
SelectItem(getString(R.string.show), "show"),
|
||||
SelectItem(getString(R.string.refresh), "refresh")
|
||||
)
|
||||
)
|
||||
imagePopupAction.onActionClick = {
|
||||
popupAction.onActionClick = {
|
||||
when (it) {
|
||||
"show" -> showDialogFragment(PhotoDialog(src))
|
||||
"refresh" -> {
|
||||
ImageProvider.bitmapLruCache.remove(src)
|
||||
ReadBook.loadContent(false)
|
||||
}
|
||||
"refresh" -> viewModel.refreshImage(src)
|
||||
}
|
||||
imagePopupAction.dismiss()
|
||||
popupAction.dismiss()
|
||||
}
|
||||
val navigationBarHeight =
|
||||
if (!ReadBookConfig.hideNavigationBar && navigationBarGravity == Gravity.BOTTOM)
|
||||
navigationBarHeight else 0
|
||||
imagePopupAction.showAtLocation(
|
||||
popupAction.showAtLocation(
|
||||
binding.readView, Gravity.BOTTOM or Gravity.LEFT, x.toInt(),
|
||||
binding.root.height + navigationBarHeight - y.toInt()
|
||||
)
|
||||
@@ -1104,7 +1100,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
textActionMenu.dismiss()
|
||||
imagePopupAction.dismiss()
|
||||
popupAction.dismiss()
|
||||
binding.readView.onDestroy()
|
||||
ReadBook.msg = 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.service.BaseReadAloudService
|
||||
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.utils.msg
|
||||
import io.legado.app.utils.postEvent
|
||||
@@ -398,6 +399,17 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
|
||||
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