Upgrade StorIO to 1.8.0

This commit is contained in:
inorichi 2016-01-19 15:49:13 +01:00
parent dda0c50a1c
commit 416fd128ba
12 changed files with 23 additions and 24 deletions

View File

@ -81,7 +81,7 @@ dependencies {
final SUPPORT_LIBRARY_VERSION = '23.1.1' final SUPPORT_LIBRARY_VERSION = '23.1.1'
final DAGGER_VERSION = '2.0.2' final DAGGER_VERSION = '2.0.2'
final MOCKITO_VERSION = '1.10.19' final MOCKITO_VERSION = '1.10.19'
final STORIO_VERSION = '1.7.0' final STORIO_VERSION = '1.8.0'
final ICEPICK_VERSION = '3.1.0' final ICEPICK_VERSION = '3.1.0'
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])

View File

@ -63,7 +63,7 @@ public class UpdateMangaSyncService extends Service {
subscriptions.add(Observable.defer(() -> sync.update(mangaSync)) subscriptions.add(Observable.defer(() -> sync.update(mangaSync))
.flatMap(response -> { .flatMap(response -> {
if (response.isSuccessful()) { if (response.isSuccessful()) {
return db.insertMangaSync(mangaSync).createObservable(); return db.insertMangaSync(mangaSync).asRxObservable();
} }
return Observable.error(new Exception("Could not update MAL")); return Observable.error(new Exception("Could not update MAL"));
}) })

View File

@ -70,12 +70,12 @@ public class LibraryPresenter extends BasePresenter<LibraryFragment> {
} }
private Observable<List<Category>> getCategoriesObservable() { private Observable<List<Category>> getCategoriesObservable() {
return db.getCategories().createObservable() return db.getCategories().asRxObservable()
.doOnNext(categories -> this.categories = categories); .doOnNext(categories -> this.categories = categories);
} }
private Observable<Map<Integer, List<Manga>>> getLibraryMangasObservable() { private Observable<Map<Integer, List<Manga>>> getLibraryMangasObservable() {
return db.getLibraryMangas().createObservable() return db.getLibraryMangas().asRxObservable()
.flatMap(mangas -> Observable.from(mangas) .flatMap(mangas -> Observable.from(mangas)
.groupBy(manga -> manga.category) .groupBy(manga -> manga.category)
.flatMap(group -> group.toList() .flatMap(group -> group.toList()

View File

@ -24,7 +24,7 @@ public class CategoryPresenter extends BasePresenter<CategoryActivity> {
super.onCreate(savedState); super.onCreate(savedState);
restartableLatestCache(GET_CATEGORIES, restartableLatestCache(GET_CATEGORIES,
() -> db.getCategories().createObservable() () -> db.getCategories().asRxObservable()
.doOnNext(categories -> this.categories = categories) .doOnNext(categories -> this.categories = categories)
.observeOn(AndroidSchedulers.mainThread()), .observeOn(AndroidSchedulers.mainThread()),
CategoryActivity::setCategories); CategoryActivity::setCategories);
@ -46,11 +46,11 @@ public class CategoryPresenter extends BasePresenter<CategoryActivity> {
} }
cat.order = max; cat.order = max;
db.insertCategory(cat).createObservable().subscribe(); db.insertCategory(cat).asRxObservable().subscribe();
} }
public void deleteCategories(List<Category> categories) { public void deleteCategories(List<Category> categories) {
db.deleteCategories(categories).createObservable().subscribe(); db.deleteCategories(categories).asRxObservable().subscribe();
} }
public void reorderCategories(List<Category> categories) { public void reorderCategories(List<Category> categories) {
@ -58,11 +58,11 @@ public class CategoryPresenter extends BasePresenter<CategoryActivity> {
categories.get(i).order = i; categories.get(i).order = i;
} }
db.insertCategories(categories).createObservable().subscribe(); db.insertCategories(categories).asRxObservable().subscribe();
} }
public void renameCategory(Category category, String name) { public void renameCategory(Category category, String name) {
category.name = name; category.name = name;
db.insertCategory(category).createObservable().subscribe(); db.insertCategory(category).asRxObservable().subscribe();
} }
} }

View File

@ -36,7 +36,7 @@ public class MangaPresenter extends BasePresenter<MangaActivity> {
} }
private Observable<Manga> getDbMangaObservable() { private Observable<Manga> getDbMangaObservable() {
return db.getManga(mangaId).createObservable() return db.getManga(mangaId).asRxObservable()
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.doOnNext(manga -> EventBus.getDefault().postSticky(manga)); .doOnNext(manga -> EventBus.getDefault().postSticky(manga));

View File

@ -97,7 +97,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
source = sourceManager.get(manga.source); source = sourceManager.get(manga.source);
start(DB_CHAPTERS); start(DB_CHAPTERS);
add(db.getChapters(manga).createObservable() add(db.getChapters(manga).asRxObservable()
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnNext(chapters -> { .doOnNext(chapters -> {
this.chapters = chapters; this.chapters = chapters;
@ -202,7 +202,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
return chapter; return chapter;
}) })
.toList() .toList()
.flatMap(chapters -> db.insertChapters(chapters).createObservable()) .flatMap(chapters -> db.insertChapters(chapters).asRxObservable())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe()); .subscribe());
} }

View File

@ -46,7 +46,7 @@ public class MyAnimeListPresenter extends BasePresenter<MyAnimeListFragment> {
myAnimeList = syncManager.getMyAnimeList(); myAnimeList = syncManager.getMyAnimeList();
restartableLatestCache(GET_MANGA_SYNC, restartableLatestCache(GET_MANGA_SYNC,
() -> db.getMangaSync(manga, myAnimeList).createObservable() () -> db.getMangaSync(manga, myAnimeList).asRxObservable()
.doOnNext(mangaSync -> this.mangaSync = mangaSync) .doOnNext(mangaSync -> this.mangaSync = mangaSync)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()), .observeOn(AndroidSchedulers.mainThread()),
@ -75,7 +75,7 @@ public class MyAnimeListPresenter extends BasePresenter<MyAnimeListFragment> {
} }
return Observable.error(new Exception("Could not find manga")); return Observable.error(new Exception("Could not find manga"));
}) })
.flatMap(myManga -> db.insertMangaSync(myManga).createObservable()) .flatMap(myManga -> db.insertMangaSync(myManga).asRxObservable())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()), .observeOn(AndroidSchedulers.mainThread()),
(view, result) -> view.onRefreshDone(), (view, result) -> view.onRefreshDone(),
@ -109,7 +109,7 @@ public class MyAnimeListPresenter extends BasePresenter<MyAnimeListFragment> {
private void updateRemote() { private void updateRemote() {
add(myAnimeList.update(mangaSync) add(myAnimeList.update(mangaSync)
.flatMap(response -> db.insertMangaSync(mangaSync).createObservable()) .flatMap(response -> db.insertMangaSync(mangaSync).asRxObservable())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(next -> {}, .subscribe(next -> {},
@ -139,7 +139,7 @@ public class MyAnimeListPresenter extends BasePresenter<MyAnimeListFragment> {
add(myAnimeList.bind(manga) add(myAnimeList.bind(manga)
.flatMap(response -> { .flatMap(response -> {
if (response.isSuccessful()) { if (response.isSuccessful()) {
return db.insertMangaSync(manga).createObservable(); return db.insertMangaSync(manga).asRxObservable();
} }
return Observable.error(new Exception("Could not bind manga")); return Observable.error(new Exception("Could not bind manga"));
}) })

View File

@ -172,8 +172,8 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
private Observable<Pair<Chapter, Chapter>> getAdjacentChaptersObservable() { private Observable<Pair<Chapter, Chapter>> getAdjacentChaptersObservable() {
return Observable.zip( return Observable.zip(
db.getPreviousChapter(chapter).createObservable().take(1), db.getPreviousChapter(chapter).asRxObservable().take(1),
db.getNextChapter(chapter).createObservable().take(1), db.getNextChapter(chapter).asRxObservable().take(1),
Pair::create) Pair::create)
.doOnNext(pair -> { .doOnNext(pair -> {
previousChapter = pair.first; previousChapter = pair.first;
@ -211,7 +211,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
} }
private Observable<List<MangaSync>> getMangaSyncObservable() { private Observable<List<MangaSync>> getMangaSyncObservable() {
return db.getMangasSync(manga).createObservable() return db.getMangasSync(manga).asRxObservable()
.doOnNext(mangaSync -> this.mangaSyncList = mangaSync); .doOnNext(mangaSync -> this.mangaSyncList = mangaSync);
} }
@ -262,7 +262,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
if (isChapterFinished()) { if (isChapterFinished()) {
chapter.read = true; chapter.read = true;
} }
db.insertChapter(chapter).createObservable().subscribe(); db.insertChapter(chapter).asRxObservable().subscribe();
} }
// Check whether the chapter has been read // Check whether the chapter has been read

View File

@ -47,7 +47,6 @@ public class WebtoonAdapter extends RecyclerView.Adapter<WebtoonHolder> {
public void setPages(List<Page> pages) { public void setPages(List<Page> pages) {
this.pages = pages; this.pages = pages;
notifyDataSetChanged();
} }
public void clear() { public void clear() {

View File

@ -107,9 +107,8 @@ public class WebtoonReader extends BaseReader {
if (pages != null) { if (pages != null) {
unsubscribeStatus(); unsubscribeStatus();
recycler.clearOnScrollListeners(); recycler.clearOnScrollListeners();
adapter.clear();
recycler.scrollTo(0, 0);
adapter.setPages(pages); adapter.setPages(pages);
recycler.setAdapter(adapter);
setScrollListener(); setScrollListener();
observeStatus(0); observeStatus(0);
} }

View File

@ -75,6 +75,7 @@ public class RecentChaptersAdapter extends FlexibleAdapter<RecyclerView.ViewHold
case SECTION: case SECTION:
final Date date = (Date) getItem(position); final Date date = (Date) getItem(position);
((SectionViewHolder) holder).onSetValues(date); ((SectionViewHolder) holder).onSetValues(date);
break;
} }
//When user scrolls this bind the correct selection status //When user scrolls this bind the correct selection status

View File

@ -42,7 +42,7 @@ public class RecentChaptersPresenter extends BasePresenter<RecentChaptersFragmen
} }
private Observable<List<Object>> getRecentChaptersObservable() { private Observable<List<Object>> getRecentChaptersObservable() {
return db.getRecentChapters().createObservable() return db.getRecentChapters().asRxObservable()
// group chapters by the date they were fetched on a ordered map // group chapters by the date they were fetched on a ordered map
.flatMap(recents -> Observable.from(recents) .flatMap(recents -> Observable.from(recents)
.toMultimap( .toMultimap(