mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 00:55:08 +01:00
Upgrade storio to 1.7.0
This commit is contained in:
parent
62535c77ae
commit
b0ad72afad
@ -78,7 +78,7 @@ dependencies {
|
||||
final DAGGER_VERSION = '2.0.2'
|
||||
final HAMCREST_VERSION = '1.3'
|
||||
final MOCKITO_VERSION = '1.10.19'
|
||||
final STORIO_VERSION = '1.6.1'
|
||||
final STORIO_VERSION = '1.7.0'
|
||||
final ICEPICK_VERSION = '3.1.0'
|
||||
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
@ -3,13 +3,13 @@ package eu.kanade.mangafeed.data.database;
|
||||
import android.content.Context;
|
||||
|
||||
import com.pushtorefresh.storio.Queries;
|
||||
import com.pushtorefresh.storio.sqlite.SQLiteTypeMapping;
|
||||
import com.pushtorefresh.storio.sqlite.StorIOSQLite;
|
||||
import com.pushtorefresh.storio.sqlite.impl.DefaultStorIOSQLite;
|
||||
import com.pushtorefresh.storio.sqlite.operations.delete.PreparedDeleteByQuery;
|
||||
import com.pushtorefresh.storio.sqlite.operations.delete.PreparedDeleteCollectionOfObjects;
|
||||
import com.pushtorefresh.storio.sqlite.operations.delete.PreparedDeleteObject;
|
||||
import com.pushtorefresh.storio.sqlite.operations.get.PreparedGetListOfObjects;
|
||||
import com.pushtorefresh.storio.sqlite.operations.get.PreparedGetObject;
|
||||
import com.pushtorefresh.storio.sqlite.operations.put.PreparedPutCollectionOfObjects;
|
||||
import com.pushtorefresh.storio.sqlite.operations.put.PreparedPutObject;
|
||||
import com.pushtorefresh.storio.sqlite.operations.put.PutResults;
|
||||
@ -20,25 +20,15 @@ import com.pushtorefresh.storio.sqlite.queries.RawQuery;
|
||||
import java.util.List;
|
||||
|
||||
import eu.kanade.mangafeed.data.database.models.Category;
|
||||
import eu.kanade.mangafeed.data.database.models.CategoryStorIOSQLiteDeleteResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.CategoryStorIOSQLiteGetResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.CategoryStorIOSQLitePutResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.CategorySQLiteTypeMapping;
|
||||
import eu.kanade.mangafeed.data.database.models.Chapter;
|
||||
import eu.kanade.mangafeed.data.database.models.ChapterStorIOSQLiteDeleteResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.ChapterStorIOSQLiteGetResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.ChapterStorIOSQLitePutResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.ChapterSQLiteTypeMapping;
|
||||
import eu.kanade.mangafeed.data.database.models.Manga;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaCategory;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaCategoryStorIOSQLiteDeleteResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaCategoryStorIOSQLiteGetResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaCategoryStorIOSQLitePutResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaStorIOSQLiteDeleteResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaStorIOSQLiteGetResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaStorIOSQLitePutResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaCategorySQLiteTypeMapping;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaSQLiteTypeMapping;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaSync;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaSyncStorIOSQLiteDeleteResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaSyncStorIOSQLiteGetResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaSyncStorIOSQLitePutResolver;
|
||||
import eu.kanade.mangafeed.data.database.models.MangaSyncSQLiteTypeMapping;
|
||||
import eu.kanade.mangafeed.data.database.resolvers.LibraryMangaGetResolver;
|
||||
import eu.kanade.mangafeed.data.database.tables.CategoryTable;
|
||||
import eu.kanade.mangafeed.data.database.tables.ChapterTable;
|
||||
@ -58,31 +48,11 @@ public class DatabaseHelper {
|
||||
|
||||
db = DefaultStorIOSQLite.builder()
|
||||
.sqliteOpenHelper(new DbOpenHelper(context))
|
||||
.addTypeMapping(Manga.class, SQLiteTypeMapping.<Manga>builder()
|
||||
.putResolver(new MangaStorIOSQLitePutResolver())
|
||||
.getResolver(new MangaStorIOSQLiteGetResolver())
|
||||
.deleteResolver(new MangaStorIOSQLiteDeleteResolver())
|
||||
.build())
|
||||
.addTypeMapping(Chapter.class, SQLiteTypeMapping.<Chapter>builder()
|
||||
.putResolver(new ChapterStorIOSQLitePutResolver())
|
||||
.getResolver(new ChapterStorIOSQLiteGetResolver())
|
||||
.deleteResolver(new ChapterStorIOSQLiteDeleteResolver())
|
||||
.build())
|
||||
.addTypeMapping(MangaSync.class, SQLiteTypeMapping.<MangaSync>builder()
|
||||
.putResolver(new MangaSyncStorIOSQLitePutResolver())
|
||||
.getResolver(new MangaSyncStorIOSQLiteGetResolver())
|
||||
.deleteResolver(new MangaSyncStorIOSQLiteDeleteResolver())
|
||||
.build())
|
||||
.addTypeMapping(Category.class, SQLiteTypeMapping.<Category>builder()
|
||||
.putResolver(new CategoryStorIOSQLitePutResolver())
|
||||
.getResolver(new CategoryStorIOSQLiteGetResolver())
|
||||
.deleteResolver(new CategoryStorIOSQLiteDeleteResolver())
|
||||
.build())
|
||||
.addTypeMapping(MangaCategory.class, SQLiteTypeMapping.<MangaCategory>builder()
|
||||
.putResolver(new MangaCategoryStorIOSQLitePutResolver())
|
||||
.getResolver(new MangaCategoryStorIOSQLiteGetResolver())
|
||||
.deleteResolver(new MangaCategoryStorIOSQLiteDeleteResolver())
|
||||
.build())
|
||||
.addTypeMapping(Manga.class, new MangaSQLiteTypeMapping())
|
||||
.addTypeMapping(Chapter.class, new ChapterSQLiteTypeMapping())
|
||||
.addTypeMapping(MangaSync.class, new MangaSyncSQLiteTypeMapping())
|
||||
.addTypeMapping(Category.class, new CategorySQLiteTypeMapping())
|
||||
.addTypeMapping(MangaCategory.class, new MangaCategorySQLiteTypeMapping())
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -115,13 +85,14 @@ public class DatabaseHelper {
|
||||
.table(MangaTable.TABLE)
|
||||
.where(MangaTable.COLUMN_FAVORITE + "=?")
|
||||
.whereArgs(1)
|
||||
.orderBy(MangaTable.COLUMN_TITLE)
|
||||
.build())
|
||||
.prepare();
|
||||
}
|
||||
|
||||
public PreparedGetListOfObjects<Manga> getManga(String url, int sourceId) {
|
||||
public PreparedGetObject<Manga> getManga(String url, int sourceId) {
|
||||
return db.get()
|
||||
.listOfObjects(Manga.class)
|
||||
.object(Manga.class)
|
||||
.withQuery(Query.builder()
|
||||
.table(MangaTable.TABLE)
|
||||
.where(MangaTable.COLUMN_URL + "=? AND " + MangaTable.COLUMN_SOURCE + "=?")
|
||||
@ -130,9 +101,9 @@ public class DatabaseHelper {
|
||||
.prepare();
|
||||
}
|
||||
|
||||
public PreparedGetListOfObjects<Manga> getManga(long id) {
|
||||
public PreparedGetObject<Manga> getManga(long id) {
|
||||
return db.get()
|
||||
.listOfObjects(Manga.class)
|
||||
.object(Manga.class)
|
||||
.withQuery(Query.builder()
|
||||
.table(MangaTable.TABLE)
|
||||
.where(MangaTable.COLUMN_ID + "=?")
|
||||
@ -199,13 +170,13 @@ public class DatabaseHelper {
|
||||
.prepare();
|
||||
}
|
||||
|
||||
public PreparedGetListOfObjects<Chapter> getNextChapter(Chapter chapter) {
|
||||
public PreparedGetObject<Chapter> getNextChapter(Chapter chapter) {
|
||||
// Add a delta to the chapter number, because binary decimal representation
|
||||
// can retrieve the same chapter again
|
||||
double chapterNumber = chapter.chapter_number + 0.00001;
|
||||
|
||||
return db.get()
|
||||
.listOfObjects(Chapter.class)
|
||||
.object(Chapter.class)
|
||||
.withQuery(Query.builder()
|
||||
.table(ChapterTable.TABLE)
|
||||
.where(ChapterTable.COLUMN_MANGA_ID + "=? AND " +
|
||||
@ -218,13 +189,13 @@ public class DatabaseHelper {
|
||||
.prepare();
|
||||
}
|
||||
|
||||
public PreparedGetListOfObjects<Chapter> getPreviousChapter(Chapter chapter) {
|
||||
public PreparedGetObject<Chapter> getPreviousChapter(Chapter chapter) {
|
||||
// Add a delta to the chapter number, because binary decimal representation
|
||||
// can retrieve the same chapter again
|
||||
double chapterNumber = chapter.chapter_number - 0.00001;
|
||||
|
||||
return db.get()
|
||||
.listOfObjects(Chapter.class)
|
||||
.object(Chapter.class)
|
||||
.withQuery(Query.builder()
|
||||
.table(ChapterTable.TABLE)
|
||||
.where(ChapterTable.COLUMN_MANGA_ID + "=? AND " +
|
||||
@ -237,9 +208,9 @@ public class DatabaseHelper {
|
||||
.prepare();
|
||||
}
|
||||
|
||||
public PreparedGetListOfObjects<Chapter> getNextUnreadChapter(Manga manga) {
|
||||
public PreparedGetObject<Chapter> getNextUnreadChapter(Manga manga) {
|
||||
return db.get()
|
||||
.listOfObjects(Chapter.class)
|
||||
.object(Chapter.class)
|
||||
.withQuery(Query.builder()
|
||||
.table(ChapterTable.TABLE)
|
||||
.where(ChapterTable.COLUMN_MANGA_ID + "=? AND " +
|
||||
@ -312,9 +283,9 @@ public class DatabaseHelper {
|
||||
|
||||
// Manga sync related queries
|
||||
|
||||
public PreparedGetListOfObjects<MangaSync> getMangaSync(Manga manga, MangaSyncService sync) {
|
||||
public PreparedGetObject<MangaSync> getMangaSync(Manga manga, MangaSyncService sync) {
|
||||
return db.get()
|
||||
.listOfObjects(MangaSync.class)
|
||||
.object(MangaSync.class)
|
||||
.withQuery(Query.builder()
|
||||
.table(MangaSyncTable.TABLE)
|
||||
.where(MangaSyncTable.COLUMN_MANGA_ID + "=? AND " +
|
||||
@ -324,7 +295,7 @@ public class DatabaseHelper {
|
||||
.prepare();
|
||||
}
|
||||
|
||||
public PreparedGetListOfObjects<MangaSync> getMangaSync(Manga manga) {
|
||||
public PreparedGetListOfObjects<MangaSync> getMangasSync(Manga manga) {
|
||||
return db.get()
|
||||
.listOfObjects(MangaSync.class)
|
||||
.withQuery(Query.builder()
|
||||
|
@ -29,6 +29,9 @@ public class MangaSync implements Serializable {
|
||||
@StorIOSQLiteColumn(name = MangaSyncTable.COLUMN_LAST_CHAPTER_READ)
|
||||
public int last_chapter_read;
|
||||
|
||||
@StorIOSQLiteColumn(name = MangaSyncTable.COLUMN_TOTAL_CHAPTERS)
|
||||
public int total_chapters;
|
||||
|
||||
@StorIOSQLiteColumn(name = MangaSyncTable.COLUMN_SCORE)
|
||||
public float score;
|
||||
|
||||
|
@ -22,6 +22,8 @@ public class MangaSyncTable {
|
||||
|
||||
public static final String COLUMN_SCORE = "score";
|
||||
|
||||
public static final String COLUMN_TOTAL_CHAPTERS = "total_chapters";
|
||||
|
||||
@NonNull
|
||||
public static String getCreateTableQuery() {
|
||||
return "CREATE TABLE " + TABLE + "("
|
||||
@ -31,6 +33,7 @@ public class MangaSyncTable {
|
||||
+ COLUMN_REMOTE_ID + " INTEGER NOT NULL, "
|
||||
+ COLUMN_TITLE + " TEXT NOT NULL, "
|
||||
+ COLUMN_LAST_CHAPTER_READ + " INTEGER NOT NULL, "
|
||||
+ COLUMN_TOTAL_CHAPTERS + " INTEGER NOT NULL, "
|
||||
+ COLUMN_STATUS + " INTEGER NOT NULL, "
|
||||
+ COLUMN_SCORE + " FLOAT NOT NULL, "
|
||||
+ "FOREIGN KEY(" + COLUMN_MANGA_ID + ") REFERENCES " + MangaTable.TABLE + "(" + MangaTable.COLUMN_ID + ") "
|
||||
|
@ -134,8 +134,7 @@ public class CataloguePresenter extends BasePresenter<CatalogueFragment> {
|
||||
}
|
||||
|
||||
private Manga networkToLocalManga(Manga networkManga) {
|
||||
List<Manga> dbResult = db.getManga(networkManga.url, source.getId()).executeAsBlocking();
|
||||
Manga localManga = !dbResult.isEmpty() ? dbResult.get(0) : null;
|
||||
Manga localManga = db.getManga(networkManga.url, source.getId()).executeAsBlocking();
|
||||
if (localManga == null) {
|
||||
PutResult result = db.insertManga(networkManga).executeAsBlocking();
|
||||
networkManga.id = result.insertedId();
|
||||
|
@ -38,7 +38,6 @@ public class MangaPresenter extends BasePresenter<MangaActivity> {
|
||||
private Observable<Manga> getDbMangaObservable() {
|
||||
return db.getManga(mangaId).createObservable()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.flatMap(Observable::from)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext(manga -> EventBus.getDefault().postSticky(manga));
|
||||
}
|
||||
|
@ -191,8 +191,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||
}
|
||||
|
||||
public Chapter getNextUnreadChapter() {
|
||||
List<Chapter> chapters = db.getNextUnreadChapter(manga).executeAsBlocking();
|
||||
return !chapters.isEmpty() ? chapters.get(0) : null;
|
||||
return db.getNextUnreadChapter(manga).executeAsBlocking();
|
||||
}
|
||||
|
||||
public void markChaptersRead(Observable<Chapter> selectedChapters, boolean read) {
|
||||
|
@ -45,7 +45,6 @@ public class MyAnimeListPresenter extends BasePresenter<MyAnimeListFragment> {
|
||||
|
||||
restartableLatestCache(GET_MANGA_SYNC,
|
||||
() -> db.getMangaSync(manga, myAnimeList).createObservable()
|
||||
.flatMap(Observable::from)
|
||||
.doOnNext(mangaSync -> this.mangaSync = mangaSync)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread()),
|
||||
|
@ -249,7 +249,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||
if (pageList == null)
|
||||
return;
|
||||
|
||||
db.getMangaSync(manga).createObservable()
|
||||
db.getMangasSync(manga).createObservable()
|
||||
.take(1)
|
||||
.flatMap(Observable::from)
|
||||
.doOnNext(mangaSync -> {
|
||||
@ -281,12 +281,10 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||
private void getAdjacentChapters() {
|
||||
add(db.getNextChapter(chapter).createObservable()
|
||||
.take(1)
|
||||
.flatMap(Observable::from)
|
||||
.subscribe(result -> nextChapter = result));
|
||||
|
||||
add(db.getPreviousChapter(chapter).createObservable()
|
||||
.take(1)
|
||||
.flatMap(Observable::from)
|
||||
.subscribe(result -> previousChapter = result));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user