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

View File

@@ -193,6 +193,12 @@ object ReadBook : CoroutineScope by MainScope() {
nextTextChapter = null
}
fun clearSearchResult() {
curTextChapter?.clearSearchResult()
prevTextChapter?.clearSearchResult()
nextTextChapter?.clearSearchResult()
}
fun uploadProgress() {
book?.let {
launch(IO) {
@@ -230,6 +236,7 @@ object ReadBook : CoroutineScope by MainScope() {
hasNextPage = true
it.getPage(durPageIndex)?.removePageAloudSpan()
durChapterPos = nextPagePos
callBack?.cancelSelect()
callBack?.upContent()
saveRead(true)
}
@@ -885,6 +892,8 @@ object ReadBook : CoroutineScope by MainScope() {
fun upPageAnim(upRecorder: Boolean = false)
fun notifyBookChanged()
fun cancelSelect()
}
}

View File

@@ -852,8 +852,7 @@ class ReadBookActivity : BaseReadBookActivity(),
*/
override fun onMenuActionFinally() = binding.run {
textActionMenu.dismiss()
readView.curPage.cancelSelect()
readView.isTextSelected = false
readView.cancelSelect()
}
private fun speak(text: String) {
@@ -958,7 +957,6 @@ class ReadBookActivity : BaseReadBookActivity(),
success: (() -> Unit)?
) {
lifecycleScope.launch {
binding.readView.cancelSelect()
binding.readView.upContent(relativePosition, resetPageOffset)
if (relativePosition == 0) {
upSeekBarProgress()
@@ -973,7 +971,6 @@ class ReadBookActivity : BaseReadBookActivity(),
resetPageOffset: Boolean,
success: (() -> Unit)?
) = withContext(Main.immediate) {
binding.readView.cancelSelect()
binding.readView.upContent(relativePosition, resetPageOffset)
if (relativePosition == 0) {
upSeekBarProgress()
@@ -994,6 +991,12 @@ class ReadBookActivity : BaseReadBookActivity(),
}
}
override fun cancelSelect() {
runOnUiThread {
binding.readView.cancelSelect()
}
}
/**
* 页面改变
*/
@@ -1184,11 +1187,8 @@ class ReadBookActivity : BaseReadBookActivity(),
isShowingSearchResult = false
binding.searchMenu.invalidate()
binding.searchMenu.invisible()
binding.readView.isTextSelected = false
ReadBook.curTextChapter?.clearSearchResult()
ReadBook.prevTextChapter?.clearSearchResult()
ReadBook.nextTextChapter?.clearSearchResult()
binding.readView.curPage.cancelSelect(true)
ReadBook.clearSearchResult()
binding.readView.cancelSelect(true)
}
}

View File

@@ -254,9 +254,9 @@ class ReadView(context: Context, attrs: AttributeSet) :
return true
}
fun cancelSelect() {
fun cancelSelect(clearSearchResult: Boolean = false) {
if (isTextSelected) {
curPage.cancelSelect()
curPage.cancelSelect(clearSearchResult)
isTextSelected = false
}
}