From 87661eb85a54fc938defe4f5e1d046b34585f08b Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 24 May 2022 18:16:07 -0400 Subject: [PATCH] Minor cleanup --- .../data/backup/full/models/BackupTracking.kt | 3 ++- .../tachiyomi/data/database/models/TrackImpl.kt | 12 +++++++----- .../data/track/mangaupdates/MangaUpdatesApi.kt | 4 ++-- .../kanade/tachiyomi/data/track/model/TrackSearch.kt | 12 +++++++----- .../java/eu/kanade/tachiyomi/source/LocalSource.kt | 4 ---- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupTracking.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupTracking.kt index fbd6a55003..5e45f86635 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupTracking.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/full/models/BackupTracking.kt @@ -12,7 +12,8 @@ data class BackupTracking( @ProtoNumber(1) var syncId: Int, // LibraryId is not null in 1.x @ProtoNumber(2) var libraryId: Long, - @Deprecated("Use mediaId instead", level = DeprecationLevel.WARNING) @ProtoNumber(3) var mediaIdInt: Int = 0, + @Deprecated("Use mediaId instead", level = DeprecationLevel.WARNING) @ProtoNumber(3) + var mediaIdInt: Int = 0, // trackingUrl is called mediaUrl in 1.x @ProtoNumber(4) var trackingUrl: String = "", @ProtoNumber(5) var title: String = "", diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt index b447ef56af..f3c0b90149 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt @@ -30,19 +30,21 @@ class TrackImpl : Track { override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || javaClass != other.javaClass) return false + if (javaClass != other?.javaClass) return false - other as Track + other as TrackImpl if (manga_id != other.manga_id) return false if (sync_id != other.sync_id) return false - return media_id == other.media_id + if (media_id != other.media_id) return false + + return true } override fun hashCode(): Int { - var result = (manga_id xor manga_id.ushr(32)).toInt() + var result = manga_id.hashCode() result = 31 * result + sync_id - result = 31 * result + media_id.toInt() + result = 31 * result + media_id.hashCode() return result } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdatesApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdatesApi.kt index d23b308a6a..1cc28b7a41 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdatesApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/mangaupdates/MangaUpdatesApi.kt @@ -34,11 +34,11 @@ class MangaUpdatesApi( interceptor: MangaUpdatesInterceptor, private val client: OkHttpClient, ) { + private val json: Json by injectLazy() + private val baseUrl = "https://api.mangaupdates.com" private val contentType = "application/vnd.api+json".toMediaType() - private val json by injectLazy() - private val authClient by lazy { client.newBuilder() .addInterceptor(interceptor) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/model/TrackSearch.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/model/TrackSearch.kt index 1dab62211e..a043610d8b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/model/TrackSearch.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/model/TrackSearch.kt @@ -42,19 +42,21 @@ class TrackSearch : Track { override fun equals(other: Any?): Boolean { if (this === other) return true - if (other == null || javaClass != other.javaClass) return false + if (javaClass != other?.javaClass) return false - other as Track + other as TrackSearch if (manga_id != other.manga_id) return false if (sync_id != other.sync_id) return false - return media_id == other.media_id + if (media_id != other.media_id) return false + + return true } override fun hashCode(): Int { - var result = (manga_id xor manga_id.ushr(32)).toInt() + var result = manga_id.hashCode() result = 31 * result + sync_id - result = 31 * result + media_id.toInt() + result = 31 * result + media_id.hashCode() return result } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index a4ecd52d6b..a03e8d6fa3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.source import android.content.Context -import androidx.core.net.toUri import com.github.junrar.Archive import com.hippo.unifile.UniFile import eu.kanade.tachiyomi.R @@ -20,7 +19,6 @@ import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.EpubFile import eu.kanade.tachiyomi.util.system.ImageUtil -import eu.kanade.tachiyomi.util.system.logcat import kotlinx.coroutines.runBlocking import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject @@ -29,7 +27,6 @@ import kotlinx.serialization.json.decodeFromStream import kotlinx.serialization.json.intOrNull import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonPrimitive -import logcat.LogPriority import rx.Observable import tachiyomi.source.model.ChapterInfo import tachiyomi.source.model.MangaInfo @@ -359,7 +356,6 @@ class LocalSource( var coverFile = getCoverFile(manga.url, baseDirsFiles) if (coverFile == null) { coverFile = File(mangaDir.absolutePath, DEFAULT_COVER_NAME) - } // It might not exist at this point