mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 17:11:51 +01:00
Update dependencies. Update last chapter read in MAL only when the reader is left, instead of on every chapter change. Other minor improvements.
This commit is contained in:
parent
273527e7fb
commit
04d9176c3c
@ -79,7 +79,6 @@ dependencies {
|
|||||||
final HAMCREST_VERSION = '1.3'
|
final HAMCREST_VERSION = '1.3'
|
||||||
final MOCKITO_VERSION = '1.10.19'
|
final MOCKITO_VERSION = '1.10.19'
|
||||||
final STORIO_VERSION = '1.6.1'
|
final STORIO_VERSION = '1.6.1'
|
||||||
final NUCLEUS_VERSION = '2.0.3'
|
|
||||||
final ICEPICK_VERSION = '3.1.0'
|
final ICEPICK_VERSION = '3.1.0'
|
||||||
|
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
@ -90,25 +89,24 @@ dependencies {
|
|||||||
compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
|
compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
|
||||||
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
|
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
|
||||||
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
|
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
|
||||||
compile 'com.squareup.okhttp:okhttp-urlconnection:2.6.0'
|
compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.0'
|
||||||
compile 'com.squareup.okhttp:okhttp:2.6.0'
|
compile 'com.squareup.okhttp:okhttp:2.7.0'
|
||||||
compile 'com.squareup.okio:okio:1.6.0'
|
compile 'com.squareup.okio:okio:1.6.0'
|
||||||
compile 'com.google.code.gson:gson:2.4'
|
compile 'com.google.code.gson:gson:2.4'
|
||||||
compile 'com.jakewharton:disklrucache:2.0.2'
|
compile 'com.jakewharton:disklrucache:2.0.2'
|
||||||
compile 'org.jsoup:jsoup:1.8.3'
|
compile 'org.jsoup:jsoup:1.8.3'
|
||||||
compile 'io.reactivex:rxandroid:1.0.1'
|
compile 'io.reactivex:rxandroid:1.1.0'
|
||||||
compile 'io.reactivex:rxjava:1.1.0'
|
compile 'io.reactivex:rxjava:1.1.0'
|
||||||
compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.1'
|
compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.1'
|
||||||
compile "com.pushtorefresh.storio:sqlite:$STORIO_VERSION"
|
compile "com.pushtorefresh.storio:sqlite:$STORIO_VERSION"
|
||||||
compile "com.pushtorefresh.storio:sqlite-annotations:$STORIO_VERSION"
|
compile "com.pushtorefresh.storio:sqlite-annotations:$STORIO_VERSION"
|
||||||
compile "info.android15.nucleus:nucleus:$NUCLEUS_VERSION"
|
compile 'info.android15.nucleus:nucleus:2.0.4'
|
||||||
compile 'de.greenrobot:eventbus:2.4.0'
|
compile 'de.greenrobot:eventbus:2.4.0'
|
||||||
compile 'com.github.bumptech.glide:glide:3.6.1'
|
compile 'com.github.bumptech.glide:glide:3.6.1'
|
||||||
compile 'com.jakewharton:butterknife:7.0.1'
|
compile 'com.jakewharton:butterknife:7.0.1'
|
||||||
compile 'com.jakewharton.timber:timber:4.1.0'
|
compile 'com.jakewharton.timber:timber:4.1.0'
|
||||||
compile 'uk.co.ribot:easyadapter:1.5.0@aar'
|
compile 'uk.co.ribot:easyadapter:1.5.0@aar'
|
||||||
compile 'ch.acra:acra:4.6.2'
|
compile 'ch.acra:acra:4.7.0'
|
||||||
compile 'com.github.castorflex.verticalviewpager:library:19.0.1'
|
|
||||||
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.4.1'
|
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.4.1'
|
||||||
compile "frankiesardo:icepick:$ICEPICK_VERSION"
|
compile "frankiesardo:icepick:$ICEPICK_VERSION"
|
||||||
provided "frankiesardo:icepick-processor:$ICEPICK_VERSION"
|
provided "frankiesardo:icepick-processor:$ICEPICK_VERSION"
|
||||||
@ -121,7 +119,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.4.8@aar') {
|
compile('com.mikepenz:materialdrawer:4.5.9@aar') {
|
||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
compile('com.github.afollestad.material-dialogs:core:0.8.5.2@aar') {
|
compile('com.github.afollestad.material-dialogs:core:0.8.5.2@aar') {
|
||||||
|
@ -17,7 +17,7 @@ import com.pushtorefresh.storio.sqlite.queries.RawQuery;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
||||||
import eu.kanade.mangafeed.data.mangasync.base.BaseMangaSync;
|
import eu.kanade.mangafeed.data.mangasync.base.MangaSyncService;
|
||||||
import eu.kanade.mangafeed.data.database.models.Chapter;
|
import eu.kanade.mangafeed.data.database.models.Chapter;
|
||||||
import eu.kanade.mangafeed.data.database.models.ChapterStorIOSQLiteDeleteResolver;
|
import eu.kanade.mangafeed.data.database.models.ChapterStorIOSQLiteDeleteResolver;
|
||||||
import eu.kanade.mangafeed.data.database.models.ChapterStorIOSQLiteGetResolver;
|
import eu.kanade.mangafeed.data.database.models.ChapterStorIOSQLiteGetResolver;
|
||||||
@ -303,8 +303,7 @@ public class DatabaseHelper {
|
|||||||
|
|
||||||
// Manga sync related queries
|
// Manga sync related queries
|
||||||
|
|
||||||
public PreparedGetListOfObjects<MangaSync> getMangaSync(Manga manga, BaseMangaSync sync) {
|
public PreparedGetListOfObjects<MangaSync> getMangaSync(Manga manga, MangaSyncService sync) {
|
||||||
|
|
||||||
return db.get()
|
return db.get()
|
||||||
.listOfObjects(MangaSync.class)
|
.listOfObjects(MangaSync.class)
|
||||||
.withQuery(Query.builder()
|
.withQuery(Query.builder()
|
||||||
@ -316,6 +315,17 @@ public class DatabaseHelper {
|
|||||||
.prepare();
|
.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PreparedGetListOfObjects<MangaSync> getMangaSync(Manga manga) {
|
||||||
|
return db.get()
|
||||||
|
.listOfObjects(MangaSync.class)
|
||||||
|
.withQuery(Query.builder()
|
||||||
|
.table(MangaSyncTable.TABLE)
|
||||||
|
.where(MangaSyncTable.COLUMN_MANGA_ID + "=?")
|
||||||
|
.whereArgs(manga.id)
|
||||||
|
.build())
|
||||||
|
.prepare();
|
||||||
|
}
|
||||||
|
|
||||||
public PreparedPutObject<MangaSync> insertMangaSync(MangaSync manga) {
|
public PreparedPutObject<MangaSync> insertMangaSync(MangaSync manga) {
|
||||||
return db.put()
|
return db.put()
|
||||||
.object(manga)
|
.object(manga)
|
||||||
|
@ -3,11 +3,13 @@ package eu.kanade.mangafeed.data.database.models;
|
|||||||
import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn;
|
import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn;
|
||||||
import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType;
|
import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.data.mangasync.base.BaseMangaSync;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import eu.kanade.mangafeed.data.mangasync.base.MangaSyncService;
|
||||||
import eu.kanade.mangafeed.data.database.tables.MangaSyncTable;
|
import eu.kanade.mangafeed.data.database.tables.MangaSyncTable;
|
||||||
|
|
||||||
@StorIOSQLiteType(table = MangaSyncTable.TABLE)
|
@StorIOSQLiteType(table = MangaSyncTable.TABLE)
|
||||||
public class MangaSync {
|
public class MangaSync implements Serializable {
|
||||||
|
|
||||||
@StorIOSQLiteColumn(name = MangaSyncTable.COLUMN_ID, key = true)
|
@StorIOSQLiteColumn(name = MangaSyncTable.COLUMN_ID, key = true)
|
||||||
public Long id;
|
public Long id;
|
||||||
@ -33,7 +35,7 @@ public class MangaSync {
|
|||||||
@StorIOSQLiteColumn(name = MangaSyncTable.COLUMN_STATUS)
|
@StorIOSQLiteColumn(name = MangaSyncTable.COLUMN_STATUS)
|
||||||
public int status;
|
public int status;
|
||||||
|
|
||||||
public static MangaSync create(BaseMangaSync service) {
|
public static MangaSync create(MangaSyncService service) {
|
||||||
MangaSync mangasync = new MangaSync();
|
MangaSync mangasync = new MangaSync();
|
||||||
mangasync.sync_id = service.getId();
|
mangasync.sync_id = service.getId();
|
||||||
return mangasync;
|
return mangasync;
|
||||||
|
@ -5,12 +5,12 @@ import android.content.Context;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.data.mangasync.base.BaseMangaSync;
|
import eu.kanade.mangafeed.data.mangasync.base.MangaSyncService;
|
||||||
import eu.kanade.mangafeed.data.mangasync.services.MyAnimeList;
|
import eu.kanade.mangafeed.data.mangasync.services.MyAnimeList;
|
||||||
|
|
||||||
public class MangaSyncManager {
|
public class MangaSyncManager {
|
||||||
|
|
||||||
private List<BaseMangaSync> services;
|
private List<MangaSyncService> services;
|
||||||
private MyAnimeList myAnimeList;
|
private MyAnimeList myAnimeList;
|
||||||
|
|
||||||
public static final int MYANIMELIST = 1;
|
public static final int MYANIMELIST = 1;
|
||||||
@ -25,11 +25,11 @@ public class MangaSyncManager {
|
|||||||
return myAnimeList;
|
return myAnimeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BaseMangaSync> getSyncServices() {
|
public List<MangaSyncService> getSyncServices() {
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseMangaSync getSyncService(int id) {
|
public MangaSyncService getSyncService(int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case MYANIMELIST:
|
case MYANIMELIST:
|
||||||
return myAnimeList;
|
return myAnimeList;
|
||||||
|
@ -5,7 +5,7 @@ import com.squareup.okhttp.Response;
|
|||||||
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
|
|
||||||
public abstract class BaseMangaSync {
|
public abstract class MangaSyncService {
|
||||||
|
|
||||||
// Name of the manga sync service to display
|
// Name of the manga sync service to display
|
||||||
public abstract String getName();
|
public abstract String getName();
|
@ -22,12 +22,12 @@ import javax.inject.Inject;
|
|||||||
import eu.kanade.mangafeed.App;
|
import eu.kanade.mangafeed.App;
|
||||||
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
||||||
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
||||||
import eu.kanade.mangafeed.data.mangasync.base.BaseMangaSync;
|
import eu.kanade.mangafeed.data.mangasync.base.MangaSyncService;
|
||||||
import eu.kanade.mangafeed.data.network.NetworkHelper;
|
import eu.kanade.mangafeed.data.network.NetworkHelper;
|
||||||
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
|
|
||||||
public class MyAnimeList extends BaseMangaSync {
|
public class MyAnimeList extends MangaSyncService {
|
||||||
|
|
||||||
@Inject PreferencesHelper preferences;
|
@Inject PreferencesHelper preferences;
|
||||||
@Inject NetworkHelper networkService;
|
@Inject NetworkHelper networkService;
|
||||||
|
@ -11,7 +11,7 @@ import com.f2prateek.rx.preferences.RxSharedPreferences;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.R;
|
import eu.kanade.mangafeed.R;
|
||||||
import eu.kanade.mangafeed.data.mangasync.base.BaseMangaSync;
|
import eu.kanade.mangafeed.data.mangasync.base.MangaSyncService;
|
||||||
import eu.kanade.mangafeed.data.source.base.Source;
|
import eu.kanade.mangafeed.data.source.base.Source;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
|
|
||||||
@ -106,15 +106,15 @@ public class PreferencesHelper {
|
|||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMangaSyncUsername(BaseMangaSync sync) {
|
public String getMangaSyncUsername(MangaSyncService sync) {
|
||||||
return prefs.getString(MANGASYNC_ACCOUNT_USERNAME + sync.getId(), "");
|
return prefs.getString(MANGASYNC_ACCOUNT_USERNAME + sync.getId(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMangaSyncPassword(BaseMangaSync sync) {
|
public String getMangaSyncPassword(MangaSyncService sync) {
|
||||||
return prefs.getString(MANGASYNC_ACCOUNT_PASSWORD + sync.getId(), "");
|
return prefs.getString(MANGASYNC_ACCOUNT_PASSWORD + sync.getId(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMangaSyncCredentials(BaseMangaSync sync, String username, String password) {
|
public void setMangaSyncCredentials(MangaSyncService sync, String username, String password) {
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.putString(MANGASYNC_ACCOUNT_USERNAME + sync.getId(), username)
|
.putString(MANGASYNC_ACCOUNT_USERNAME + sync.getId(), username)
|
||||||
.putString(MANGASYNC_ACCOUNT_PASSWORD + sync.getId(), password)
|
.putString(MANGASYNC_ACCOUNT_PASSWORD + sync.getId(), password)
|
||||||
|
@ -7,14 +7,12 @@ import android.os.IBinder;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import eu.kanade.mangafeed.App;
|
import eu.kanade.mangafeed.App;
|
||||||
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
||||||
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
||||||
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
||||||
import eu.kanade.mangafeed.data.mangasync.base.BaseMangaSync;
|
import eu.kanade.mangafeed.data.mangasync.base.MangaSyncService;
|
||||||
import eu.kanade.mangafeed.event.UpdateMangaSyncEvent;
|
import rx.Observable;
|
||||||
import eu.kanade.mangafeed.util.EventBusHook;
|
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
import rx.schedulers.Schedulers;
|
import rx.schedulers.Schedulers;
|
||||||
import rx.subscriptions.CompositeSubscription;
|
import rx.subscriptions.CompositeSubscription;
|
||||||
@ -26,8 +24,12 @@ public class UpdateMangaSyncService extends Service {
|
|||||||
|
|
||||||
private CompositeSubscription subscriptions;
|
private CompositeSubscription subscriptions;
|
||||||
|
|
||||||
public static void start(Context context) {
|
private static final String EXTRA_MANGASYNC = "extra_mangasync";
|
||||||
context.startService(new Intent(context, UpdateMangaSyncService.class));
|
|
||||||
|
public static void start(Context context, MangaSync mangaSync) {
|
||||||
|
Intent intent = new Intent(context, UpdateMangaSyncService.class);
|
||||||
|
intent.putExtra(EXTRA_MANGASYNC, mangaSync);
|
||||||
|
context.startService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -35,17 +37,17 @@ public class UpdateMangaSyncService extends Service {
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
App.get(this).getComponent().inject(this);
|
App.get(this).getComponent().inject(this);
|
||||||
subscriptions = new CompositeSubscription();
|
subscriptions = new CompositeSubscription();
|
||||||
EventBus.getDefault().registerSticky(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
MangaSync mangaSync = (MangaSync) intent.getSerializableExtra(EXTRA_MANGASYNC);
|
||||||
|
updateLastChapterRead(mangaSync, startId);
|
||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
EventBus.getDefault().unregister(this);
|
|
||||||
subscriptions.unsubscribe();
|
subscriptions.unsubscribe();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
@ -55,22 +57,17 @@ public class UpdateMangaSyncService extends Service {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusHook
|
private void updateLastChapterRead(MangaSync mangaSync, int startId) {
|
||||||
public void onEventMainThread(UpdateMangaSyncEvent event) {
|
MangaSyncService sync = syncManager.getSyncService(mangaSync.sync_id);
|
||||||
updateLastChapteRead(event.getMangaSync());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLastChapteRead(MangaSync mangaSync) {
|
subscriptions.add(Observable.fromCallable(() -> sync.update(mangaSync))
|
||||||
BaseMangaSync sync = syncManager.getSyncService(mangaSync.sync_id);
|
|
||||||
|
|
||||||
subscriptions.add(sync.update(mangaSync)
|
|
||||||
.flatMap(response -> db.insertMangaSync(mangaSync).createObservable())
|
.flatMap(response -> db.insertMangaSync(mangaSync).createObservable())
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(result -> {
|
.subscribe(result -> {
|
||||||
stopSelf();
|
stopSelf(startId);
|
||||||
}, error -> {
|
}, error -> {
|
||||||
stopSelf();
|
stopSelf(startId);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package eu.kanade.mangafeed.event;
|
|
||||||
|
|
||||||
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
|
||||||
|
|
||||||
public class UpdateMangaSyncEvent {
|
|
||||||
|
|
||||||
private MangaSync mangaSync;
|
|
||||||
|
|
||||||
public UpdateMangaSyncEvent(MangaSync mangaSync) {
|
|
||||||
this.mangaSync = mangaSync;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MangaSync getMangaSync() {
|
|
||||||
return mangaSync;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -8,25 +8,22 @@ import java.util.List;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
import de.greenrobot.event.EventBus;
|
||||||
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
|
||||||
import eu.kanade.mangafeed.data.mangasync.services.MyAnimeList;
|
|
||||||
import eu.kanade.mangafeed.data.sync.UpdateMangaSyncService;
|
|
||||||
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
import eu.kanade.mangafeed.data.database.DatabaseHelper;
|
||||||
import eu.kanade.mangafeed.data.database.models.Chapter;
|
import eu.kanade.mangafeed.data.database.models.Chapter;
|
||||||
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
|
||||||
import eu.kanade.mangafeed.data.database.models.Manga;
|
import eu.kanade.mangafeed.data.database.models.Manga;
|
||||||
import eu.kanade.mangafeed.data.download.DownloadManager;
|
import eu.kanade.mangafeed.data.download.DownloadManager;
|
||||||
|
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
||||||
|
import eu.kanade.mangafeed.data.mangasync.base.MangaSyncService;
|
||||||
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
||||||
import eu.kanade.mangafeed.data.source.SourceManager;
|
import eu.kanade.mangafeed.data.source.SourceManager;
|
||||||
import eu.kanade.mangafeed.data.source.base.Source;
|
import eu.kanade.mangafeed.data.source.base.Source;
|
||||||
import eu.kanade.mangafeed.data.source.model.Page;
|
import eu.kanade.mangafeed.data.source.model.Page;
|
||||||
|
import eu.kanade.mangafeed.data.sync.UpdateMangaSyncService;
|
||||||
import eu.kanade.mangafeed.event.ReaderEvent;
|
import eu.kanade.mangafeed.event.ReaderEvent;
|
||||||
import eu.kanade.mangafeed.event.UpdateMangaSyncEvent;
|
|
||||||
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
||||||
import eu.kanade.mangafeed.util.EventBusHook;
|
import eu.kanade.mangafeed.util.EventBusHook;
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
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;
|
||||||
import rx.subjects.PublishSubject;
|
import rx.subjects.PublishSubject;
|
||||||
@ -53,9 +50,6 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
|
|
||||||
private PublishSubject<Page> retryPageSubject;
|
private PublishSubject<Page> retryPageSubject;
|
||||||
|
|
||||||
private Subscription nextChapterSubscription;
|
|
||||||
private Subscription previousChapterSubscription;
|
|
||||||
|
|
||||||
private static final int GET_PAGE_LIST = 1;
|
private static final int GET_PAGE_LIST = 1;
|
||||||
private static final int GET_PAGE_IMAGES = 2;
|
private static final int GET_PAGE_IMAGES = 2;
|
||||||
private static final int RETRY_IMAGES = 3;
|
private static final int RETRY_IMAGES = 3;
|
||||||
@ -110,6 +104,9 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
unregisterForEvents();
|
unregisterForEvents();
|
||||||
|
if (pageList != null && isChapterFinished()) {
|
||||||
|
updateMangaSyncLastChapterRead();
|
||||||
|
}
|
||||||
onChapterLeft();
|
onChapterLeft();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
@ -231,13 +228,11 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
source.savePageList(chapter.url, pageList);
|
source.savePageList(chapter.url, pageList);
|
||||||
|
|
||||||
// Save current progress of the chapter. Mark as read if the chapter is finished
|
// Save current progress of the chapter. Mark as read if the chapter is finished
|
||||||
// and update progress in remote services (like MyAnimeList)
|
|
||||||
chapter.last_page_read = currentPage;
|
chapter.last_page_read = currentPage;
|
||||||
if (isChapterFinished()) {
|
if (isChapterFinished()) {
|
||||||
chapter.read = true;
|
chapter.read = true;
|
||||||
updateMangaSyncLastChapterRead();
|
|
||||||
}
|
}
|
||||||
db.insertChapter(chapter).executeAsBlocking();
|
db.insertChapter(chapter).createObservable().subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether the chapter has been read
|
// Check whether the chapter has been read
|
||||||
@ -246,26 +241,23 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateMangaSyncLastChapterRead() {
|
private void updateMangaSyncLastChapterRead() {
|
||||||
// TODO don't use MAL methods for possible alternatives to MAL
|
db.getMangaSync(manga).createObservable()
|
||||||
MyAnimeList mal = syncManager.getMyAnimeList();
|
.take(1)
|
||||||
|
.flatMap(Observable::from)
|
||||||
if (!mal.isLogged())
|
.doOnNext(mangaSync -> {
|
||||||
|
MangaSyncService service = syncManager.getSyncService(mangaSync.sync_id);
|
||||||
|
if (!service.isLogged())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<MangaSync> result = db.getMangaSync(manga, mal).executeAsBlocking();
|
|
||||||
if (result.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
MangaSync mangaSync = result.get(0);
|
|
||||||
|
|
||||||
int lastChapterReadLocal = (int) Math.floor(chapter.chapter_number);
|
int lastChapterReadLocal = (int) Math.floor(chapter.chapter_number);
|
||||||
int lastChapterReadRemote = mangaSync.last_chapter_read;
|
int lastChapterReadRemote = mangaSync.last_chapter_read;
|
||||||
|
|
||||||
if (lastChapterReadLocal > lastChapterReadRemote) {
|
if (lastChapterReadLocal > lastChapterReadRemote) {
|
||||||
mangaSync.last_chapter_read = lastChapterReadLocal;
|
mangaSync.last_chapter_read = lastChapterReadLocal;
|
||||||
EventBus.getDefault().postSticky(new UpdateMangaSyncEvent(mangaSync));
|
UpdateMangaSyncService.start(getContext(), mangaSync);
|
||||||
UpdateMangaSyncService.start(getContext());
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentPage(int currentPage) {
|
public void setCurrentPage(int currentPage) {
|
||||||
@ -273,20 +265,14 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getAdjacentChapters() {
|
private void getAdjacentChapters() {
|
||||||
if (nextChapterSubscription != null)
|
add(db.getNextChapter(chapter).createObservable()
|
||||||
remove(nextChapterSubscription);
|
.take(1)
|
||||||
|
|
||||||
add(nextChapterSubscription = db.getNextChapter(chapter).createObservable()
|
|
||||||
.flatMap(Observable::from)
|
.flatMap(Observable::from)
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe(result -> nextChapter = result));
|
.subscribe(result -> nextChapter = result));
|
||||||
|
|
||||||
if (previousChapterSubscription != null)
|
add(db.getPreviousChapter(chapter).createObservable()
|
||||||
remove(previousChapterSubscription);
|
.take(1)
|
||||||
|
|
||||||
add(previousChapterSubscription = db.getPreviousChapter(chapter).createObservable()
|
|
||||||
.flatMap(Observable::from)
|
.flatMap(Observable::from)
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe(result -> previousChapter = result));
|
.subscribe(result -> previousChapter = result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.App;
|
import eu.kanade.mangafeed.App;
|
||||||
import eu.kanade.mangafeed.data.mangasync.base.BaseMangaSync;
|
import eu.kanade.mangafeed.data.mangasync.base.MangaSyncService;
|
||||||
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
import eu.kanade.mangafeed.data.mangasync.MangaSyncManager;
|
||||||
import eu.kanade.mangafeed.data.source.SourceManager;
|
import eu.kanade.mangafeed.data.source.SourceManager;
|
||||||
import eu.kanade.mangafeed.data.source.base.Source;
|
import eu.kanade.mangafeed.data.source.base.Source;
|
||||||
@ -60,7 +60,7 @@ public class SettingsAccountsFragment extends SettingsNestedFragment {
|
|||||||
mangaSyncCategory.setTitle("Sync");
|
mangaSyncCategory.setTitle("Sync");
|
||||||
screen.addPreference(mangaSyncCategory);
|
screen.addPreference(mangaSyncCategory);
|
||||||
|
|
||||||
for (BaseMangaSync sync : syncManager.getSyncServices()) {
|
for (MangaSyncService sync : syncManager.getSyncServices()) {
|
||||||
MangaSyncLoginDialog dialog = new MangaSyncLoginDialog(
|
MangaSyncLoginDialog dialog = new MangaSyncLoginDialog(
|
||||||
screen.getContext(), preferences, sync);
|
screen.getContext(), preferences, sync);
|
||||||
dialog.setTitle(sync.getName());
|
dialog.setTitle(sync.getName());
|
||||||
|
@ -5,7 +5,7 @@ import android.content.DialogInterface;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.R;
|
import eu.kanade.mangafeed.R;
|
||||||
import eu.kanade.mangafeed.data.mangasync.base.BaseMangaSync;
|
import eu.kanade.mangafeed.data.mangasync.base.MangaSyncService;
|
||||||
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
||||||
import eu.kanade.mangafeed.util.ToastUtil;
|
import eu.kanade.mangafeed.util.ToastUtil;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
@ -13,9 +13,9 @@ import rx.schedulers.Schedulers;
|
|||||||
|
|
||||||
public class MangaSyncLoginDialog extends LoginDialogPreference {
|
public class MangaSyncLoginDialog extends LoginDialogPreference {
|
||||||
|
|
||||||
private BaseMangaSync sync;
|
private MangaSyncService sync;
|
||||||
|
|
||||||
public MangaSyncLoginDialog(Context context, PreferencesHelper preferences, BaseMangaSync sync) {
|
public MangaSyncLoginDialog(Context context, PreferencesHelper preferences, MangaSyncService sync) {
|
||||||
super(context, preferences);
|
super(context, preferences);
|
||||||
this.sync = sync;
|
this.sync = sync;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.5.0'
|
classpath 'com.android.tools.build:gradle:1.5.0'
|
||||||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
|
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
|
||||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
|
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.11.3'
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
Loading…
Reference in New Issue
Block a user