pull/5/head v2.1.3
fengyuecanzhu 4 years ago
parent 55061acb55
commit 35d7b1287a
  1. 13
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java
  2. 10
      app/src/main/java/xyz/fycz/myreader/webapi/ThirdSourceApi.java
  3. 70
      app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java
  4. 2
      app/version_code.properties

@ -186,6 +186,8 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
private boolean isPrivate;//是否私密书籍 private boolean isPrivate;//是否私密书籍
private boolean isFirstLoad = true;
// 接收电池信息和时间更新的广播 // 接收电池信息和时间更新的广播
private BroadcastReceiver mReceiver = new BroadcastReceiver() { private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@ -391,7 +393,6 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
public void onChapterChange(int pos) { public void onChapterChange(int pos) {
chapterPos = pos; chapterPos = pos;
mBook.setHistoryChapterId(mChapters.get(pos).getTitle()); mBook.setHistoryChapterId(mChapters.get(pos).getTitle());
recordReadTime();
} }
@Override @Override
@ -420,8 +421,13 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
@Override @Override
public void onPageChange(int pos, boolean resetRead) { public void onPageChange(int pos, boolean resetRead) {
pagePos = pos; if (isFirstLoad) {
saveLastChapterReadPosition(); pagePos = mBook.getLastReadPosition();
isFirstLoad = false;
} else {
pagePos = pos;
saveLastChapterReadPosition();
}
screenOffTimerStart(); screenOffTimerStart();
initMenu(); initMenu();
recordReadTime(); recordReadTime();
@ -443,6 +449,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
} }
} }
} }
} }
); );

@ -82,7 +82,15 @@ public class ThirdSourceApi {
headers.putAll(getCookies(rc.getNameSpace())); headers.putAll(getCookies(rc.getNameSpace()));
BookChapterList bookChapterList = new BookChapterList(source.getSourceUrl(), source, true); BookChapterList bookChapterList = new BookChapterList(source.getSourceUrl(), source, true);
if (!TextUtils.isEmpty(book.getCathe("ChapterListHtml"))) { if (!TextUtils.isEmpty(book.getCathe("ChapterListHtml"))) {
return bookChapterList.analyzeChapterList(book.getCathe("ChapterListHtml"), book, headers); return bookChapterList.analyzeChapterList(book.getCathe("ChapterListHtml"), book, headers)
.flatMap(chapters -> Observable.create(emitter -> {
for (int i = 0; i < chapters.size(); i++) {
Chapter chapter = chapters.get(i);
chapter.setNumber(i);
}
emitter.onNext(chapters);
emitter.onComplete();
}));
} }
try { try {
AnalyzeUrl analyzeUrl = new AnalyzeUrl(book.getChapterUrl(), headers, book.getInfoUrl()); AnalyzeUrl analyzeUrl = new AnalyzeUrl(book.getChapterUrl(), headers, book.getInfoUrl());

@ -917,48 +917,44 @@ public abstract class PageLoader {
: getReadProgress(getChapterPos(), mChapterList.size(), getPagePos(), getAllPagePos()); : getReadProgress(getChapterPos(), mChapterList.size(), getPagePos(), getAllPagePos());
/****绘制背景****/ /****绘制背景****/
if (!mSettingManager.isShowStatusBar()) { if (!mSettingManager.isShowStatusBar()) {
if (!mChapterList.isEmpty()) { //需要注意的是:绘制text的y的起始点是text的基准线的位置,而不是从text的头部的位置
float tipTop = tipMarginHeight - mTipPaint.getFontMetrics().top;
if (!mChapterList.isEmpty() && mStatus == STATUS_FINISH) {
/*****初始化标题的参数********/ /*****初始化标题的参数********/
//需要注意的是:绘制text的y的起始点是text的基准线的位置,而不是从text的头部的位置 String title = getPagePos() == 0 ? mCollBook.getName() : mCurPage.title;
float tipTop = tipMarginHeight - mTipPaint.getFontMetrics().top; title = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), title, true);
//根据状态不一样,数据不一样 title = TextUtils.ellipsize(title, mTipPaint, mDisplayWidth - mMarginLeft - mMarginRight - mTipPaint.measureText(progress), TextUtils.TruncateAt.END).toString();
if (mStatus != STATUS_FINISH) { canvas.drawText(title, mMarginLeft, tipTop, mTipPaint);
if (isChapterListPrepare) { /******绘制页码********/
String title = mChapterList.get(mCurChapterPos).getTitle(); // 底部的字显示的位置Y
title = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), title, true); float y = mDisplayHeight - mTipPaint.getFontMetrics().bottom - tipMarginHeight;
canvas.drawText(title, mMarginLeft, tipTop, mTipPaint); String percent = (mCurPage.position + 1) + "/" + mCurChapter.getPageSize();
} canvas.drawText(percent, mMarginLeft, y, mTipPaint);
} else { } else {
String title = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), mCurPage.title, true); String title = mCollBook.getName();
title = TextUtils.ellipsize(title, mTipPaint, mDisplayWidth - mMarginLeft - mMarginRight - mTipPaint.measureText(progress), TextUtils.TruncateAt.END).toString(); title = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), title, true);
canvas.drawText(title, mMarginLeft, tipTop, mTipPaint); canvas.drawText(title, mMarginLeft, tipTop, mTipPaint);
/******绘制页码********/
// 底部的字显示的位置Y
float y = mDisplayHeight - mTipPaint.getFontMetrics().bottom - tipMarginHeight;
String percent = (mCurPage.position + 1) + "/" + mCurChapter.getPageSize();
canvas.drawText(percent, mMarginLeft, y, mTipPaint);
}
/*******绘制进度*******/
float progressTipLeft = mDisplayWidth - mMarginRight - mTipPaint.measureText(progress);
canvas.drawText(progress, progressTipLeft, tipTop, mTipPaint);
} }
/*******绘制进度*******/
float progressTipLeft = mDisplayWidth - mMarginRight - mTipPaint.measureText(progress);
canvas.drawText(progress, progressTipLeft, tipTop, mTipPaint);
} else { } else {
float tipBottom = mDisplayHeight - mTipPaint.getFontMetrics().bottom - tipMarginHeight; float tipBottom = mDisplayHeight - mTipPaint.getFontMetrics().bottom - tipMarginHeight;
//根据状态不一样,数据不一样 if (!mChapterList.isEmpty() && mStatus == STATUS_FINISH) {
if (mStatus != STATUS_FINISH) {
if (isChapterListPrepare) {
canvas.drawText(mChapterList.get(mCurChapterPos).getTitle()
, mMarginLeft, tipBottom, mTipPaint);
}
} else {
/******绘制页码********/ /******绘制页码********/
String percent = (mCurPage.position + 1) + "/" + mCurChapter.getPageSize(); String percent = (mCurPage.position + 1) + "/" + mCurChapter.getPageSize();
//页码的x坐标 //页码的x坐标
float tipLeft = mDisplayWidth - 2 * mMarginRight - mTipPaint.measureText(percent + progress); float tipLeft = mDisplayWidth - 2 * mMarginRight - mTipPaint.measureText(percent + progress);
canvas.drawText(percent, tipLeft, tipBottom, mTipPaint); canvas.drawText(percent, tipLeft, tipBottom, mTipPaint);
String title = TextUtils.ellipsize(mCurPage.title, mTipPaint, tipLeft - 2 * mMarginRight, TextUtils.TruncateAt.END).toString(); String title = getPagePos() == 0 ? mCollBook.getName() : mCurPage.title;
title = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), title, true);
title = TextUtils.ellipsize(title, mTipPaint, tipLeft - 2 * mMarginRight, TextUtils.TruncateAt.END).toString();
canvas.drawText(title, mMarginLeft, tipBottom, mTipPaint);
} else {
String title = mCollBook.getName();
title = contentHelper.replaceContent(mCollBook.getName() + "-" + mCollBook.getAuthor(), mCollBook.getSource(), title, true);
canvas.drawText(title, mMarginLeft, tipBottom, mTipPaint); canvas.drawText(title, mMarginLeft, tipBottom, mTipPaint);
} }
/*******绘制进度*******/ /*******绘制进度*******/
@ -1031,7 +1027,10 @@ public abstract class PageLoader {
String tip = ""; String tip = "";
switch (mStatus) { switch (mStatus) {
case STATUS_LOADING: case STATUS_LOADING:
tip = "正在加载章节内容..."; if (isChapterListPrepare) {
tip = mChapterList.get(mCurChapterPos).getTitle();
}
tip += "\n正在加载章节内容...";
break; break;
case STATUS_LOADING_CHAPTER: case STATUS_LOADING_CHAPTER:
tip = "正在加载目录列表..."; tip = "正在加载目录列表...";
@ -1056,7 +1055,8 @@ public abstract class PageLoader {
break; break;
} }
if (mStatus == STATUS_ERROR || mStatus == STATUS_CATEGORY_ERROR if (mStatus == STATUS_ERROR || mStatus == STATUS_CATEGORY_ERROR
|| mStatus == STATUS_PARSE_ERROR) { || mStatus == STATUS_PARSE_ERROR
|| (isChapterListPrepare && mStatus == STATUS_LOADING)) {
drawErrorMsg(canvas, tip, 0); drawErrorMsg(canvas, tip, 0);
} else { } else {
//将提示语句放到正中间 //将提示语句放到正中间
@ -1517,8 +1517,8 @@ public abstract class PageLoader {
private void chapterChangeCallback() { private void chapterChangeCallback() {
if (mPageChangeListener != null) { if (mPageChangeListener != null) {
readAloudParagraph = -1; readAloudParagraph = -1;
mPageChangeListener.onPageChange(0, resetReadAloud);
mPageChangeListener.onChapterChange(mCurChapterPos); mPageChangeListener.onChapterChange(mCurChapterPos);
mPageChangeListener.onPageChange(mCollBook.getLastReadPosition(), resetReadAloud);
resetReadAloud = true; resetReadAloud = true;
mPageChangeListener.onPageCountChange(mCurChapter != null ? mCurChapter.getPageSize() : 0); mPageChangeListener.onPageCountChange(mCurChapter != null ? mCurChapter.getPageSize() : 0);
} }

@ -1,2 +1,2 @@
#Mon Jun 14 12:41:11 CST 2021 #Tue Jun 15 19:45:01 CST 2021
VERSION_CODE=212 VERSION_CODE=212

Loading…
Cancel
Save