|
|
|
@ -2128,12 +2128,14 @@ public abstract class PageLoader { |
|
|
|
|
|
|
|
|
|
public void skipToSearch(int chapterNum, int countInChapter, String keyword) { |
|
|
|
|
skipToChapter(chapterNum); |
|
|
|
|
if (mStatus != STATUS_FINISH){ |
|
|
|
|
if (mStatus != STATUS_FINISH) { |
|
|
|
|
App.getHandler().postDelayed(() -> skipToSearch(chapterNum, countInChapter, keyword), 300); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
int[] position = searchWordPositions(countInChapter, keyword); |
|
|
|
|
skipToPage(position[0]); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
mPageView.setFirstSelectTxtChar(mCurPage.txtLists.get(position[1]). |
|
|
|
|
getCharsData().get(position[2])); |
|
|
|
|
switch (position[3]) { |
|
|
|
@ -2153,6 +2155,9 @@ public abstract class PageLoader { |
|
|
|
|
} |
|
|
|
|
mPageView.setSelectMode(PageView.SelectMode.SelectMoveForward); |
|
|
|
|
mPageView.invalidate(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private int[] searchWordPositions(int countInChapter, String keyword) { |
|
|
|
@ -2195,9 +2200,14 @@ public abstract class PageLoader { |
|
|
|
|
|
|
|
|
|
// charIndex
|
|
|
|
|
String currentLine = currentPage.lines.get(lineIndex); |
|
|
|
|
if (currentLine.endsWith("\n")){ |
|
|
|
|
currentLine = StringUtils.trim(currentLine) + "\n"; |
|
|
|
|
}else { |
|
|
|
|
currentLine = StringUtils.trim(currentLine); |
|
|
|
|
} |
|
|
|
|
length -= currentLine.length(); |
|
|
|
|
int charIndex = contentPosition - length; |
|
|
|
|
if (charIndex < 0) charIndex = 0; |
|
|
|
|
int addLine = 0; |
|
|
|
|
int charIndex2 = 0; |
|
|
|
|
// change line
|
|
|
|
@ -2210,6 +2220,7 @@ public abstract class PageLoader { |
|
|
|
|
addLine = -1; |
|
|
|
|
charIndex2 = charIndex + keyword.length() - currentLine.length() - 1; |
|
|
|
|
} |
|
|
|
|
if (charIndex2 < 0) charIndex = 0; |
|
|
|
|
return new int[]{pageIndex, lineIndex, charIndex, addLine, charIndex2}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|