mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
Bump dependencies. Minor changes to download manager
This commit is contained in:
parent
936d5e46eb
commit
67c9420606
5 changed files with 18 additions and 24 deletions
|
@ -112,7 +112,7 @@ dependencies {
|
||||||
provided "frankiesardo:icepick-processor:$ICEPICK_VERSION"
|
provided "frankiesardo:icepick-processor:$ICEPICK_VERSION"
|
||||||
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
|
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
|
||||||
compile 'eu.davidea:flexible-adapter:4.2.0@aar'
|
compile 'eu.davidea:flexible-adapter:4.2.0@aar'
|
||||||
compile 'com.nononsenseapps:filepicker:2.5.0'
|
compile 'com.nononsenseapps:filepicker:2.5.1'
|
||||||
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||||
compile 'com.github.pwittchen:reactivenetwork:0.1.5'
|
compile 'com.github.pwittchen:reactivenetwork:0.1.5'
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ dependencies {
|
||||||
apt "com.pushtorefresh.storio:sqlite-annotations-processor:$STORIO_VERSION"
|
apt "com.pushtorefresh.storio:sqlite-annotations-processor:$STORIO_VERSION"
|
||||||
provided 'org.glassfish:javax.annotation:10.0-b28'
|
provided 'org.glassfish:javax.annotation:10.0-b28'
|
||||||
|
|
||||||
compile('com.mikepenz:materialdrawer:4.6.1@aar') {
|
compile('com.mikepenz:materialdrawer:4.6.4@aar') {
|
||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') {
|
compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import java.io.FileOutputStream;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
import eu.kanade.tachiyomi.data.database.models.Chapter;
|
||||||
|
@ -42,10 +43,8 @@ public class DownloadManager {
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
|
|
||||||
private PublishSubject<Download> downloadsQueueSubject;
|
private PublishSubject<Download> downloadsQueueSubject;
|
||||||
private BehaviorSubject<Integer> threadsNumber;
|
|
||||||
private BehaviorSubject<Boolean> runningSubject;
|
private BehaviorSubject<Boolean> runningSubject;
|
||||||
private Subscription downloadsSubscription;
|
private Subscription downloadsSubscription;
|
||||||
private Subscription threadsNumberSubscription;
|
|
||||||
|
|
||||||
private DownloadQueue queue;
|
private DownloadQueue queue;
|
||||||
private volatile boolean isRunning;
|
private volatile boolean isRunning;
|
||||||
|
@ -61,7 +60,6 @@ public class DownloadManager {
|
||||||
queue = new DownloadQueue();
|
queue = new DownloadQueue();
|
||||||
|
|
||||||
downloadsQueueSubject = PublishSubject.create();
|
downloadsQueueSubject = PublishSubject.create();
|
||||||
threadsNumber = BehaviorSubject.create();
|
|
||||||
runningSubject = BehaviorSubject.create();
|
runningSubject = BehaviorSubject.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,14 +67,8 @@ public class DownloadManager {
|
||||||
if (downloadsSubscription != null && !downloadsSubscription.isUnsubscribed())
|
if (downloadsSubscription != null && !downloadsSubscription.isUnsubscribed())
|
||||||
downloadsSubscription.unsubscribe();
|
downloadsSubscription.unsubscribe();
|
||||||
|
|
||||||
if (threadsNumberSubscription != null && !threadsNumberSubscription.isUnsubscribed())
|
|
||||||
threadsNumberSubscription.unsubscribe();
|
|
||||||
|
|
||||||
threadsNumberSubscription = preferences.downloadThreads().asObservable()
|
|
||||||
.subscribe(threadsNumber::onNext);
|
|
||||||
|
|
||||||
downloadsSubscription = downloadsQueueSubject
|
downloadsSubscription = downloadsQueueSubject
|
||||||
.lift(new DynamicConcurrentMergeOperator<>(this::downloadChapter, threadsNumber))
|
.flatMap(this::downloadChapter, preferences.downloadThreads())
|
||||||
.onBackpressureBuffer()
|
.onBackpressureBuffer()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.map(download -> areAllDownloadsFinished())
|
.map(download -> areAllDownloadsFinished())
|
||||||
|
@ -102,11 +94,6 @@ public class DownloadManager {
|
||||||
downloadsSubscription.unsubscribe();
|
downloadsSubscription.unsubscribe();
|
||||||
downloadsSubscription = null;
|
downloadsSubscription = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threadsNumberSubscription != null && !threadsNumberSubscription.isUnsubscribed()) {
|
|
||||||
threadsNumberSubscription.unsubscribe();
|
|
||||||
threadsNumberSubscription = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a download object for every chapter in the event and add them to the downloads queue
|
// Create a download object for every chapter in the event and add them to the downloads queue
|
||||||
|
@ -114,7 +101,14 @@ public class DownloadManager {
|
||||||
final Manga manga = event.getManga();
|
final Manga manga = event.getManga();
|
||||||
final Source source = sourceManager.get(manga.source);
|
final Source source = sourceManager.get(manga.source);
|
||||||
|
|
||||||
|
// Used to avoid downloading chapters with the same name
|
||||||
|
final List<String> addedChapters = new ArrayList<>();
|
||||||
|
|
||||||
for (Chapter chapter : event.getChapters()) {
|
for (Chapter chapter : event.getChapters()) {
|
||||||
|
if (addedChapters.contains(chapter.name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
addedChapters.add(chapter.name);
|
||||||
Download download = new Download(source, manga, chapter);
|
Download download = new Download(source, manga, chapter);
|
||||||
|
|
||||||
if (!prepareDownload(download)) {
|
if (!prepareDownload(download)) {
|
||||||
|
@ -362,7 +356,7 @@ public class DownloadManager {
|
||||||
File.separator +
|
File.separator +
|
||||||
manga.title.replaceAll("[^\\sa-zA-Z0-9.-]", "_") +
|
manga.title.replaceAll("[^\\sa-zA-Z0-9.-]", "_") +
|
||||||
File.separator +
|
File.separator +
|
||||||
chapter.name.replaceAll("[^\\sa-zA-Z0-9.-]", "_") + " (" + chapter.id + ")";
|
chapter.name.replaceAll("[^\\sa-zA-Z0-9.-]", "_");
|
||||||
|
|
||||||
return new File(preferences.getDownloadsDirectory(), chapterRelativePath);
|
return new File(preferences.getDownloadsDirectory(), chapterRelativePath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,8 +85,7 @@ public class PreferencesHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefaultViewer() {
|
public int getDefaultViewer() {
|
||||||
// TODO use IntListPreference
|
return prefs.getInt(getKey(R.string.pref_default_viewer_key), 1);
|
||||||
return Integer.parseInt(prefs.getString(getKey(R.string.pref_default_viewer_key), "1"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Preference<Integer> portraitColumns() {
|
public Preference<Integer> portraitColumns() {
|
||||||
|
@ -156,8 +155,8 @@ public class PreferencesHelper {
|
||||||
prefs.edit().putString(getKey(R.string.pref_download_directory_key), path).apply();
|
prefs.edit().putString(getKey(R.string.pref_download_directory_key), path).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Preference<Integer> downloadThreads() {
|
public int downloadThreads() {
|
||||||
return rxPrefs.getInteger(getKey(R.string.pref_download_slots_key), 1);
|
return prefs.getInt(getKey(R.string.pref_download_slots_key), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean downloadOnlyOverWifi() {
|
public boolean downloadOnlyOverWifi() {
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
android:key="@string/pref_custom_brightness_key"
|
android:key="@string/pref_custom_brightness_key"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
|
||||||
<ListPreference android:title="@string/pref_viewer_type"
|
<eu.kanade.tachiyomi.widget.preference.IntListPreference
|
||||||
|
android:title="@string/pref_viewer_type"
|
||||||
android:key="@string/pref_default_viewer_key"
|
android:key="@string/pref_default_viewer_key"
|
||||||
android:entries="@array/viewers"
|
android:entries="@array/viewers"
|
||||||
android:entryValues="@array/viewers_values"
|
android:entryValues="@array/viewers_values"
|
||||||
|
|
|
@ -10,7 +10,7 @@ buildscript {
|
||||||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
|
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
|
||||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||||
classpath 'me.tatarka:gradle-retrolambda:3.2.4'
|
classpath 'me.tatarka:gradle-retrolambda:3.2.4'
|
||||||
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
|
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue