This commit is contained in:
Horis
2024-08-25 17:12:01 +08:00
parent e06cc88901
commit 96be80aaaf
3 changed files with 20 additions and 11 deletions
@@ -193,6 +193,12 @@ object ReadBook : CoroutineScope by MainScope() {
nextTextChapter = null nextTextChapter = null
} }
fun clearSearchResult() {
curTextChapter?.clearSearchResult()
prevTextChapter?.clearSearchResult()
nextTextChapter?.clearSearchResult()
}
fun uploadProgress() { fun uploadProgress() {
book?.let { book?.let {
launch(IO) { launch(IO) {
@@ -230,6 +236,7 @@ object ReadBook : CoroutineScope by MainScope() {
hasNextPage = true hasNextPage = true
it.getPage(durPageIndex)?.removePageAloudSpan() it.getPage(durPageIndex)?.removePageAloudSpan()
durChapterPos = nextPagePos durChapterPos = nextPagePos
callBack?.cancelSelect()
callBack?.upContent() callBack?.upContent()
saveRead(true) saveRead(true)
} }
@@ -885,6 +892,8 @@ object ReadBook : CoroutineScope by MainScope() {
fun upPageAnim(upRecorder: Boolean = false) fun upPageAnim(upRecorder: Boolean = false)
fun notifyBookChanged() fun notifyBookChanged()
fun cancelSelect()
} }
} }
@@ -852,8 +852,7 @@ class ReadBookActivity : BaseReadBookActivity(),
*/ */
override fun onMenuActionFinally() = binding.run { override fun onMenuActionFinally() = binding.run {
textActionMenu.dismiss() textActionMenu.dismiss()
readView.curPage.cancelSelect() readView.cancelSelect()
readView.isTextSelected = false
} }
private fun speak(text: String) { private fun speak(text: String) {
@@ -958,7 +957,6 @@ class ReadBookActivity : BaseReadBookActivity(),
success: (() -> Unit)? success: (() -> Unit)?
) { ) {
lifecycleScope.launch { lifecycleScope.launch {
binding.readView.cancelSelect()
binding.readView.upContent(relativePosition, resetPageOffset) binding.readView.upContent(relativePosition, resetPageOffset)
if (relativePosition == 0) { if (relativePosition == 0) {
upSeekBarProgress() upSeekBarProgress()
@@ -973,7 +971,6 @@ class ReadBookActivity : BaseReadBookActivity(),
resetPageOffset: Boolean, resetPageOffset: Boolean,
success: (() -> Unit)? success: (() -> Unit)?
) = withContext(Main.immediate) { ) = withContext(Main.immediate) {
binding.readView.cancelSelect()
binding.readView.upContent(relativePosition, resetPageOffset) binding.readView.upContent(relativePosition, resetPageOffset)
if (relativePosition == 0) { if (relativePosition == 0) {
upSeekBarProgress() upSeekBarProgress()
@@ -994,6 +991,12 @@ class ReadBookActivity : BaseReadBookActivity(),
} }
} }
override fun cancelSelect() {
runOnUiThread {
binding.readView.cancelSelect()
}
}
/** /**
* 页面改变 * 页面改变
*/ */
@@ -1184,11 +1187,8 @@ class ReadBookActivity : BaseReadBookActivity(),
isShowingSearchResult = false isShowingSearchResult = false
binding.searchMenu.invalidate() binding.searchMenu.invalidate()
binding.searchMenu.invisible() binding.searchMenu.invisible()
binding.readView.isTextSelected = false ReadBook.clearSearchResult()
ReadBook.curTextChapter?.clearSearchResult() binding.readView.cancelSelect(true)
ReadBook.prevTextChapter?.clearSearchResult()
ReadBook.nextTextChapter?.clearSearchResult()
binding.readView.curPage.cancelSelect(true)
} }
} }
@@ -254,9 +254,9 @@ class ReadView(context: Context, attrs: AttributeSet) :
return true return true
} }
fun cancelSelect() { fun cancelSelect(clearSearchResult: Boolean = false) {
if (isTextSelected) { if (isTextSelected) {
curPage.cancelSelect() curPage.cancelSelect(clearSearchResult)
isTextSelected = false isTextSelected = false
} }
} }