diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy index 814173f..0bdce35 100644 --- a/app/src/main/assets/updatelog.fy +++ b/app/src/main/assets/updatelog.fy @@ -2,6 +2,7 @@ 风月读书v2.1.3 更新内容: 1、优化阅读文字选择 +2、修复已知bug 2021.06.13 风月读书v2.1.2 diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java index e46e2a5..7f047cd 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java @@ -401,10 +401,12 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe mBook.setChapterTotalNum(chapters.size()); mBook.setNewestChapterTitle(chapters.get(chapters.size() - 1).getTitle()); if (hasChangeSource) { - mBookService.matchHistoryChapterPos(mBook, mChapters); - skipToChapterAndPage(mBook.getHisttoryChapterNum(), mBook.getLastReadPosition()); + boolean flag = mBookService.matchHistoryChapterPos(mBook, mChapters); + Log.d(TAG, "matchHistoryChapterPos=" + flag); hasChangeSource = false; - mChapterService.addChapters(chapters); + if (flag) { + mPageLoader.skipToChapter(mBook.getHisttoryChapterNum()); + } } mBookService.updateEntity(mBook); loadFinish = true; @@ -481,9 +483,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe if (!StringHelper.isEmpty(bean.getDesc())) { bookTem.setDesc(bean.getDesc()); } - if (isCollected) { - mBookService.updateBook(mBook, bookTem); - } + mBookService.updateBook(mBook, bookTem); mBook = bookTem; aBooks = mSourceDialog.getaBooks(); aBooks.set(pos, mBook); @@ -1748,15 +1748,15 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe int dx = (int) event.getRawX() - lastX; int dy = (int) event.getRawY() - lastY; - int l = v.getLeft() + dx; + /*int l = v.getLeft() + dx; int b = v.getBottom() + dy; int r = v.getRight() + dx; - int t = v.getTop() + dy; + int t = v.getTop() + dy;*/ - v.layout(l, t, r, b); + //v.layout(l, t, r, b); lastX = (int) event.getRawX(); lastY = (int) event.getRawY(); - v.postInvalidate(); + //v.postInvalidate(); //移动过程中要画线 binding.readPvContent.setSelectMode(PageView.SelectMode.SelectMoveForward); @@ -1780,7 +1780,6 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe right.setY(binding.readPvContent.getLastSelectTxtChar().getBottomRightPosition().y); } - float leftX = left.getX(); float leftY = left.getY(); float rightX = right.getX(); @@ -1831,18 +1830,20 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe * 显示长按菜单 */ public void showAction() { + ImageView left = binding.getRoot().findViewWithTag("left"); + ImageView right = binding.getRoot().findViewWithTag("right"); float x, y; - if (binding.cursorLeft.getX() - binding.cursorRight.getX() > 0) { - x = binding.cursorRight.getX() + (binding.cursorLeft.getX() - binding.cursorRight.getX()) / 2 + ScreenUtils.dpToPx(12); + if (left.getX() - right.getX() > 0) { + x = right.getX() + (left.getX() - right.getX()) / 2 + ScreenUtils.dpToPx(12); } else { - x = binding.cursorLeft.getX() + (binding.cursorRight.getX() - binding.cursorLeft.getX()) / 2 + ScreenUtils.dpToPx(12); + x = left.getX() + (right.getX() - left.getX()) / 2 + ScreenUtils.dpToPx(12); } - if ((binding.cursorLeft.getY() - ScreenUtils.spToPx(mSetting.getReadWordSize()) - ScreenUtils.dpToPx(60)) < 0) { + if ((left.getY() - ScreenUtils.spToPx(mSetting.getReadWordSize()) - ScreenUtils.dpToPx(60)) < 0) { longPressMenu.setShowBottom(true); - y = binding.cursorLeft.getY() + binding.cursorLeft.getHeight() * 3 / 5; + y = left.getY() + left.getHeight() * 3 / 5; } else { longPressMenu.setShowBottom(false); - y = binding.cursorLeft.getY() - ScreenUtils.spToPx(mSetting.getReadWordSize()) - ScreenUtils.dpToPx(5); + y = left.getY() - ScreenUtils.spToPx(mSetting.getReadWordSize()) - ScreenUtils.dpToPx(5); } longPressMenu.showPopupListWindow(binding.rlContent, 0, x, y, longPressMenuItems, longPressMenuListener); diff --git a/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java b/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java index 377cdf9..4ec111c 100644 --- a/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java +++ b/app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java @@ -2079,7 +2079,9 @@ public abstract class PageLoader { if (txtLines == null) return null; for (TxtLine l : txtLines) { List txtChars = l.getCharsData(); - if (txtChars != null) { + if (txtChars != null && txtChars.size() > 0) { + TxtChar first = txtChars.get(0); + TxtChar last = txtChars.get(txtChars.size() - 1); for (int i = 0; i < txtChars.size(); i++) { TxtChar c = txtChars.get(i); Point leftPoint = c.getBottomLeftPosition(); @@ -2091,10 +2093,12 @@ public abstract class PageLoader { boolean flag = down_X2 >= leftPoint.x && down_X2 <= rightPoint.x; switch (detect) { case Left: - flag = flag || (i == 0 && down_X2 < leftPoint.x); + flag = flag || (i == 0 && (down_X2 < leftPoint.x || + down_X2 > last.getBottomRightPosition().x)); break; case Right: - flag = flag || (i == txtChars.size() - 1 && down_X2 > rightPoint.x); + flag = flag || (i == txtChars.size() - 1 && (down_X2 > rightPoint.x || + down_X2 < first.getBottomLeftPosition().x)); break; } if (flag) return c; @@ -2106,41 +2110,22 @@ public abstract class PageLoader { return null; } - TxtChar detectLastTxtChar(TxtChar txtChar) { - TxtChar last = txtChar; + TxtChar detectTxtCharByIndex(int index) { TxtPage txtPage = mCurPage; - if (txtPage == null) return txtChar; + if (txtPage == null) return null; List txtLines = txtPage.txtLists; - if (txtLines == null) return txtChar; + if (txtLines == null) return null; for (TxtLine l : txtLines) { List txtChars = l.getCharsData(); if (txtChars != null) { for (TxtChar c : txtChars) { - if (c != null && c.getIndex() == txtChar.getIndex()) return last; - last = c; + if (c != null && c.getIndex() == index) return c; } } } - return txtChar; + return null; } - TxtChar detectNextTxtChar(TxtChar txtChar) { - TxtPage txtPage = mCurPage; - boolean isNext = false; - if (txtPage == null) return txtChar; - List txtLines = txtPage.txtLists; - if (txtLines == null) return txtChar; - for (TxtLine l : txtLines) { - List txtChars = l.getCharsData(); - if (txtChars != null) { - for (TxtChar c : txtChars) { - if (isNext) return c; - if (c != null && c.getIndex() == txtChar.getIndex()) isNext = true; - } - } - } - return txtChar; - } public boolean isPrev() { return isPrev; diff --git a/app/src/main/java/xyz/fycz/myreader/widget/page/PageView.java b/app/src/main/java/xyz/fycz/myreader/widget/page/PageView.java index 48a0bbb..8f68c50 100644 --- a/app/src/main/java/xyz/fycz/myreader/widget/page/PageView.java +++ b/app/src/main/java/xyz/fycz/myreader/widget/page/PageView.java @@ -632,11 +632,13 @@ public class PageView extends View { } public TxtChar getLastTxtChar(TxtChar txtChar){ - return mPageLoader.detectLastTxtChar(txtChar); + TxtChar last = mPageLoader.detectTxtCharByIndex(txtChar.getIndex() - 1); + return last == null ? txtChar : last; } public TxtChar getNextTxtChar(TxtChar txtChar){ - return mPageLoader.detectNextTxtChar(txtChar); + TxtChar next = mPageLoader.detectTxtCharByIndex(txtChar.getIndex() + 1); + return next == null ? txtChar : next; } private void drawOaleSeletLinesBg(Canvas canvas) {// 绘制选中背景