From 532a1b1abacde1a35e4c0bfcf9f083e59f6924b5 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 17 Dec 2021 12:30:41 -0500 Subject: [PATCH] Address some IDE warnings --- .../database/mappers/CategoryTypeMapping.kt | 8 ++--- .../database/mappers/ChapterTypeMapping.kt | 24 ++++++------- .../database/mappers/HistoryTypeMapping.kt | 8 ++--- .../mappers/MangaCategoryTypeMapping.kt | 6 ++-- .../data/database/mappers/MangaTypeMapping.kt | 34 +++++++++---------- .../data/database/mappers/TrackTypeMapping.kt | 26 +++++++------- .../resolvers/LibraryMangaGetResolver.kt | 4 +-- .../resolvers/MangaChapterGetResolver.kt | 2 +- .../MangaChapterHistoryGetResolver.kt | 2 +- .../SourceIdMangaCountGetResolver.kt | 4 +-- .../extension/util/ExtensionInstaller.kt | 4 +-- 11 files changed, 61 insertions(+), 61 deletions(-) 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 b08dd31dc0..858a9e4fdc 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 c663d2f2f3..52a353f04f 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 d5cce7312a..896881cbd7 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 f5e5843337..93950fbf6c 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 7392a170ac..3d7c34f4d7 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 89f4a4d300..ab94778625 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 aac8ead3e8..998c141fb9 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 edd6a8983d..a6305b1bae 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 a87afe78c5..dbad8246eb 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 ace4cc252c..3e023dd438 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 370670887a..14fa145048 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))