From c6df23b1aa3a8de083ee5a7ffb0e928d69adbe0e Mon Sep 17 00:00:00 2001 From: inorichi Date: Sun, 18 Oct 2015 01:59:21 +0200 Subject: [PATCH] Don't query db twice --- .../main/java/eu/kanade/mangafeed/data/models/Manga.java | 1 - .../eu/kanade/mangafeed/presenter/MangaInfoPresenter.java | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/mangafeed/data/models/Manga.java b/app/src/main/java/eu/kanade/mangafeed/data/models/Manga.java index 17ea54d20..2994dbebb 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/models/Manga.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/models/Manga.java @@ -10,7 +10,6 @@ import eu.kanade.mangafeed.data.tables.MangasTable; @StorIOSQLiteType(table = MangasTable.TABLE) public class Manga { - @Nullable @StorIOSQLiteColumn(name = MangasTable.COLUMN_ID, key = true) public Long id; diff --git a/app/src/main/java/eu/kanade/mangafeed/presenter/MangaInfoPresenter.java b/app/src/main/java/eu/kanade/mangafeed/presenter/MangaInfoPresenter.java index b6e07e3d3..fbc3e5c81 100644 --- a/app/src/main/java/eu/kanade/mangafeed/presenter/MangaInfoPresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/presenter/MangaInfoPresenter.java @@ -36,12 +36,9 @@ public class MangaInfoPresenter extends BasePresenter { private void getMangaInfo() { if (mangaInfoSubscription != null) - return; + remove(mangaInfoSubscription); - add(mangaInfoSubscription = db.getManga(manga.id) - .subscribeOn(Schedulers.io()) - .take(1) - .flatMap(Observable::from) + add(mangaInfoSubscription = Observable.just(manga) .observeOn(AndroidSchedulers.mainThread()) .compose(deliverLatestCache()) .subscribe(split(MangaInfoFragment::setMangaInfo)));