修复搜索结果绘制背景错位的bug

master
fengyuecanzhu 3 years ago
parent e62da66aed
commit dce96b599a
  1. 1
      app/src/main/java/xyz/fycz/myreader/ui/activity/SearchWordActivity.kt
  2. 13
      app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java

@ -100,6 +100,7 @@ class SearchWordActivity : BaseActivity() {
@Synchronized
override fun loadMore(item: SearchWord1) {
if (adapter.items.contains(item)) return
if (adapter.itemSize == 0) {
adapter.addItem(item)
} else {

@ -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};
}

Loading…
Cancel
Save