Browse Source

Minor changes

inorichi 9 years ago
parent
commit
68f1e5f4bb

+ 2 - 2
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;

+ 1 - 1
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;

+ 1 - 1
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;
         }
 

+ 1 - 1
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));
     }
 }

+ 7 - 5
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() {

+ 7 - 1
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<ChaptersPresenter> 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;

+ 5 - 1
app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java

@@ -171,7 +171,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
 
     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<ChaptersFragment> {
     public boolean getReadFilter() {
         return onlyUnread;
     }
+
+    public Manga getManga() {
+        return manga;
+    }
 }