From 68f1e5f4bb056746c7fcb08722eade8747525c16 Mon Sep 17 00:00:00 2001 From: inorichi Date: Wed, 2 Dec 2015 10:32:16 +0100 Subject: [PATCH] Minor changes --- .../mangafeed/data/database/models/Chapter.java | 4 ++-- .../kanade/mangafeed/data/database/models/Manga.java | 2 +- .../mangafeed/data/download/DownloadManager.java | 2 +- .../mangafeed/data/download/model/Download.java | 2 +- .../kanade/mangafeed/event/DownloadStatusEvent.java | 12 +++++++----- .../mangafeed/ui/manga/chapter/ChaptersFragment.java | 8 +++++++- .../ui/manga/chapter/ChaptersPresenter.java | 6 +++++- 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/models/Chapter.java b/app/src/main/java/eu/kanade/mangafeed/data/database/models/Chapter.java index 146e918709..2bf5013d06 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/models/Chapter.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/models/Chapter.java @@ -10,10 +10,10 @@ import eu.kanade.mangafeed.util.UrlUtil; public class Chapter { @StorIOSQLiteColumn(name = ChapterTable.COLUMN_ID, key = true) - public Long id; + public long id; @StorIOSQLiteColumn(name = ChapterTable.COLUMN_MANGA_ID) - public Long manga_id; + public long manga_id; @StorIOSQLiteColumn(name = ChapterTable.COLUMN_URL) public String url; diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/models/Manga.java b/app/src/main/java/eu/kanade/mangafeed/data/database/models/Manga.java index 780cbc0a3e..f17f233c87 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/models/Manga.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/models/Manga.java @@ -10,7 +10,7 @@ import eu.kanade.mangafeed.util.UrlUtil; public class Manga { @StorIOSQLiteColumn(name = MangaTable.COLUMN_ID, key = true) - public Long id; + public long id; @StorIOSQLiteColumn(name = MangaTable.COLUMN_SOURCE) public int source; diff --git a/app/src/main/java/eu/kanade/mangafeed/data/download/DownloadManager.java b/app/src/main/java/eu/kanade/mangafeed/data/download/DownloadManager.java index e8c7092536..3133fed7ba 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/download/DownloadManager.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/download/DownloadManager.java @@ -133,7 +133,7 @@ public class DownloadManager { private boolean prepareDownload(Download download) { // If the chapter is already queued, don't add it again for (Download queuedDownload : queue.get()) { - if (download.chapter.id.equals(queuedDownload.chapter.id)) + if (download.chapter.id == queuedDownload.chapter.id) return true; } diff --git a/app/src/main/java/eu/kanade/mangafeed/data/download/model/Download.java b/app/src/main/java/eu/kanade/mangafeed/data/download/model/Download.java index 00648b98db..7d8c02cf61 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/download/model/Download.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/download/model/Download.java @@ -54,6 +54,6 @@ public class Download { private void notifyStatus() { if (statusSubject != null) statusSubject.onNext(this); - EventBus.getDefault().post(new DownloadStatusEvent(chapter.id, status)); + EventBus.getDefault().post(new DownloadStatusEvent(chapter, status)); } } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/mangafeed/event/DownloadStatusEvent.java b/app/src/main/java/eu/kanade/mangafeed/event/DownloadStatusEvent.java index 7ab00a8142..c3f288b80c 100644 --- a/app/src/main/java/eu/kanade/mangafeed/event/DownloadStatusEvent.java +++ b/app/src/main/java/eu/kanade/mangafeed/event/DownloadStatusEvent.java @@ -1,17 +1,19 @@ package eu.kanade.mangafeed.event; +import eu.kanade.mangafeed.data.database.models.Chapter; + public class DownloadStatusEvent { - private long chapterId; + private Chapter chapter; private int status; - public DownloadStatusEvent(long chapterId, int status) { - this.chapterId = chapterId; + public DownloadStatusEvent(Chapter chapter, int status) { + this.chapter = chapter; this.status = status; } - public long getChapterId() { - return chapterId; + public Chapter getChapter() { + return chapter; } public int getStatus() { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java index 9b282f47f7..794afd8b31 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java @@ -23,6 +23,7 @@ import butterknife.Bind; import butterknife.ButterKnife; import eu.kanade.mangafeed.R; import eu.kanade.mangafeed.data.database.models.Chapter; +import eu.kanade.mangafeed.data.database.models.Manga; import eu.kanade.mangafeed.data.download.DownloadService; import eu.kanade.mangafeed.event.DownloadStatusEvent; import eu.kanade.mangafeed.ui.base.activity.BaseActivity; @@ -150,10 +151,15 @@ public class ChaptersFragment extends BaseRxFragment implemen @EventBusHook public void onEventMainThread(DownloadStatusEvent event) { + Manga manga = getPresenter().getManga(); + // If the download status is from another manga, don't bother + if (manga != null && event.getChapter().manga_id != manga.id) + return; + Chapter chapter; for (int i = 0; i < adapter.getItemCount(); i++) { chapter = adapter.getItem(i); - if (event.getChapterId() == chapter.id) { + if (event.getChapter().id == chapter.id) { chapter.status = event.getStatus(); adapter.notifyItemChanged(i); break; diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java index 0722d5ea03..459cfe7135 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java @@ -171,7 +171,7 @@ public class ChaptersPresenter extends BasePresenter { public void checkIsChapterDownloaded(Chapter chapter) { for (Download download : downloadManager.getQueue().get()) { - if (chapter.id.equals(download.chapter.id)) { + if (chapter.id == download.chapter.id) { chapter.status = download.getStatus(); return; } @@ -207,4 +207,8 @@ public class ChaptersPresenter extends BasePresenter { public boolean getReadFilter() { return onlyUnread; } + + public Manga getManga() { + return manga; + } }