diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt index 4c774bd0a..1925d1ca8 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt @@ -484,8 +484,10 @@ class DetailsActivity : textViewProgress.textAndVisible = if (info.percent <= 0f) { null } else { - getString(R.string.percent_string_pattern, (info.percent * 100f).toInt().toString()) + val displayPercent = if (info.percent >= 0.999999f) 100 else (info.percent * 100f).toInt() + getString(R.string.percent_string_pattern, displayPercent.toString()) } + progress.setProgressCompat( (progress.max * info.percent.coerceIn(0f, 1f)).roundToInt(), true, 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 f4ddacbd6..bdce762ed 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,15 +473,9 @@ class ReaderViewModel @Inject constructor( if (chaptersCount == 0 || pagesCount == 0) { return PROGRESS_NONE } - val pagePercent = (pageIndex + 1).toFloat() / pagesCount + val pagePercent = (pageIndex + 1) / pagesCount.toFloat() val ppc = 1f / chaptersCount - var progress = ppc * chapterIndex + ppc * pagePercent - - if (chapterIndex == chaptersCount - 1 && pageIndex + 1 == pagesCount) { - progress = 1.0f - } - - return progress + return ppc * chapterIndex + ppc * pagePercent } private fun observeIsWebtoonZoomEnabled() = settings.observeAsFlow(