mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
fdb649a27c
commit
77711af564
@ -1377,40 +1377,38 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
|
|
||||||
/* 全文搜索跳转 */
|
/* 全文搜索跳转 */
|
||||||
private fun skipToSearch(searchResult: SearchResult) {
|
private fun skipToSearch(searchResult: SearchResult) {
|
||||||
val previousResult = binding.searchMenu.previousSearchResult
|
if (searchResult.chapterIndex != ReadBook.durChapterIndex) {
|
||||||
|
|
||||||
fun jumpToPosition() {
|
|
||||||
val curTextChapter = ReadBook.curTextChapter ?: return
|
|
||||||
binding.searchMenu.updateSearchInfo()
|
|
||||||
val (pageIndex, lineIndex, charIndex, addLine, charIndex2) =
|
|
||||||
viewModel.searchResultPositions(curTextChapter, searchResult)
|
|
||||||
ReadBook.skipToPage(pageIndex) {
|
|
||||||
isSelectingSearchResult = true
|
|
||||||
binding.readView.curPage.selectStartMoveIndex(0, lineIndex, charIndex)
|
|
||||||
when (addLine) {
|
|
||||||
0 -> binding.readView.curPage.selectEndMoveIndex(
|
|
||||||
0,
|
|
||||||
lineIndex,
|
|
||||||
charIndex + viewModel.searchContentQuery.length - 1
|
|
||||||
)
|
|
||||||
|
|
||||||
1 -> binding.readView.curPage.selectEndMoveIndex(
|
|
||||||
0, lineIndex + 1, charIndex2
|
|
||||||
)
|
|
||||||
//consider change page, jump to scroll position
|
|
||||||
-1 -> binding.readView.curPage.selectEndMoveIndex(1, 0, charIndex2)
|
|
||||||
}
|
|
||||||
binding.readView.isTextSelected = true
|
|
||||||
isSelectingSearchResult = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (searchResult.chapterIndex != previousResult?.chapterIndex) {
|
|
||||||
viewModel.openChapter(searchResult.chapterIndex) {
|
viewModel.openChapter(searchResult.chapterIndex) {
|
||||||
jumpToPosition()
|
jumpToPosition(searchResult)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
jumpToPosition()
|
jumpToPosition(searchResult)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun jumpToPosition(searchResult: SearchResult) {
|
||||||
|
val curTextChapter = ReadBook.curTextChapter ?: return
|
||||||
|
binding.searchMenu.updateSearchInfo()
|
||||||
|
val (pageIndex, lineIndex, charIndex, addLine, charIndex2) =
|
||||||
|
viewModel.searchResultPositions(curTextChapter, searchResult)
|
||||||
|
ReadBook.skipToPage(pageIndex) {
|
||||||
|
isSelectingSearchResult = true
|
||||||
|
binding.readView.curPage.selectStartMoveIndex(0, lineIndex, charIndex)
|
||||||
|
when (addLine) {
|
||||||
|
0 -> binding.readView.curPage.selectEndMoveIndex(
|
||||||
|
0,
|
||||||
|
lineIndex,
|
||||||
|
charIndex + viewModel.searchContentQuery.length - 1
|
||||||
|
)
|
||||||
|
|
||||||
|
1 -> binding.readView.curPage.selectEndMoveIndex(
|
||||||
|
0, lineIndex + 1, charIndex2
|
||||||
|
)
|
||||||
|
//consider change page, jump to scroll position
|
||||||
|
-1 -> binding.readView.curPage.selectEndMoveIndex(1, 0, charIndex2)
|
||||||
|
}
|
||||||
|
binding.readView.isTextSelected = true
|
||||||
|
isSelectingSearchResult = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user