diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index dfa337ae7..2e96221f3 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -339,11 +339,9 @@ object ReadBook { index = content.indexOf(query, index + 1); count += 1 } - Log.d("h11128", "new index $index") val contentPosition = index var pageIndex = 0 var length = pages[pageIndex].text.length - Log.d("h11128", "page size ${pages.size}") while (length < contentPosition){ pageIndex += 1 if (pageIndex >pages.size){ @@ -351,16 +349,12 @@ object ReadBook { break } length += pages[pageIndex].text.length - Log.d("h11128", "to next page , add length change to $length") } - Log.d("h11128", "at pageindex $pageIndex") - // calculate search result's lineIndex val currentPage = pages[pageIndex] var lineIndex = 0 length = length - currentPage.text.length + currentPage.textLines[lineIndex].text.length - Log.d("h11128", "currentLine ${currentPage.textLines[lineIndex].text}") while (length < contentPosition){ lineIndex += 1 if (lineIndex >currentPage.textLines.size){ @@ -368,17 +362,12 @@ object ReadBook { break } length += currentPage.textLines[lineIndex].text.length - Log.d("h11128", "currentLine ${currentPage.textLines[lineIndex].text}") } // charIndex - Log.d("h11128", "currentLine ${currentPage.textLines[lineIndex].text}") - Log.d("h11128", "currentLength $length") val currentLine = currentPage.textLines[lineIndex] length -= currentLine.text.length - Log.d("h11128", "currentLength $length") val charIndex = contentPosition - length - Log.d("h11128", "contentLength $contentPosition") return arrayOf(pageIndex, lineIndex, charIndex) } 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 fc7e262af..563a6f27c 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 @@ -780,17 +780,12 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo val indexWithinChapter = data.getIntExtra("indexWithinChapter", 0) val query = data.getStringExtra("query") viewModel.openChapter(index) - // block until load correct chapter and pages while (ReadBook.durChapterIndex != index || ReadBook.curTextChapter?.pages == null ){ delay(100L) } val pages = ReadBook.curTextChapter?.pages - Log.d("Jason", "Current chapter pages ${pages!!.size}") val positions = ReadBook.searchResultPositions(pages, indexWithinChapter, query!!) - Log.d("h11128", positions[0].toString()) - Log.d("h11128", positions[1].toString()) - Log.d("h11128", positions[2].toString()) //todo: show selected text val job1 = async(Main){ ReadBook.skipToPage(positions[0]) diff --git a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchListFragment.kt b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchListFragment.kt index 646153b6c..38ac013df 100644 --- a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchListFragment.kt +++ b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchListFragment.kt @@ -121,15 +121,12 @@ class SearchListFragment : VMBaseFragment(R.layout.fragment val job = async(IO){ if (isLocalBook || adapter.cacheFileNames.contains(BookHelp.formatChapterName(chapter))) { searchResults = searchChapter(newText, chapter) - //Log.d("h11128", "find ${searchResults.size} results in chapter ${chapter.title}") } } job.await() if (searchResults.isNotEmpty()){ - //Log.d("h11128", "load ${searchResults.size} results in chapter ${chapter.title}") searchResultList.addAll(searchResults) tv_current_search_info.text = "搜索结果:$searchResultCounts" - //Log.d("h11128", "searchResultList size ${searchResultList.size}") adapter.addItems(searchResults) searchResults = listOf() } @@ -229,7 +226,6 @@ class SearchListFragment : VMBaseFragment(R.layout.fragment searchData.putExtra("contentPosition", searchResult.contentPosition) searchData.putExtra("query", searchResult.query) searchData.putExtra("indexWithinChapter", searchResult.indexWithinChapter) - Log.d("h11128","current chapter index ${searchResult.chapterIndex}") activity?.setResult(RESULT_OK, searchData) activity?.finish()