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

@ -82,7 +82,15 @@ public class ThirdSourceApi {
headers.putAll(getCookies(rc.getNameSpace()));
BookChapterList bookChapterList = new BookChapterList(source.getSourceUrl(), source, true);
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 {
AnalyzeUrl analyzeUrl = new AnalyzeUrl(book.getChapterUrl(), headers, book.getInfoUrl());

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

Loading…
Cancel
Save