mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-25 14:45:59 +03:00
Minor changes
This commit is contained in:
parent
96f6e28c68
commit
ab48686262
4 changed files with 18 additions and 16 deletions
|
@ -340,6 +340,7 @@ public class DownloadManager {
|
||||||
public void deleteChapter(Source source, Manga manga, Chapter chapter) {
|
public void deleteChapter(Source source, Manga manga, Chapter chapter) {
|
||||||
File path = getAbsoluteChapterDirectory(source, manga, chapter);
|
File path = getAbsoluteChapterDirectory(source, manga, chapter);
|
||||||
DiskUtils.deleteFiles(path);
|
DiskUtils.deleteFiles(path);
|
||||||
|
queue.remove(chapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadQueue getQueue() {
|
public DownloadQueue getQueue() {
|
||||||
|
|
|
@ -35,7 +35,6 @@ public class Download {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.manga = manga;
|
this.manga = manga;
|
||||||
this.chapter = chapter;
|
this.chapter = chapter;
|
||||||
this.status = QUEUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatus() {
|
public int getStatus() {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package eu.kanade.mangafeed.data.download.model;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.data.download.model.Download;
|
import eu.kanade.mangafeed.data.database.models.Chapter;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.subjects.PublishSubject;
|
import rx.subjects.PublishSubject;
|
||||||
|
|
||||||
|
@ -19,14 +19,25 @@ public class DownloadQueue {
|
||||||
|
|
||||||
public void add(Download download) {
|
public void add(Download download) {
|
||||||
download.setStatusSubject(statusSubject);
|
download.setStatusSubject(statusSubject);
|
||||||
|
download.setStatus(Download.QUEUE);
|
||||||
queue.add(download);
|
queue.add(download);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(Download download) {
|
public void remove(Download download) {
|
||||||
queue.remove(download);
|
queue.remove(download);
|
||||||
|
download.setStatus(Download.NOT_DOWNLOADED);
|
||||||
download.setStatusSubject(null);
|
download.setStatusSubject(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void remove(Chapter chapter) {
|
||||||
|
for (Download download : queue) {
|
||||||
|
if (download.chapter.id == chapter.id) {
|
||||||
|
remove(download);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<Download> get() {
|
public List<Download> get() {
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
||||||
import eu.kanade.mangafeed.util.EventBusHook;
|
import eu.kanade.mangafeed.util.EventBusHook;
|
||||||
import eu.kanade.mangafeed.util.PostResult;
|
import eu.kanade.mangafeed.util.PostResult;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.Subscription;
|
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
import rx.schedulers.Schedulers;
|
import rx.schedulers.Schedulers;
|
||||||
|
|
||||||
|
@ -42,10 +41,6 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||||
private static final int DB_CHAPTERS = 1;
|
private static final int DB_CHAPTERS = 1;
|
||||||
private static final int FETCH_CHAPTERS = 2;
|
private static final int FETCH_CHAPTERS = 2;
|
||||||
|
|
||||||
private Subscription markReadSubscription;
|
|
||||||
private Subscription downloadSubscription;
|
|
||||||
private Subscription deleteSubscription;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
|
@ -128,7 +123,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void markChaptersRead(Observable<Chapter> selectedChapters, boolean read) {
|
public void markChaptersRead(Observable<Chapter> selectedChapters, boolean read) {
|
||||||
add(markReadSubscription = selectedChapters
|
add(selectedChapters
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.map(chapter -> {
|
.map(chapter -> {
|
||||||
chapter.read = read;
|
chapter.read = read;
|
||||||
|
@ -138,27 +133,23 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||||
.toList()
|
.toList()
|
||||||
.flatMap(chapters -> db.insertChapters(chapters).createObservable())
|
.flatMap(chapters -> db.insertChapters(chapters).createObservable())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doOnCompleted(() -> remove(markReadSubscription))
|
.subscribe());
|
||||||
.subscribe(result -> {
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadChapters(Observable<Chapter> selectedChapters) {
|
public void downloadChapters(Observable<Chapter> selectedChapters) {
|
||||||
add(downloadSubscription = selectedChapters
|
add(selectedChapters
|
||||||
.toList()
|
.toList()
|
||||||
.subscribe(chapters -> {
|
.subscribe(chapters -> {
|
||||||
EventBus.getDefault().postSticky(new DownloadChaptersEvent(manga, chapters));
|
EventBus.getDefault().postSticky(new DownloadChaptersEvent(manga, chapters));
|
||||||
remove(downloadSubscription);
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteChapters(Observable<Chapter> selectedChapters) {
|
public void deleteChapters(Observable<Chapter> selectedChapters) {
|
||||||
deleteSubscription = selectedChapters
|
add(selectedChapters
|
||||||
.doOnCompleted(() -> remove(deleteSubscription))
|
|
||||||
.subscribe(chapter -> {
|
.subscribe(chapter -> {
|
||||||
downloadManager.deleteChapter(source, manga, chapter);
|
downloadManager.deleteChapter(source, manga, chapter);
|
||||||
chapter.status = Download.NOT_DOWNLOADED;
|
chapter.status = Download.NOT_DOWNLOADED;
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue