From 2cd87332125e8b4c703d2b8f47cfc0d540118a97 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Sat, 28 Aug 2021 22:37:45 +0800 Subject: [PATCH] change Track.last_chapter_read to Float (#5802) each TrackService can convert it to Int if decimal chapters are not supported --- .../data/backup/full/models/BackupTracking.kt | 6 ++---- .../legacy/serializer/TrackTypeSerializer.kt | 3 ++- .../tachiyomi/data/database/DbOpenCallback.kt | 8 +++++++- .../data/database/mappers/TrackTypeMapping.kt | 2 +- .../tachiyomi/data/database/models/Track.kt | 2 +- .../tachiyomi/data/database/models/TrackImpl.kt | 2 +- .../data/database/tables/TrackTable.kt | 17 ++++++++++++++++- .../tachiyomi/data/track/anilist/AnilistApi.kt | 4 ++-- .../data/track/anilist/AnilistModels.kt | 2 +- .../tachiyomi/data/track/bangumi/BangumiApi.kt | 4 ++-- .../tachiyomi/data/track/kitsu/KitsuApi.kt | 4 ++-- .../tachiyomi/data/track/kitsu/KitsuModels.kt | 2 +- .../tachiyomi/data/track/komga/KomgaApi.kt | 4 ++-- .../tachiyomi/data/track/model/TrackSearch.kt | 2 +- .../data/track/myanimelist/MyAnimeListApi.kt | 5 +++-- .../data/track/shikimori/ShikimoriApi.kt | 5 +++-- .../kanade/tachiyomi/ui/manga/MangaPresenter.kt | 8 ++++---- .../ui/manga/track/SetTrackChaptersDialog.kt | 2 +- .../tachiyomi/ui/manga/track/TrackHolder.kt | 2 +- .../tachiyomi/ui/reader/ReaderPresenter.kt | 2 +- .../tachiyomi/util/chapter/ChapterTrackSync.kt | 6 +++++- .../kanade/tachiyomi/data/backup/BackupTest.kt | 8 ++++---- 22 files changed, 63 insertions(+), 37 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 270adf2bfa..9a8c2ea455 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 @@ -32,8 +32,7 @@ data class BackupTracking( media_id = this@BackupTracking.mediaId library_id = this@BackupTracking.libraryId title = this@BackupTracking.title - // convert from float to int because of 1.x types - last_chapter_read = this@BackupTracking.lastChapterRead.toInt() + last_chapter_read = this@BackupTracking.lastChapterRead total_chapters = this@BackupTracking.totalChapters score = this@BackupTracking.score status = this@BackupTracking.status @@ -51,8 +50,7 @@ data class BackupTracking( // forced not null so its compatible with 1.x backup system libraryId = track.library_id!!, title = track.title, - // convert to float for 1.x - lastChapterRead = track.last_chapter_read.toFloat(), + lastChapterRead = track.last_chapter_read, totalChapters = track.total_chapters, score = track.score, status = track.status, diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/legacy/serializer/TrackTypeSerializer.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/legacy/serializer/TrackTypeSerializer.kt index 8a08f79ffc..1c259dd066 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/legacy/serializer/TrackTypeSerializer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/legacy/serializer/TrackTypeSerializer.kt @@ -10,6 +10,7 @@ import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.json.JsonDecoder import kotlinx.serialization.json.JsonEncoder import kotlinx.serialization.json.buildJsonObject +import kotlinx.serialization.json.float import kotlinx.serialization.json.int import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive @@ -46,7 +47,7 @@ open class TrackBaseSerializer : KSerializer { sync_id = jsonObject[SYNC]!!.jsonPrimitive.int media_id = jsonObject[MEDIA]!!.jsonPrimitive.int library_id = jsonObject[LIBRARY]!!.jsonPrimitive.long - last_chapter_read = jsonObject[LAST_READ]!!.jsonPrimitive.int + last_chapter_read = jsonObject[LAST_READ]!!.jsonPrimitive.float tracking_url = jsonObject[TRACKING_URL]!!.jsonPrimitive.content } as T } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt index de2300af46..9a7d7dd4f4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/DbOpenCallback.kt @@ -20,7 +20,7 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) { /** * Version of the database. */ - const val DATABASE_VERSION = 12 + const val DATABASE_VERSION = 13 } override fun onCreate(db: SupportSQLiteDatabase) = with(db) { @@ -85,6 +85,12 @@ class DbOpenCallback : SupportSQLiteOpenHelper.Callback(DATABASE_VERSION) { if (oldVersion < 12) { db.execSQL(MangaTable.addNextUpdateCol) } + if (oldVersion < 13) { + db.execSQL(TrackTable.renameTableToTemp) + db.execSQL(TrackTable.createTableQuery) + db.execSQL(TrackTable.insertFromTempTable) + db.execSQL(TrackTable.dropTempTable) + } } override fun onConfigure(db: SupportSQLiteDatabase) { 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 1ab6f811c2..89f4a4d300 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 @@ -71,7 +71,7 @@ class TrackGetResolver : DefaultGetResolver() { 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.getInt(cursor.getColumnIndex(COL_LAST_CHAPTER_READ)) + 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)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt index 0f3815c544..b577451af5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt @@ -16,7 +16,7 @@ interface Track : Serializable { var title: String - var last_chapter_read: Int + var last_chapter_read: Float var total_chapters: Int 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 6f5991133c..082769b2d6 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 @@ -14,7 +14,7 @@ class TrackImpl : Track { override lateinit var title: String - override var last_chapter_read: Int = 0 + override var last_chapter_read: Float = 0F override var total_chapters: Int = 0 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/TrackTable.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/TrackTable.kt index c8dff441a4..c3b2cff480 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/TrackTable.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/TrackTable.kt @@ -39,7 +39,7 @@ object TrackTable { $COL_MEDIA_ID INTEGER NOT NULL, $COL_LIBRARY_ID INTEGER, $COL_TITLE TEXT NOT NULL, - $COL_LAST_CHAPTER_READ INTEGER NOT NULL, + $COL_LAST_CHAPTER_READ REAL NOT NULL, $COL_TOTAL_CHAPTERS INTEGER NOT NULL, $COL_STATUS INTEGER NOT NULL, $COL_SCORE FLOAT NOT NULL, @@ -62,4 +62,19 @@ object TrackTable { val addFinishDate: String get() = "ALTER TABLE $TABLE ADD COLUMN $COL_FINISH_DATE LONG NOT NULL DEFAULT 0" + + val renameTableToTemp: String + get() = + "ALTER TABLE $TABLE RENAME TO ${TABLE}_tmp" + + val insertFromTempTable: String + get() = + """ + |INSERT INTO $TABLE($COL_ID,$COL_MANGA_ID,$COL_SYNC_ID,$COL_MEDIA_ID,$COL_LIBRARY_ID,$COL_TITLE,$COL_LAST_CHAPTER_READ,$COL_TOTAL_CHAPTERS,$COL_STATUS,$COL_SCORE,$COL_TRACKING_URL,$COL_START_DATE,$COL_FINISH_DATE) + |SELECT $COL_ID,$COL_MANGA_ID,$COL_SYNC_ID,$COL_MEDIA_ID,$COL_LIBRARY_ID,$COL_TITLE,$COL_LAST_CHAPTER_READ,$COL_TOTAL_CHAPTERS,$COL_STATUS,$COL_SCORE,$COL_TRACKING_URL,$COL_START_DATE,$COL_FINISH_DATE + |FROM ${TABLE}_tmp + """.trimMargin() + + val dropTempTable: String + get() = "DROP TABLE ${TABLE}_tmp" } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt index 0147dbb542..06d4a6e341 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistApi.kt @@ -48,7 +48,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { put("query", query) putJsonObject("variables") { put("mangaId", track.media_id) - put("progress", track.last_chapter_read) + put("progress", track.last_chapter_read.toInt()) put("status", track.toAnilistStatus()) } } @@ -89,7 +89,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) { put("query", query) putJsonObject("variables") { put("listId", track.library_id) - put("progress", track.last_chapter_read) + put("progress", track.last_chapter_read.toInt()) put("status", track.toAnilistStatus()) put("score", track.score.toInt()) put("startedAt", createDate(track.started_reading_date)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt index 2d97583448..c85d53f625 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/AnilistModels.kt @@ -56,7 +56,7 @@ data class ALUserManga( score = score_raw.toFloat() started_reading_date = start_date_fuzzy finished_reading_date = completed_date_fuzzy - last_chapter_read = chapters_read + last_chapter_read = chapters_read.toFloat() library_id = this@ALUserManga.library_id total_chapters = manga.total_chapters } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt index 3c958936df..a2c1f22b29 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/BangumiApi.kt @@ -55,7 +55,7 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept // chapter update val body = FormBody.Builder() - .add("watched_eps", track.last_chapter_read.toString()) + .add("watched_eps", track.last_chapter_read.toInt().toString()) .build() authClient.newCall( POST( @@ -143,7 +143,7 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept } else { json.decodeFromString(responseBody).let { track.status = it.status?.id!! - track.last_chapter_read = it.ep_status!! + track.last_chapter_read = it.ep_status!!.toFloat() track.score = it.rating!! track } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt index 71c655798b..4b6710239f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuApi.kt @@ -36,7 +36,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) put("type", "libraryEntries") putJsonObject("attributes") { put("status", track.toKitsuStatus()) - put("progress", track.last_chapter_read) + put("progress", track.last_chapter_read.toInt()) } putJsonObject("relationships") { putJsonObject("user") { @@ -82,7 +82,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor) put("id", track.media_id) putJsonObject("attributes") { put("status", track.toKitsuStatus()) - put("progress", track.last_chapter_read) + put("progress", track.last_chapter_read.toInt()) put("ratingTwenty", track.toKitsuScore()) put("startedAt", KitsuDateHelper.convert(track.started_reading_date)) put("finishedAt", KitsuDateHelper.convert(track.finished_reading_date)) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuModels.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuModels.kt index d5ec925414..f844660250 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuModels.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/KitsuModels.kt @@ -79,7 +79,7 @@ class KitsuLibManga(obj: JsonObject, manga: JsonObject) { finished_reading_date = KitsuDateHelper.parse(finishedAt) status = toTrackStatus() score = ratingTwenty?.let { it.toInt() / 2f } ?: 0f - last_chapter_read = progress + last_chapter_read = progress.toFloat() } private fun toTrackStatus() = when (status) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/KomgaApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/KomgaApi.kt index c901580c3e..d59efdec3e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/KomgaApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/KomgaApi.kt @@ -51,7 +51,7 @@ class KomgaApi(private val client: OkHttpClient) { progress.booksReadCount -> Komga.COMPLETED else -> Komga.READING } - last_chapter_read = progress.lastReadContinuousIndex + last_chapter_read = progress.lastReadContinuousIndex.toFloat() } } catch (e: Exception) { Timber.w(e, "Could not get item: $url") @@ -60,7 +60,7 @@ class KomgaApi(private val client: OkHttpClient) { } suspend fun updateProgress(track: Track): Track { - val progress = ReadProgressUpdateDto(track.last_chapter_read) + val progress = ReadProgressUpdateDto(track.last_chapter_read.toInt()) val payload = json.encodeToString(progress) client.newCall( Request.Builder() 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 9035f55502..90c689b0d4 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 @@ -16,7 +16,7 @@ class TrackSearch : Track { override lateinit var title: String - override var last_chapter_read: Int = 0 + override var last_chapter_read: Float = 0F override var total_chapters: Int = 0 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt index 3130ca5441..ba1141231b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListApi.kt @@ -16,6 +16,7 @@ import kotlinx.coroutines.awaitAll import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.boolean import kotlinx.serialization.json.contentOrNull +import kotlinx.serialization.json.float import kotlinx.serialization.json.int import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonObject @@ -117,7 +118,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI .add("status", track.toMyAnimeListStatus() ?: "reading") .add("is_rereading", (track.status == MyAnimeList.REREADING).toString()) .add("score", track.score.toString()) - .add("num_chapters_read", track.last_chapter_read.toString()) + .add("num_chapters_read", track.last_chapter_read.toInt().toString()) convertToIsoDate(track.started_reading_date)?.let { formBodyBuilder.add("start_date", it) } @@ -205,7 +206,7 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI return track.apply { val isRereading = obj["is_rereading"]!!.jsonPrimitive.boolean status = if (isRereading) MyAnimeList.REREADING else getStatus(obj["status"]!!.jsonPrimitive.content) - last_chapter_read = obj["num_chapters_read"]!!.jsonPrimitive.int + last_chapter_read = obj["num_chapters_read"]!!.jsonPrimitive.float score = obj["score"]!!.jsonPrimitive.int.toFloat() obj["start_date"]?.let { started_reading_date = parseDate(it.jsonPrimitive.content) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt index 19c61d6f6a..efde7c7eb0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/ShikimoriApi.kt @@ -15,6 +15,7 @@ import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.contentOrNull +import kotlinx.serialization.json.float import kotlinx.serialization.json.int import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive @@ -35,7 +36,7 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter put("user_id", user_id) put("target_id", track.media_id) put("target_type", "Manga") - put("chapters", track.last_chapter_read) + put("chapters", track.last_chapter_read.toInt()) put("score", track.score.toInt()) put("status", track.toShikimoriStatus()) } @@ -89,7 +90,7 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter title = mangas["name"]!!.jsonPrimitive.content media_id = obj["id"]!!.jsonPrimitive.int total_chapters = mangas["chapters"]!!.jsonPrimitive.int - last_chapter_read = obj["chapters"]!!.jsonPrimitive.int + last_chapter_read = obj["chapters"]!!.jsonPrimitive.float score = (obj["score"]!!.jsonPrimitive.int).toFloat() status = toTrackStatus(obj["status"]!!.jsonPrimitive.content) tracking_url = baseUrl + mangas["url"]!!.jsonPrimitive.content diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index 116a51d7f1..472f8d6e23 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -878,7 +878,7 @@ class MangaPresenter( val track = item.track!! track.status = item.service.getStatusList()[index] if (track.status == item.service.getCompletionStatus() && track.total_chapters != 0) { - track.last_chapter_read = track.total_chapters + track.last_chapter_read = track.total_chapters.toFloat() } updateRemote(track, item.service) } @@ -891,11 +891,11 @@ class MangaPresenter( fun setTrackerLastChapterRead(item: TrackItem, chapterNumber: Int) { val track = item.track!! - if (track.last_chapter_read == 0 && track.last_chapter_read < chapterNumber && track.status != item.service.getRereadingStatus()) { + if (track.last_chapter_read == 0F && track.last_chapter_read < chapterNumber && track.status != item.service.getRereadingStatus()) { track.status = item.service.getReadingStatus() } - track.last_chapter_read = chapterNumber - if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) { + track.last_chapter_read = chapterNumber.toFloat() + if (track.total_chapters != 0 && track.last_chapter_read.toInt() == track.total_chapters) { track.status = item.service.getCompletionStatus() } updateRemote(track, item.service) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt index e5c25db2ba..67efe8ea47 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/SetTrackChaptersDialog.kt @@ -41,7 +41,7 @@ class SetTrackChaptersDialog : DialogController val np = pickerView.chaptersPicker // Set initial value - np.value = item.track?.last_chapter_read ?: 0 + np.value = item.track?.last_chapter_read?.toInt() ?: 0 // Enforce maximum value if tracker has total number of chapters set if (item.track != null && item.track.total_chapters > 0) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt index 1419de13d9..8400ed4058 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackHolder.kt @@ -55,7 +55,7 @@ class TrackHolder(private val binding: TrackItemBinding, adapter: TrackAdapter) listener.onOpenInBrowserClick(bindingAdapterPosition) } binding.trackTitle.text = track.title - binding.trackChapters.text = track.last_chapter_read.toString() + binding.trackChapters.text = track.last_chapter_read.toInt().toString() if (track.total_chapters > 0) { binding.trackChapters.text = "${binding.trackChapters.text} / ${track.total_chapters}" } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 377bf542fc..26355daa4d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -698,7 +698,7 @@ class ReaderPresenter( if (!preferences.autoUpdateTrack()) return val manga = manga ?: return - val chapterRead = readerChapter.chapter.chapter_number.toInt() + val chapterRead = readerChapter.chapter.chapter_number val trackManager = Injekt.get() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterTrackSync.kt b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterTrackSync.kt index 4cd66d2b58..192ce0711d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterTrackSync.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/chapter/ChapterTrackSync.kt @@ -22,6 +22,10 @@ fun syncChaptersWithTrackServiceTwoWay(db: DatabaseHelper, chapters: List sortedChapters.size sortedChapters.any { !it.read } -> sortedChapters.indexOfFirst { !it.read } @@ -29,7 +33,7 @@ fun syncChaptersWithTrackServiceTwoWay(db: DatabaseHelper, chapters: List