Incorrect mark as read with seamless mode. #142
This commit is contained in:
parent
4c073e713d
commit
5c329d2314
@ -253,7 +253,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveChapter(Chapter chapter) {
|
public void setActiveChapter(Chapter chapter) {
|
||||||
onChapterLeft(true); // force markAsRead since at this point the current page is already for the next chapter
|
onChapterLeft();
|
||||||
this.activeChapter = chapter;
|
this.activeChapter = chapter;
|
||||||
nextChapter = null;
|
nextChapter = null;
|
||||||
previousChapter = null;
|
previousChapter = null;
|
||||||
@ -292,25 +292,29 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
retryPageSubject.onNext(page);
|
retryPageSubject.onNext(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onChapterLeft() {
|
|
||||||
onChapterLeft(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called before loading another chapter or leaving the reader. It allows to do operations
|
// Called before loading another chapter or leaving the reader. It allows to do operations
|
||||||
// over the chapter read like saving progress
|
// over the chapter read like saving progress
|
||||||
public void onChapterLeft(boolean forceMarkAsRead) {
|
public void onChapterLeft() {
|
||||||
if (activeChapter.getPages() == null)
|
List<Page> pages = activeChapter.getPages();
|
||||||
|
if (pages == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Page activePage = getCurrentPage();
|
// Get the last page read
|
||||||
|
int activePageNumber = activeChapter.last_page_read;
|
||||||
|
|
||||||
|
// Just in case, avoid out of index exceptions
|
||||||
|
if (activePageNumber >= pages.size()) {
|
||||||
|
activePageNumber = pages.size() - 1;
|
||||||
|
}
|
||||||
|
Page activePage = pages.get(activePageNumber);
|
||||||
|
|
||||||
// Cache current page list progress for online chapters to allow a faster reopen
|
// Cache current page list progress for online chapters to allow a faster reopen
|
||||||
if (!activeChapter.isDownloaded())
|
if (!activeChapter.isDownloaded()) {
|
||||||
source.savePageList(activeChapter.url, activePage.getChapter().getPages());
|
source.savePageList(activeChapter.url, pages);
|
||||||
|
}
|
||||||
|
|
||||||
// Save current progress of the chapter. Mark as read if the chapter is finished
|
// Save current progress of the chapter. Mark as read if the chapter is finished
|
||||||
activeChapter.last_page_read = activePage.getPageNumber();
|
if (activePage.isLastPage()) {
|
||||||
if (forceMarkAsRead || activePage.isLastPage()) {
|
|
||||||
activeChapter.read = true;
|
activeChapter.read = true;
|
||||||
}
|
}
|
||||||
db.insertChapter(activeChapter).asRxObservable().subscribe();
|
db.insertChapter(activeChapter).asRxObservable().subscribe();
|
||||||
|
@ -36,16 +36,19 @@ public abstract class BaseReader extends BaseFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onPageChanged(int position) {
|
public void onPageChanged(int position) {
|
||||||
|
Page oldPage = pages.get(currentPage);
|
||||||
|
Page newPage = pages.get(position);
|
||||||
|
newPage.getChapter().last_page_read = newPage.getPageNumber();
|
||||||
|
|
||||||
if (getReaderActivity().getPresenter().isSeamlessMode()) {
|
if (getReaderActivity().getPresenter().isSeamlessMode()) {
|
||||||
Chapter oldChapter = pages.get(currentPage).getChapter();
|
Chapter oldChapter = oldPage.getChapter();
|
||||||
Chapter newChapter = pages.get(position).getChapter();
|
Chapter newChapter = newPage.getChapter();
|
||||||
if (!hasRequestedNextChapter && position > pages.size() - 5) {
|
if (!hasRequestedNextChapter && position > pages.size() - 5) {
|
||||||
hasRequestedNextChapter = true;
|
hasRequestedNextChapter = true;
|
||||||
getReaderActivity().getPresenter().appendNextChapter();
|
getReaderActivity().getPresenter().appendNextChapter();
|
||||||
}
|
}
|
||||||
if (!oldChapter.id.equals(newChapter.id)) {
|
if (!oldChapter.id.equals(newChapter.id)) {
|
||||||
Page page = pages.get(position);
|
onChapterChanged(newPage.getChapter(), newPage);
|
||||||
onChapterChanged(page.getChapter(), page);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentPage = position;
|
currentPage = position;
|
||||||
|
Loading…
Reference in New Issue
Block a user