diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 563a6f27c..7120e047a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -781,10 +781,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo val query = data.getStringExtra("query") viewModel.openChapter(index) // block until load correct chapter and pages - while (ReadBook.durChapterIndex != index || ReadBook.curTextChapter?.pages == null ){ + var pages = ReadBook.curTextChapter?.pages + while (ReadBook.durChapterIndex != index || pages == null ){ delay(100L) + pages = ReadBook.curTextChapter?.pages } - val pages = ReadBook.curTextChapter?.pages val positions = ReadBook.searchResultPositions(pages, indexWithinChapter, query!!) //todo: show selected text val job1 = async(Main){