mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 06:01:49 +01:00
Minor changes
This commit is contained in:
parent
aa6dfddffa
commit
68f1e5f4bb
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user