diff --git a/app/src/main/java/com/kylecorry/trail_sense/tools/astronomy/ui/AstronomyFragment.kt b/app/src/main/java/com/kylecorry/trail_sense/tools/astronomy/ui/AstronomyFragment.kt index 1b42149fa..63aef9bf9 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/tools/astronomy/ui/AstronomyFragment.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/tools/astronomy/ui/AstronomyFragment.kt @@ -261,9 +261,13 @@ class AstronomyFragment : BoundFragment() { private fun getSeekProgress(): Int { val totalDuration = Duration.between(minChartTime, maxChartTime).seconds + if (totalDuration <= 0) { + return 0 + } + val currentDuration = Duration.between(minChartTime, currentSeekChartTime).seconds val progress = maxProgress * currentDuration / totalDuration.toFloat() - return progress.toInt() + return progress.toInt().coerceIn(0, maxProgress) } private fun hideTimeSeeker() {