diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryRepository.kt b/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryRepository.kt index 13aaf137b..cb319e58d 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryRepository.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/history/data/HistoryRepository.kt @@ -145,10 +145,11 @@ class HistoryRepository @Inject constructor( suspend fun getProgress(mangaId: Long, mode: ProgressIndicatorMode): ReadingProgress? { val entity = db.getHistoryDao().find(mangaId) ?: return null + val fixedPercent = if (entity.percent >= 0.999999f) 1f else entity.percent return ReadingProgress( - percent = entity.percent, + percent = fixedPercent, totalChapters = entity.chaptersCount, - mode = mode, + mode = mode ).takeIf { it.isValid() } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt index bdce762ed..f4ddacbd6 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt @@ -473,9 +473,15 @@ class ReaderViewModel @Inject constructor( if (chaptersCount == 0 || pagesCount == 0) { return PROGRESS_NONE } - val pagePercent = (pageIndex + 1) / pagesCount.toFloat() + val pagePercent = (pageIndex + 1).toFloat() / pagesCount val ppc = 1f / chaptersCount - return ppc * chapterIndex + ppc * pagePercent + var progress = ppc * chapterIndex + ppc * pagePercent + + if (chapterIndex == chaptersCount - 1 && pageIndex + 1 == pagesCount) { + progress = 1.0f + } + + return progress } private fun observeIsWebtoonZoomEnabled() = settings.observeAsFlow(