More fixes for pass item in Compose

This commit is contained in:
Arty Bishop committed 2025-12-27 15:01:32 +00:00
1 parent ac479f80ee
commit 46f0b9608b
7 files changed
+31 -19

No files matched your search

@@ -18,16 +18,14 @@
package com.rtbishop.look4sat.domain.predict
data class SatPass(
val aosTime: Long,
val aosAzimuth: Double,
val losTime: Long,
val losAzimuth: Double,
// val tcaTime: Long,
// val tcaAzimuth: Double,
val altitude: Int,
val maxElevation: Double,
val aosTime: Long = 0L,
val aosAzimuth: Double = 90.0,
val losTime: Long = 0L,
val losAzimuth: Double = 270.0,
val altitude: Int = 1000,
val maxElevation: Double = 75.0,
val satellite: Satellite,
var progress: Int = 0
var progress: Float = 0.0f
) {
val catNum: Int = satellite.data.catnum
val name: String = satellite.data.name
@@ -78,11 +78,11 @@ class SatelliteManager(private val defaultDispatcher: CoroutineDispatcher) : ISa
if (time > timeStart) {
val deltaNow = time.minus(timeStart).toFloat()
val deltaTotal = pass.losTime.minus(timeStart).toFloat()
pass.progress = ((deltaNow / deltaTotal) * 100).toInt()
pass.progress = (deltaNow / deltaTotal).round(2)
}
}
}
passList.filter { pass -> pass.progress < 100 }.map { it.copy() }
passList.filter { pass -> pass.progress < 1.0 }.map { it.copy() }
}
}
@@ -29,6 +29,12 @@ fun Long.toTimerString(): String {
return String.format(format, hours, minutes, seconds)
}
fun Float.round(decimals: Int): Float {
var multiplier = 1.0f
repeat(decimals) { multiplier *= 10 }
return kotlin.math.round(this * multiplier) / multiplier
}
fun Double.round(decimals: Int): Double {
var multiplier = 1.0
repeat(decimals) { multiplier *= 10 }