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 b08dd31dc..858a9e4fd 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 @@ -47,10 +47,10 @@ class CategoryPutResolver : DefaultPutResolver() { class CategoryGetResolver : DefaultGetResolver() { 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)) - flags = cursor.getInt(cursor.getColumnIndex(COL_FLAGS)) + id = cursor.getInt(cursor.getColumnIndexOrThrow(COL_ID)) + name = cursor.getString(cursor.getColumnIndexOrThrow(COL_NAME)) + order = cursor.getInt(cursor.getColumnIndexOrThrow(COL_ORDER)) + flags = cursor.getInt(cursor.getColumnIndexOrThrow(COL_FLAGS)) } } 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 c663d2f2f..52a353f04 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 @@ -63,18 +63,18 @@ class ChapterPutResolver : DefaultPutResolver() { class ChapterGetResolver : DefaultGetResolver() { 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)) - name = cursor.getString(cursor.getColumnIndex(COL_NAME)) - scanlator = cursor.getString(cursor.getColumnIndex(COL_SCANLATOR)) - read = cursor.getInt(cursor.getColumnIndex(COL_READ)) == 1 - bookmark = cursor.getInt(cursor.getColumnIndex(COL_BOOKMARK)) == 1 - date_fetch = cursor.getLong(cursor.getColumnIndex(COL_DATE_FETCH)) - date_upload = cursor.getLong(cursor.getColumnIndex(COL_DATE_UPLOAD)) - last_page_read = cursor.getInt(cursor.getColumnIndex(COL_LAST_PAGE_READ)) - chapter_number = cursor.getFloat(cursor.getColumnIndex(COL_CHAPTER_NUMBER)) - source_order = cursor.getInt(cursor.getColumnIndex(COL_SOURCE_ORDER)) + id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_ID)) + manga_id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_MANGA_ID)) + url = cursor.getString(cursor.getColumnIndexOrThrow(COL_URL)) + name = cursor.getString(cursor.getColumnIndexOrThrow(COL_NAME)) + scanlator = cursor.getString(cursor.getColumnIndexOrThrow(COL_SCANLATOR)) + read = cursor.getInt(cursor.getColumnIndexOrThrow(COL_READ)) == 1 + bookmark = cursor.getInt(cursor.getColumnIndexOrThrow(COL_BOOKMARK)) == 1 + date_fetch = cursor.getLong(cursor.getColumnIndexOrThrow(COL_DATE_FETCH)) + date_upload = cursor.getLong(cursor.getColumnIndexOrThrow(COL_DATE_UPLOAD)) + last_page_read = cursor.getInt(cursor.getColumnIndexOrThrow(COL_LAST_PAGE_READ)) + chapter_number = cursor.getFloat(cursor.getColumnIndexOrThrow(COL_CHAPTER_NUMBER)) + source_order = cursor.getInt(cursor.getColumnIndexOrThrow(COL_SOURCE_ORDER)) } } 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 d5cce7312..896881cbd 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 @@ -47,10 +47,10 @@ open class HistoryPutResolver : DefaultPutResolver() { class HistoryGetResolver : DefaultGetResolver() { override fun mapFromCursor(cursor: Cursor): History = HistoryImpl().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)) - time_read = cursor.getLong(cursor.getColumnIndex(COL_TIME_READ)) + id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_ID)) + chapter_id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_CHAPTER_ID)) + last_read = cursor.getLong(cursor.getColumnIndexOrThrow(COL_LAST_READ)) + time_read = cursor.getLong(cursor.getColumnIndexOrThrow(COL_TIME_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 f5e584333..93950fbf6 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 @@ -44,9 +44,9 @@ class MangaCategoryPutResolver : DefaultPutResolver() { class MangaCategoryGetResolver : DefaultGetResolver() { 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)) + id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_ID)) + manga_id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_MANGA_ID)) + category_id = cursor.getInt(cursor.getColumnIndexOrThrow(COL_CATEGORY_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 7392a170a..3d7c34f4d 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 @@ -72,23 +72,23 @@ class MangaPutResolver : DefaultPutResolver() { interface BaseMangaGetResolver { fun mapBaseFromCursor(manga: Manga, cursor: Cursor) = manga.apply { - id = cursor.getLong(cursor.getColumnIndex(COL_ID)) - source = cursor.getLong(cursor.getColumnIndex(COL_SOURCE)) - url = cursor.getString(cursor.getColumnIndex(COL_URL)) - artist = cursor.getString(cursor.getColumnIndex(COL_ARTIST)) - author = cursor.getString(cursor.getColumnIndex(COL_AUTHOR)) - description = cursor.getString(cursor.getColumnIndex(COL_DESCRIPTION)) - genre = cursor.getString(cursor.getColumnIndex(COL_GENRE)) - title = cursor.getString(cursor.getColumnIndex(COL_TITLE)) - status = cursor.getInt(cursor.getColumnIndex(COL_STATUS)) - thumbnail_url = cursor.getString(cursor.getColumnIndex(COL_THUMBNAIL_URL)) - favorite = cursor.getInt(cursor.getColumnIndex(COL_FAVORITE)) == 1 - last_update = cursor.getLong(cursor.getColumnIndex(COL_LAST_UPDATE)) - initialized = cursor.getInt(cursor.getColumnIndex(COL_INITIALIZED)) == 1 - viewer_flags = cursor.getInt(cursor.getColumnIndex(COL_VIEWER)) - chapter_flags = cursor.getInt(cursor.getColumnIndex(COL_CHAPTER_FLAGS)) - cover_last_modified = cursor.getLong(cursor.getColumnIndex(COL_COVER_LAST_MODIFIED)) - date_added = cursor.getLong(cursor.getColumnIndex(COL_DATE_ADDED)) + id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_ID)) + source = cursor.getLong(cursor.getColumnIndexOrThrow(COL_SOURCE)) + url = cursor.getString(cursor.getColumnIndexOrThrow(COL_URL)) + artist = cursor.getString(cursor.getColumnIndexOrThrow(COL_ARTIST)) + author = cursor.getString(cursor.getColumnIndexOrThrow(COL_AUTHOR)) + description = cursor.getString(cursor.getColumnIndexOrThrow(COL_DESCRIPTION)) + genre = cursor.getString(cursor.getColumnIndexOrThrow(COL_GENRE)) + title = cursor.getString(cursor.getColumnIndexOrThrow(COL_TITLE)) + status = cursor.getInt(cursor.getColumnIndexOrThrow(COL_STATUS)) + thumbnail_url = cursor.getString(cursor.getColumnIndexOrThrow(COL_THUMBNAIL_URL)) + favorite = cursor.getInt(cursor.getColumnIndexOrThrow(COL_FAVORITE)) == 1 + last_update = cursor.getLong(cursor.getColumnIndexOrThrow(COL_LAST_UPDATE)) + initialized = cursor.getInt(cursor.getColumnIndexOrThrow(COL_INITIALIZED)) == 1 + viewer_flags = cursor.getInt(cursor.getColumnIndexOrThrow(COL_VIEWER)) + chapter_flags = cursor.getInt(cursor.getColumnIndexOrThrow(COL_CHAPTER_FLAGS)) + cover_last_modified = cursor.getLong(cursor.getColumnIndexOrThrow(COL_COVER_LAST_MODIFIED)) + date_added = cursor.getLong(cursor.getColumnIndexOrThrow(COL_DATE_ADDED)) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/TrackTypeMapping.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/TrackTypeMapping.kt index 89f4a4d30..ab9477862 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/TrackTypeMapping.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/mappers/TrackTypeMapping.kt @@ -65,19 +65,19 @@ class TrackPutResolver : DefaultPutResolver() { class TrackGetResolver : DefaultGetResolver() { override fun mapFromCursor(cursor: Cursor): Track = TrackImpl().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)) - media_id = cursor.getInt(cursor.getColumnIndex(COL_MEDIA_ID)) - library_id = cursor.getLong(cursor.getColumnIndex(COL_LIBRARY_ID)) - title = cursor.getString(cursor.getColumnIndex(COL_TITLE)) - last_chapter_read = cursor.getFloat(cursor.getColumnIndex(COL_LAST_CHAPTER_READ)) - total_chapters = cursor.getInt(cursor.getColumnIndex(COL_TOTAL_CHAPTERS)) - status = cursor.getInt(cursor.getColumnIndex(COL_STATUS)) - score = cursor.getFloat(cursor.getColumnIndex(COL_SCORE)) - tracking_url = cursor.getString(cursor.getColumnIndex(COL_TRACKING_URL)) - started_reading_date = cursor.getLong(cursor.getColumnIndex(COL_START_DATE)) - finished_reading_date = cursor.getLong(cursor.getColumnIndex(COL_FINISH_DATE)) + id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_ID)) + manga_id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_MANGA_ID)) + sync_id = cursor.getInt(cursor.getColumnIndexOrThrow(COL_SYNC_ID)) + media_id = cursor.getInt(cursor.getColumnIndexOrThrow(COL_MEDIA_ID)) + library_id = cursor.getLong(cursor.getColumnIndexOrThrow(COL_LIBRARY_ID)) + title = cursor.getString(cursor.getColumnIndexOrThrow(COL_TITLE)) + last_chapter_read = cursor.getFloat(cursor.getColumnIndexOrThrow(COL_LAST_CHAPTER_READ)) + total_chapters = cursor.getInt(cursor.getColumnIndexOrThrow(COL_TOTAL_CHAPTERS)) + status = cursor.getInt(cursor.getColumnIndexOrThrow(COL_STATUS)) + score = cursor.getFloat(cursor.getColumnIndexOrThrow(COL_SCORE)) + tracking_url = cursor.getString(cursor.getColumnIndexOrThrow(COL_TRACKING_URL)) + started_reading_date = cursor.getLong(cursor.getColumnIndexOrThrow(COL_START_DATE)) + finished_reading_date = cursor.getLong(cursor.getColumnIndexOrThrow(COL_FINISH_DATE)) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.kt index aac8ead3e..998c141fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/LibraryMangaGetResolver.kt @@ -16,8 +16,8 @@ class LibraryMangaGetResolver : DefaultGetResolver(), BaseMangaGet val manga = LibraryManga() mapBaseFromCursor(manga, cursor) - manga.unread = cursor.getInt(cursor.getColumnIndex(MangaTable.COL_UNREAD)) - manga.category = cursor.getInt(cursor.getColumnIndex(MangaTable.COL_CATEGORY)) + manga.unread = cursor.getInt(cursor.getColumnIndexOrThrow(MangaTable.COL_UNREAD)) + manga.category = cursor.getInt(cursor.getColumnIndexOrThrow(MangaTable.COL_CATEGORY)) return manga } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.kt index edd6a8983..a6305b1ba 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/MangaChapterGetResolver.kt @@ -20,7 +20,7 @@ class MangaChapterGetResolver : DefaultGetResolver() { val manga = mangaGetResolver.mapFromCursor(cursor) val chapter = chapterGetResolver.mapFromCursor(cursor) manga.id = chapter.manga_id - manga.url = cursor.getString(cursor.getColumnIndex("mangaUrl")) + manga.url = cursor.getString(cursor.getColumnIndexOrThrow("mangaUrl")) return MangaChapter(manga, chapter) } 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 a87afe78c..dbad8246e 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 @@ -42,7 +42,7 @@ class MangaChapterHistoryGetResolver : DefaultGetResolver() // Make certain column conflicts are dealt with manga.id = chapter.manga_id - manga.url = cursor.getString(cursor.getColumnIndex("mangaUrl")) + manga.url = cursor.getString(cursor.getColumnIndexOrThrow("mangaUrl")) chapter.id = history.chapter_id // Return result diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/SourceIdMangaCountGetResolver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/SourceIdMangaCountGetResolver.kt index ace4cc252..3e023dd43 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/SourceIdMangaCountGetResolver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/resolvers/SourceIdMangaCountGetResolver.kt @@ -15,8 +15,8 @@ class SourceIdMangaCountGetResolver : DefaultGetResolver() { @SuppressLint("Range") override fun mapFromCursor(cursor: Cursor): SourceIdMangaCount { - val sourceID = cursor.getLong(cursor.getColumnIndex(MangaTable.COL_SOURCE)) - val count = cursor.getInt(cursor.getColumnIndex(COL_COUNT)) + val sourceID = cursor.getLong(cursor.getColumnIndexOrThrow(MangaTable.COL_SOURCE)) + val count = cursor.getInt(cursor.getColumnIndexOrThrow(COL_COUNT)) return SourceIdMangaCount(sourceID, count) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt index 370670887..14fa14504 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionInstaller.kt @@ -110,7 +110,7 @@ internal class ExtensionInstaller(private val context: Context) { .map { downloadManager.query(query).use { cursor -> cursor.moveToFirst() - cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) + cursor.getInt(cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS)) } } // Ignore duplicate results @@ -249,7 +249,7 @@ internal class ExtensionInstaller(private val context: Context) { downloadManager.query(query).use { cursor -> if (cursor.moveToFirst()) { val localUri = cursor.getString( - cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI) + cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_LOCAL_URI) ).removePrefix(FILE_SCHEME) installApk(id, File(localUri).getUriCompat(context))