From 589160242ee5f1f64d255b85db0a2907a44fb495 Mon Sep 17 00:00:00 2001 From: len Date: Tue, 14 Jun 2016 15:11:23 +0200 Subject: [PATCH] Rewrite database models in Kotlin --- .../database/mappers/CategoryTypeMapping.kt | 3 +- .../database/mappers/ChapterTypeMapping.kt | 3 +- .../database/mappers/HistoryTypeMapping.kt | 2 +- .../mappers/MangaCategoryTypeMapping.kt | 2 +- .../database/mappers/MangaSyncTypeMapping.kt | 3 +- .../data/database/mappers/MangaTypeMapping.kt | 3 +- .../data/database/models/Category.java | 57 ----- .../data/database/models/Category.kt | 27 +++ .../data/database/models/CategoryImpl.kt | 26 +++ .../data/database/models/Chapter.java | 94 -------- .../tachiyomi/data/database/models/Chapter.kt | 36 +++ .../data/database/models/ChapterImpl.kt | 39 ++++ .../data/database/models/History.java | 58 ----- .../tachiyomi/data/database/models/History.kt | 44 ++++ .../tachiyomi/data/database/models/Manga.java | 213 ------------------ .../tachiyomi/data/database/models/Manga.kt | 131 +++++++++++ .../data/database/models/MangaCategory.java | 29 --- .../data/database/models/MangaCategory.kt | 21 ++ .../data/database/models/MangaChapter.java | 12 - .../data/database/models/MangaChapter.kt | 3 + .../database/models/MangaChapterHistory.java | 27 --- .../database/models/MangaChapterHistory.kt | 10 + .../data/database/models/MangaImpl.kt | 53 +++++ .../data/database/models/MangaSync.java | 78 ------- .../data/database/models/MangaSync.kt | 40 ++++ .../data/database/models/MangaSyncImpl.kt | 43 ++++ .../data/database/queries/ChapterQueries.kt | 75 ------ .../MangaChapterHistoryGetResolver.kt | 6 +- 28 files changed, 484 insertions(+), 654 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/Category.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/Category.kt create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/CategoryImpl.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/History.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/History.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaCategory.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaCategory.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapter.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapter.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapterHistory.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapterHistory.kt create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSync.java create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSync.kt create mode 100644 app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSyncImpl.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt index b1bd29fc4..0069934be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/CategoryTypeMapping.kt @@ -10,6 +10,7 @@ import com.pushtorefresh.storio.sqlite.queries.DeleteQuery import com.pushtorefresh.storio.sqlite.queries.InsertQuery import com.pushtorefresh.storio.sqlite.queries.UpdateQuery import eu.kanade.tachiyomi.data.database.models.Category +import eu.kanade.tachiyomi.data.database.models.CategoryImpl import eu.kanade.tachiyomi.data.database.tables.CategoryTable.COL_FLAGS import eu.kanade.tachiyomi.data.database.tables.CategoryTable.COL_ID import eu.kanade.tachiyomi.data.database.tables.CategoryTable.COL_NAME @@ -44,7 +45,7 @@ class CategoryPutResolver : DefaultPutResolver() { class CategoryGetResolver : DefaultGetResolver() { - override fun mapFromCursor(cursor: Cursor) = Category().apply { + override fun mapFromCursor(cursor: Cursor): Category = CategoryImpl().apply { id = cursor.getInt(cursor.getColumnIndex(COL_ID)) name = cursor.getString(cursor.getColumnIndex(COL_NAME)) order = cursor.getInt(cursor.getColumnIndex(COL_ORDER)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt index bdc2e51d4..82914045f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/ChapterTypeMapping.kt @@ -10,6 +10,7 @@ import com.pushtorefresh.storio.sqlite.queries.DeleteQuery import com.pushtorefresh.storio.sqlite.queries.InsertQuery import com.pushtorefresh.storio.sqlite.queries.UpdateQuery import eu.kanade.tachiyomi.data.database.models.Chapter +import eu.kanade.tachiyomi.data.database.models.ChapterImpl import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_CHAPTER_NUMBER import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_DATE_FETCH import eu.kanade.tachiyomi.data.database.tables.ChapterTable.COL_DATE_UPLOAD @@ -56,7 +57,7 @@ class ChapterPutResolver : DefaultPutResolver() { class ChapterGetResolver : DefaultGetResolver() { - override fun mapFromCursor(cursor: Cursor) = Chapter().apply { + override fun mapFromCursor(cursor: Cursor): Chapter = ChapterImpl().apply { id = cursor.getLong(cursor.getColumnIndex(COL_ID)) manga_id = cursor.getLong(cursor.getColumnIndex(COL_MANGA_ID)) url = cursor.getString(cursor.getColumnIndex(COL_URL)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/HistoryTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/HistoryTypeMapping.kt index 2997f8db1..ef2378b3b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/HistoryTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/HistoryTypeMapping.kt @@ -44,7 +44,7 @@ class HistoryPutResolver : DefaultPutResolver() { class HistoryGetResolver : DefaultGetResolver() { - override fun mapFromCursor(cursor: Cursor) = History().apply { + override fun mapFromCursor(cursor: Cursor): History = History().apply { id = cursor.getLong(cursor.getColumnIndex(COL_ID)) chapter_id = cursor.getLong(cursor.getColumnIndex(COL_CHAPTER_ID)) last_read = cursor.getLong(cursor.getColumnIndex(COL_LAST_READ)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaCategoryTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaCategoryTypeMapping.kt index b0b11e2fb..99cfdd47c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaCategoryTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaCategoryTypeMapping.kt @@ -42,7 +42,7 @@ class MangaCategoryPutResolver : DefaultPutResolver() { class MangaCategoryGetResolver : DefaultGetResolver() { - override fun mapFromCursor(cursor: Cursor) = MangaCategory().apply { + override fun mapFromCursor(cursor: Cursor): MangaCategory = MangaCategory().apply { id = cursor.getLong(cursor.getColumnIndex(COL_ID)) manga_id = cursor.getLong(cursor.getColumnIndex(COL_MANGA_ID)) category_id = cursor.getInt(cursor.getColumnIndex(COL_CATEGORY_ID)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaSyncTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaSyncTypeMapping.kt index b3c7cc92b..b02ae16a5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaSyncTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaSyncTypeMapping.kt @@ -10,6 +10,7 @@ import com.pushtorefresh.storio.sqlite.queries.DeleteQuery import com.pushtorefresh.storio.sqlite.queries.InsertQuery import com.pushtorefresh.storio.sqlite.queries.UpdateQuery import eu.kanade.tachiyomi.data.database.models.MangaSync +import eu.kanade.tachiyomi.data.database.models.MangaSyncImpl import eu.kanade.tachiyomi.data.database.tables.MangaSyncTable.COL_ID import eu.kanade.tachiyomi.data.database.tables.MangaSyncTable.COL_LAST_CHAPTER_READ import eu.kanade.tachiyomi.data.database.tables.MangaSyncTable.COL_MANGA_ID @@ -54,7 +55,7 @@ class MangaSyncPutResolver : DefaultPutResolver() { class MangaSyncGetResolver : DefaultGetResolver() { - override fun mapFromCursor(cursor: Cursor) = MangaSync().apply { + override fun mapFromCursor(cursor: Cursor): MangaSync = MangaSyncImpl().apply { id = cursor.getLong(cursor.getColumnIndex(COL_ID)) manga_id = cursor.getLong(cursor.getColumnIndex(COL_MANGA_ID)) sync_id = cursor.getInt(cursor.getColumnIndex(COL_SYNC_ID)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaTypeMapping.kt index e98fa6da8..0d410a2b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/MangaTypeMapping.kt @@ -10,6 +10,7 @@ import com.pushtorefresh.storio.sqlite.queries.DeleteQuery import com.pushtorefresh.storio.sqlite.queries.InsertQuery import com.pushtorefresh.storio.sqlite.queries.UpdateQuery import eu.kanade.tachiyomi.data.database.models.Manga +import eu.kanade.tachiyomi.data.database.models.MangaImpl import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_ARTIST import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_AUTHOR import eu.kanade.tachiyomi.data.database.tables.MangaTable.COL_CHAPTER_FLAGS @@ -66,7 +67,7 @@ class MangaPutResolver : DefaultPutResolver() { open class MangaGetResolver : DefaultGetResolver() { - override fun mapFromCursor(cursor: Cursor) = Manga().apply { + override fun mapFromCursor(cursor: Cursor): Manga = MangaImpl().apply { id = cursor.getLong(cursor.getColumnIndex(COL_ID)) source = cursor.getInt(cursor.getColumnIndex(COL_SOURCE)) url = cursor.getString(cursor.getColumnIndex(COL_URL)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Category.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Category.java deleted file mode 100644 index e6de5e1ca..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Category.java +++ /dev/null @@ -1,57 +0,0 @@ -package eu.kanade.tachiyomi.data.database.models; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; - -import java.io.Serializable; - -import eu.kanade.tachiyomi.data.database.tables.CategoryTable; - -@StorIOSQLiteType(table = CategoryTable.TABLE) -public class Category implements Serializable { - - @StorIOSQLiteColumn(name = CategoryTable.COL_ID, key = true) - public Integer id; - - @StorIOSQLiteColumn(name = CategoryTable.COL_NAME) - public String name; - - @StorIOSQLiteColumn(name = CategoryTable.COL_ORDER) - public int order; - - @StorIOSQLiteColumn(name = CategoryTable.COL_FLAGS) - public int flags; - - public Category() {} - - public static Category create(String name) { - Category c = new Category(); - c.name = name; - return c; - } - - public static Category createDefault() { - Category c = create("Default"); - c.id = 0; - return c; - } - - public String getNameLower() { - return name.toLowerCase(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Category category = (Category) o; - - return name.equals(category.name); - } - - @Override - public int hashCode() { - return name.hashCode(); - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Category.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Category.kt new file mode 100644 index 000000000..c88d93261 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Category.kt @@ -0,0 +1,27 @@ +package eu.kanade.tachiyomi.data.database.models + +import java.io.Serializable + +interface Category : Serializable { + + var id: Int? + + var name: String + + var order: Int + + var flags: Int + + val nameLower: String + get() = name.toLowerCase() + + companion object { + + fun create(name: String): Category = CategoryImpl().apply { + this.name = name + } + + fun createDefault(): Category = create("Default").apply { id = 0 } + } + +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/CategoryImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/CategoryImpl.kt new file mode 100644 index 000000000..65a004477 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/CategoryImpl.kt @@ -0,0 +1,26 @@ +package eu.kanade.tachiyomi.data.database.models + +class CategoryImpl : Category { + + override var id: Int? = null + + override lateinit var name: String + + override var order: Int = 0 + + override var flags: Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + + val category = other as Category + + return name == category.name + } + + override fun hashCode(): Int { + return name.hashCode() + } + +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.java deleted file mode 100644 index abe111f25..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.java +++ /dev/null @@ -1,94 +0,0 @@ -package eu.kanade.tachiyomi.data.database.models; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; - -import java.io.Serializable; -import java.util.List; - -import eu.kanade.tachiyomi.data.database.tables.ChapterTable; -import eu.kanade.tachiyomi.data.download.model.Download; -import eu.kanade.tachiyomi.data.source.model.Page; -import eu.kanade.tachiyomi.util.UrlUtil; - -@StorIOSQLiteType(table = ChapterTable.TABLE) -public class Chapter implements Serializable { - - @StorIOSQLiteColumn(name = ChapterTable.COL_ID, key = true) - public Long id; - - @StorIOSQLiteColumn(name = ChapterTable.COL_MANGA_ID) - public Long manga_id; - - @StorIOSQLiteColumn(name = ChapterTable.COL_URL) - public String url; - - @StorIOSQLiteColumn(name = ChapterTable.COL_NAME) - public String name; - - @StorIOSQLiteColumn(name = ChapterTable.COL_READ) - public boolean read; - - @StorIOSQLiteColumn(name = ChapterTable.COL_LAST_PAGE_READ) - public int last_page_read; - - @StorIOSQLiteColumn(name = ChapterTable.COL_DATE_FETCH) - public long date_fetch; - - @StorIOSQLiteColumn(name = ChapterTable.COL_DATE_UPLOAD) - public long date_upload; - - @StorIOSQLiteColumn(name = ChapterTable.COL_CHAPTER_NUMBER) - public float chapter_number; - - @StorIOSQLiteColumn(name = ChapterTable.COL_SOURCE_ORDER) - public int source_order; - - public int status; - - private transient List pages; - - public Chapter() {} - - public void setUrl(String url) { - this.url = UrlUtil.getPath(url); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Chapter chapter = (Chapter) o; - - return url.equals(chapter.url); - - } - - @Override - public int hashCode() { - return url.hashCode(); - } - - public static Chapter create() { - Chapter chapter = new Chapter(); - chapter.chapter_number = -1; - return chapter; - } - - public List getPages() { - return pages; - } - - public void setPages(List pages) { - this.pages = pages; - } - - public boolean isDownloaded() { - return status == Download.DOWNLOADED; - } - - public boolean isRecognizedNumber() { - return chapter_number >= 0f; - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt new file mode 100644 index 000000000..f0294c275 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Chapter.kt @@ -0,0 +1,36 @@ +package eu.kanade.tachiyomi.data.database.models + +import java.io.Serializable + +interface Chapter : Serializable { + + var id: Long? + + var manga_id: Long? + + var url: String + + var name: String + + var read: Boolean + + var last_page_read: Int + + var date_fetch: Long + + var date_upload: Long + + var chapter_number: Float + + var source_order: Int + + val isRecognizedNumber: Boolean + get() = chapter_number >= 0f + + companion object { + + fun create(): Chapter = ChapterImpl().apply { + chapter_number = -1f + } + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt new file mode 100644 index 000000000..7120e583b --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/ChapterImpl.kt @@ -0,0 +1,39 @@ +package eu.kanade.tachiyomi.data.database.models + +class ChapterImpl : Chapter { + + override var id: Long? = null + + override var manga_id: Long? = null + + override lateinit var url: String + + override lateinit var name: String + + override var read: Boolean = false + + override var last_page_read: Int = 0 + + override var date_fetch: Long = 0 + + override var date_upload: Long = 0 + + override var chapter_number: Float = 0f + + override var source_order: Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + + val chapter = other as Chapter + + return url == chapter.url + + } + + override fun hashCode(): Int { + return url.hashCode() + } + +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/History.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/History.java deleted file mode 100644 index 78d769c08..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/History.java +++ /dev/null @@ -1,58 +0,0 @@ -package eu.kanade.tachiyomi.data.database.models; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; - -import java.io.Serializable; - -import eu.kanade.tachiyomi.data.database.tables.HistoryTable; - -/** - * Object containing the history statistics of a chapter - */ -@StorIOSQLiteType(table = HistoryTable.TABLE) -public class History implements Serializable { - - /** - * Id of history object. - */ - @StorIOSQLiteColumn(name = HistoryTable.COL_ID, key = true) - public Long id; - - /** - * Chapter id of history object. - */ - @StorIOSQLiteColumn(name = HistoryTable.COL_CHAPTER_ID) - public long chapter_id; - - /** - * Last time chapter was read in time long format - */ - @StorIOSQLiteColumn(name = HistoryTable.COL_LAST_READ) - public long last_read; - - /** - * Total time chapter was read - todo not yet implemented - */ - @StorIOSQLiteColumn(name = HistoryTable.COL_TIME_READ) - public long time_read; - - /** - * Empty history constructor - */ - public History() { - } - - /** - * History constructor - * - * @param chapter chapter object - * @return history object - */ - public static History create(Chapter chapter) { - History history = new History(); - history.chapter_id = chapter.id; - return history; - } -} - diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/History.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/History.kt new file mode 100644 index 000000000..5d5c89c35 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/History.kt @@ -0,0 +1,44 @@ +package eu.kanade.tachiyomi.data.database.models + +import java.io.Serializable + +/** + * Object containing the history statistics of a chapter + */ +class History : Serializable { + + /** + * Id of history object. + */ + var id: Long? = null + + /** + * Chapter id of history object. + */ + var chapter_id: Long = 0 + + /** + * Last time chapter was read in time long format + */ + var last_read: Long = 0 + + /** + * Total time chapter was read - todo not yet implemented + */ + var time_read: Long = 0 + + companion object { + + /** + * History constructor + * + * @param chapter chapter object + * @return history object + */ + fun create(chapter: Chapter): History { + val history = History() + history.chapter_id = chapter.id!! + return history + } + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.java deleted file mode 100644 index 7068a4225..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.java +++ /dev/null @@ -1,213 +0,0 @@ -package eu.kanade.tachiyomi.data.database.models; - -import android.content.Context; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; - -import java.io.Serializable; - -import eu.kanade.tachiyomi.R; -import eu.kanade.tachiyomi.data.database.tables.MangaTable; -import eu.kanade.tachiyomi.util.UrlUtil; - -@StorIOSQLiteType(table = MangaTable.TABLE) -public class Manga implements Serializable { - - @StorIOSQLiteColumn(name = MangaTable.COL_ID, key = true) - public Long id; - - @StorIOSQLiteColumn(name = MangaTable.COL_SOURCE) - public int source; - - @StorIOSQLiteColumn(name = MangaTable.COL_URL) - public String url; - - @StorIOSQLiteColumn(name = MangaTable.COL_ARTIST) - public String artist; - - @StorIOSQLiteColumn(name = MangaTable.COL_AUTHOR) - public String author; - - @StorIOSQLiteColumn(name = MangaTable.COL_DESCRIPTION) - public String description; - - @StorIOSQLiteColumn(name = MangaTable.COL_GENRE) - public String genre; - - @StorIOSQLiteColumn(name = MangaTable.COL_TITLE) - public String title; - - @StorIOSQLiteColumn(name = MangaTable.COL_STATUS) - public int status; - - @StorIOSQLiteColumn(name = MangaTable.COL_THUMBNAIL_URL) - public String thumbnail_url; - - @StorIOSQLiteColumn(name = MangaTable.COL_FAVORITE) - public boolean favorite; - - @StorIOSQLiteColumn(name = MangaTable.COL_LAST_UPDATE) - public long last_update; - - @StorIOSQLiteColumn(name = MangaTable.COL_INITIALIZED) - public boolean initialized; - - @StorIOSQLiteColumn(name = MangaTable.COL_VIEWER) - public int viewer; - - @StorIOSQLiteColumn(name = MangaTable.COL_CHAPTER_FLAGS) - public int chapter_flags; - - public transient int unread; - - public transient int category; - - public static final int UNKNOWN = 0; - public static final int ONGOING = 1; - public static final int COMPLETED = 2; - public static final int LICENSED = 3; - - public static final int SORT_DESC = 0x00000000; - public static final int SORT_ASC = 0x00000001; - public static final int SORT_MASK = 0x00000001; - - // Generic filter that does not filter anything - public static final int SHOW_ALL = 0x00000000; - - public static final int SHOW_UNREAD = 0x00000002; - public static final int SHOW_READ = 0x00000004; - public static final int READ_MASK = 0x00000006; - - public static final int SHOW_DOWNLOADED = 0x00000008; - public static final int SHOW_NOT_DOWNLOADED = 0x00000010; - public static final int DOWNLOADED_MASK = 0x00000018; - - public static final int SORTING_SOURCE = 0x00000000; - public static final int SORTING_NUMBER = 0x00000100; - public static final int SORTING_MASK = 0x00000100; - - public static final int DISPLAY_NAME = 0x00000000; - public static final int DISPLAY_NUMBER = 0x00100000; - public static final int DISPLAY_MASK = 0x00100000; - - public Manga() {} - - public static Manga create(String pathUrl) { - Manga m = new Manga(); - m.url = pathUrl; - return m; - } - - public static Manga create(String pathUrl, int source) { - Manga m = new Manga(); - m.url = pathUrl; - m.source = source; - return m; - } - - public void setUrl(String url) { - this.url = UrlUtil.getPath(url); - } - - public void copyFrom(Manga other) { - if (other.title != null) - title = other.title; - - if (other.author != null) - author = other.author; - - if (other.artist != null) - artist = other.artist; - - if (other.url != null) - url = other.url; - - if (other.description != null) - description = other.description; - - if (other.genre != null) - genre = other.genre; - - if (other.thumbnail_url != null) - thumbnail_url = other.thumbnail_url; - - status = other.status; - - initialized = true; - } - - public String getStatus(Context context) { - switch (status) { - case ONGOING: - return context.getString(R.string.ongoing); - case COMPLETED: - return context.getString(R.string.completed); - case LICENSED: - return context.getString(R.string.licensed); - default: - return context.getString(R.string.unknown); - } - } - - public void setChapterOrder(int order) { - setFlags(order, SORT_MASK); - } - - public void setDisplayMode(int mode) { - setFlags(mode, DISPLAY_MASK); - } - - public void setReadFilter(int filter) { - setFlags(filter, READ_MASK); - } - - public void setDownloadedFilter(int filter) { - setFlags(filter, DOWNLOADED_MASK); - } - - public void setSorting(int sort) { - setFlags(sort, SORTING_MASK); - } - - private void setFlags(int flag, int mask) { - chapter_flags = (chapter_flags & ~mask) | (flag & mask); - } - - public boolean sortDescending() { - return (chapter_flags & SORT_MASK) == SORT_DESC; - } - - // Used to display the chapter's title one way or another - public int getDisplayMode() { - return chapter_flags & DISPLAY_MASK; - } - - public int getReadFilter() { - return chapter_flags & READ_MASK; - } - - public int getDownloadedFilter() { - return chapter_flags & DOWNLOADED_MASK; - } - - public int getSorting() { - return chapter_flags & SORTING_MASK; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Manga manga = (Manga) o; - - return url.equals(manga.url); - - } - - @Override - public int hashCode() { - return url.hashCode(); - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt new file mode 100644 index 000000000..45709b256 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt @@ -0,0 +1,131 @@ +package eu.kanade.tachiyomi.data.database.models + +import java.io.Serializable + +interface Manga : Serializable { + + var id: Long? + + var source: Int + + var url: String + + var title: String + + var artist: String? + + var author: String? + + var description: String? + + var genre: String? + + var status: Int + + var thumbnail_url: String? + + var favorite: Boolean + + var last_update: Long + + var initialized: Boolean + + var viewer: Int + + var chapter_flags: Int + + var unread: Int + + var category: Int + + fun copyFrom(other: Manga) { + if (other.author != null) + author = other.author + + if (other.artist != null) + artist = other.artist + + if (other.description != null) + description = other.description + + if (other.genre != null) + genre = other.genre + + if (other.thumbnail_url != null) + thumbnail_url = other.thumbnail_url + + status = other.status + + initialized = true + } + + fun setChapterOrder(order: Int) { + setFlags(order, SORT_MASK) + } + + private fun setFlags(flag: Int, mask: Int) { + chapter_flags = chapter_flags and mask.inv() or (flag and mask) + } + + fun sortDescending(): Boolean { + return chapter_flags and SORT_MASK == SORT_DESC + } + + // Used to display the chapter's title one way or another + var displayMode: Int + get() = chapter_flags and DISPLAY_MASK + set(mode) = setFlags(mode, DISPLAY_MASK) + + var readFilter: Int + get() = chapter_flags and READ_MASK + set(filter) = setFlags(filter, READ_MASK) + + var downloadedFilter: Int + get() = chapter_flags and DOWNLOADED_MASK + set(filter) = setFlags(filter, DOWNLOADED_MASK) + + var sorting: Int + get() = chapter_flags and SORTING_MASK + set(sort) = setFlags(sort, SORTING_MASK) + + companion object { + + const val UNKNOWN = 0 + const val ONGOING = 1 + const val COMPLETED = 2 + const val LICENSED = 3 + + const val SORT_DESC = 0x00000000 + const val SORT_ASC = 0x00000001 + const val SORT_MASK = 0x00000001 + + // Generic filter that does not filter anything + const val SHOW_ALL = 0x00000000 + + const val SHOW_UNREAD = 0x00000002 + const val SHOW_READ = 0x00000004 + const val READ_MASK = 0x00000006 + + const val SHOW_DOWNLOADED = 0x00000008 + const val SHOW_NOT_DOWNLOADED = 0x00000010 + const val DOWNLOADED_MASK = 0x00000018 + + const val SORTING_SOURCE = 0x00000000 + const val SORTING_NUMBER = 0x00000100 + const val SORTING_MASK = 0x00000100 + + const val DISPLAY_NAME = 0x00000000 + const val DISPLAY_NUMBER = 0x00100000 + const val DISPLAY_MASK = 0x00100000 + + fun create(source: Int): Manga = MangaImpl().apply { + this.source = source + } + + fun create(pathUrl: String, source: Int = 0): Manga = MangaImpl().apply { + url = pathUrl + this.source = source + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaCategory.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaCategory.java deleted file mode 100644 index 96230b54a..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaCategory.java +++ /dev/null @@ -1,29 +0,0 @@ -package eu.kanade.tachiyomi.data.database.models; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; - -import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable; - -@StorIOSQLiteType(table = MangaCategoryTable.TABLE) -public class MangaCategory { - - @StorIOSQLiteColumn(name = MangaCategoryTable.COL_ID, key = true) - public Long id; - - @StorIOSQLiteColumn(name = MangaCategoryTable.COL_MANGA_ID) - public long manga_id; - - @StorIOSQLiteColumn(name = MangaCategoryTable.COL_CATEGORY_ID) - public int category_id; - - public MangaCategory() {} - - public static MangaCategory create(Manga manga, Category category) { - MangaCategory mc = new MangaCategory(); - mc.manga_id = manga.id; - mc.category_id = category.id; - return mc; - } - -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaCategory.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaCategory.kt new file mode 100644 index 000000000..305d5ef9c --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaCategory.kt @@ -0,0 +1,21 @@ +package eu.kanade.tachiyomi.data.database.models + +class MangaCategory { + + var id: Long? = null + + var manga_id: Long = 0 + + var category_id: Int = 0 + + companion object { + + fun create(manga: Manga, category: Category): MangaCategory { + val mc = MangaCategory() + mc.manga_id = manga.id!! + mc.category_id = category.id!! + return mc + } + } + +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapter.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapter.java deleted file mode 100644 index 609a466e4..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapter.java +++ /dev/null @@ -1,12 +0,0 @@ -package eu.kanade.tachiyomi.data.database.models; - -public class MangaChapter { - - public Manga manga; - public Chapter chapter; - - public MangaChapter(Manga manga, Chapter chapter) { - this.manga = manga; - this.chapter = chapter; - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapter.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapter.kt new file mode 100644 index 000000000..bf584ba9c --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapter.kt @@ -0,0 +1,3 @@ +package eu.kanade.tachiyomi.data.database.models + +class MangaChapter(val manga: Manga, val chapter: Chapter) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapterHistory.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapterHistory.java deleted file mode 100644 index 67a59a404..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapterHistory.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.kanade.tachiyomi.data.database.models; - -/** - * Object containing manga, chapter and history - */ -public class MangaChapterHistory { - /** - * Object containing manga and chapter - */ - public MangaChapter mangaChapter; - - /** - * Object containing history - */ - public History history; - - /** - * MangaChapterHistory constructor - * - * @param mangaChapter object containing manga and chapter - * @param history object containing history - */ - public MangaChapterHistory(MangaChapter mangaChapter, History history) { - this.mangaChapter = mangaChapter; - this.history = history; - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapterHistory.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapterHistory.kt new file mode 100644 index 000000000..7fed020fc --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaChapterHistory.kt @@ -0,0 +1,10 @@ +package eu.kanade.tachiyomi.data.database.models + +/** + * Object containing manga, chapter and history + * + * @param manga object containing manga + * @param chapter object containing chater + * @param history object containing history + */ +class MangaChapterHistory(val manga: Manga, val chapter: Chapter, val history: History) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt new file mode 100644 index 000000000..000618a3a --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaImpl.kt @@ -0,0 +1,53 @@ +package eu.kanade.tachiyomi.data.database.models + +class MangaImpl : Manga { + + override var id: Long? = null + + override var source: Int = 0 + + override lateinit var url: String + + override lateinit var title: String + + override var artist: String? = null + + override var author: String? = null + + override var description: String? = null + + override var genre: String? = null + + override var status: Int = 0 + + override var thumbnail_url: String? = null + + override var favorite: Boolean = false + + override var last_update: Long = 0 + + override var initialized: Boolean = false + + override var viewer: Int = 0 + + override var chapter_flags: Int = 0 + + @Transient override var unread: Int = 0 + + @Transient override var category: Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + + val manga = other as Manga + + return url == manga.url + + } + + override fun hashCode(): Int { + return url.hashCode() + } + +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSync.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSync.java deleted file mode 100644 index 0e3beb98e..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSync.java +++ /dev/null @@ -1,78 +0,0 @@ -package eu.kanade.tachiyomi.data.database.models; - -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; -import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; - -import java.io.Serializable; - -import eu.kanade.tachiyomi.data.database.tables.MangaSyncTable; -import eu.kanade.tachiyomi.data.mangasync.MangaSyncService; - -@StorIOSQLiteType(table = MangaSyncTable.TABLE) -public class MangaSync implements Serializable { - - @StorIOSQLiteColumn(name = MangaSyncTable.COL_ID, key = true) - public Long id; - - @StorIOSQLiteColumn(name = MangaSyncTable.COL_MANGA_ID) - public long manga_id; - - @StorIOSQLiteColumn(name = MangaSyncTable.COL_SYNC_ID) - public int sync_id; - - @StorIOSQLiteColumn(name = MangaSyncTable.COL_REMOTE_ID) - public int remote_id; - - @StorIOSQLiteColumn(name = MangaSyncTable.COL_TITLE) - public String title; - - @StorIOSQLiteColumn(name = MangaSyncTable.COL_LAST_CHAPTER_READ) - public int last_chapter_read; - - @StorIOSQLiteColumn(name = MangaSyncTable.COL_TOTAL_CHAPTERS) - public int total_chapters; - - @StorIOSQLiteColumn(name = MangaSyncTable.COL_SCORE) - public float score; - - @StorIOSQLiteColumn(name = MangaSyncTable.COL_STATUS) - public int status; - - public boolean update; - - public static MangaSync create() { - return new MangaSync(); - } - - public static MangaSync create(MangaSyncService service) { - MangaSync mangasync = new MangaSync(); - mangasync.sync_id = service.getId(); - return mangasync; - } - - public void copyPersonalFrom(MangaSync other) { - last_chapter_read = other.last_chapter_read; - score = other.score; - status = other.status; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MangaSync mangaSync = (MangaSync) o; - - if (manga_id != mangaSync.manga_id) return false; - if (sync_id != mangaSync.sync_id) return false; - return remote_id == mangaSync.remote_id; - } - - @Override - public int hashCode() { - int result = (int) (manga_id ^ (manga_id >>> 32)); - result = 31 * result + sync_id; - result = 31 * result + remote_id; - return result; - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSync.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSync.kt new file mode 100644 index 000000000..c1e4664fd --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSync.kt @@ -0,0 +1,40 @@ +package eu.kanade.tachiyomi.data.database.models + +import java.io.Serializable + +interface MangaSync : Serializable { + + var id: Long? + + var manga_id: Long + + var sync_id: Int + + var remote_id: Int + + var title: String + + var last_chapter_read: Int + + var total_chapters: Int + + var score: Float + + var status: Int + + var update: Boolean + + fun copyPersonalFrom(other: MangaSync) { + last_chapter_read = other.last_chapter_read + score = other.score + status = other.status + } + + companion object { + + fun create(serviceId: Int): MangaSync = MangaSyncImpl().apply { + sync_id = serviceId + } + } + +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSyncImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSyncImpl.kt new file mode 100644 index 000000000..95d3bc4a7 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/MangaSyncImpl.kt @@ -0,0 +1,43 @@ +package eu.kanade.tachiyomi.data.database.models + +class MangaSyncImpl : MangaSync { + + override var id: Long? = null + + override var manga_id: Long = 0 + + override var sync_id: Int = 0 + + override var remote_id: Int = 0 + + override lateinit var title: String + + override var last_chapter_read: Int = 0 + + override var total_chapters: Int = 0 + + override var score: Float = 0f + + override var status: Int = 0 + + override var update: Boolean = false + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + + val mangaSync = other as MangaSync + + if (manga_id != mangaSync.manga_id) return false + if (sync_id != mangaSync.sync_id) return false + return remote_id == mangaSync.remote_id + } + + override fun hashCode(): Int { + var result = (manga_id xor manga_id.ushr(32)).toInt() + result = 31 * result + sync_id + result = 31 * result + remote_id + return result + } + +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/ChapterQueries.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/ChapterQueries.kt index 8251c04bb..f2aa6d2d5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/ChapterQueries.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/queries/ChapterQueries.kt @@ -1,6 +1,5 @@ package eu.kanade.tachiyomi.data.database.queries -import com.pushtorefresh.storio.sqlite.operations.get.PreparedGetObject import com.pushtorefresh.storio.sqlite.queries.Query import com.pushtorefresh.storio.sqlite.queries.RawQuery import eu.kanade.tachiyomi.data.database.DbProvider @@ -34,80 +33,6 @@ interface ChapterQueries : DbProvider { .withGetResolver(MangaChapterGetResolver.INSTANCE) .prepare() - fun getNextChapter(chapter: Chapter): PreparedGetObject { - // Add a delta to the chapter number, because binary decimal representation - // can retrieve the same chapter again - val chapterNumber = chapter.chapter_number + 0.00001 - - return db.get() - .`object`(Chapter::class.java) - .withQuery(Query.builder() - .table(ChapterTable.TABLE) - .where("${ChapterTable.COL_MANGA_ID} = ? AND " + - "${ChapterTable.COL_CHAPTER_NUMBER} > ? AND " + - "${ChapterTable.COL_CHAPTER_NUMBER} <= ?") - .whereArgs(chapter.manga_id, chapterNumber, chapterNumber + 1) - .orderBy(ChapterTable.COL_CHAPTER_NUMBER) - .limit(1) - .build()) - .prepare() - } - - fun getNextChapterBySource(chapter: Chapter) = db.get() - .`object`(Chapter::class.java) - .withQuery(Query.builder() - .table(ChapterTable.TABLE) - .where("""${ChapterTable.COL_MANGA_ID} = ? AND - ${ChapterTable.COL_SOURCE_ORDER} < ?""") - .whereArgs(chapter.manga_id, chapter.source_order) - .orderBy("${ChapterTable.COL_SOURCE_ORDER} DESC") - .limit(1) - .build()) - .prepare() - - fun getPreviousChapter(chapter: Chapter): PreparedGetObject { - // Add a delta to the chapter number, because binary decimal representation - // can retrieve the same chapter again - val chapterNumber = chapter.chapter_number - 0.00001 - - return db.get() - .`object`(Chapter::class.java) - .withQuery(Query.builder().table(ChapterTable.TABLE) - .where("${ChapterTable.COL_MANGA_ID} = ? AND " + - "${ChapterTable.COL_CHAPTER_NUMBER} < ? AND " + - "${ChapterTable.COL_CHAPTER_NUMBER} >= ?") - .whereArgs(chapter.manga_id, chapterNumber, chapterNumber - 1) - .orderBy("${ChapterTable.COL_CHAPTER_NUMBER} DESC") - .limit(1) - .build()) - .prepare() - } - - fun getPreviousChapterBySource(chapter: Chapter) = db.get() - .`object`(Chapter::class.java) - .withQuery(Query.builder() - .table(ChapterTable.TABLE) - .where("""${ChapterTable.COL_MANGA_ID} = ? AND - ${ChapterTable.COL_SOURCE_ORDER} > ?""") - .whereArgs(chapter.manga_id, chapter.source_order) - .orderBy(ChapterTable.COL_SOURCE_ORDER) - .limit(1) - .build()) - .prepare() - - fun getNextUnreadChapter(manga: Manga) = db.get() - .`object`(Chapter::class.java) - .withQuery(Query.builder() - .table(ChapterTable.TABLE) - .where("${ChapterTable.COL_MANGA_ID} = ? AND " + - "${ChapterTable.COL_READ} = ? AND " + - "${ChapterTable.COL_CHAPTER_NUMBER} >= ?") - .whereArgs(manga.id, 0, 0) - .orderBy(ChapterTable.COL_CHAPTER_NUMBER) - .limit(1) - .build()) - .prepare() - fun insertChapter(chapter: Chapter) = db.put().`object`(chapter).prepare() fun insertChapters(chapters: List) = db.put().objects(chapters).prepare() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterHistoryGetResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterHistoryGetResolver.kt index 6eecaf273..a87afe78c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterHistoryGetResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterHistoryGetResolver.kt @@ -5,7 +5,6 @@ import com.pushtorefresh.storio.sqlite.operations.get.DefaultGetResolver import eu.kanade.tachiyomi.data.database.mappers.ChapterGetResolver import eu.kanade.tachiyomi.data.database.mappers.HistoryGetResolver import eu.kanade.tachiyomi.data.database.mappers.MangaGetResolver -import eu.kanade.tachiyomi.data.database.models.MangaChapter import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory class MangaChapterHistoryGetResolver : DefaultGetResolver() { @@ -46,10 +45,7 @@ class MangaChapterHistoryGetResolver : DefaultGetResolver() manga.url = cursor.getString(cursor.getColumnIndex("mangaUrl")) chapter.id = history.chapter_id - // Create mangaChapter object - val mangaChapter = MangaChapter(manga, chapter) - // Return result - return MangaChapterHistory(mangaChapter, history) + return MangaChapterHistory(manga, chapter, history) } }