Refresh Distance in PlaceList
This commit is contained in:
@@ -29,6 +29,7 @@ import com.kouros.navigation.data.Constants.RECENT
|
||||
import com.kouros.navigation.data.Place
|
||||
import com.kouros.navigation.model.NavigationViewModel
|
||||
import com.kouros.navigation.utils.getSettingsRepository
|
||||
import com.kouros.navigation.utils.location
|
||||
|
||||
class PlaceListScreen(
|
||||
private val carContext: CarContext,
|
||||
@@ -59,6 +60,12 @@ class PlaceListScreen(
|
||||
override fun onStop(owner: LifecycleOwner) {
|
||||
navigationViewModel.recentPlaces.value = emptyList()
|
||||
}
|
||||
|
||||
override fun onStart(owner: LifecycleOwner) {
|
||||
recentPlaces.forEach {
|
||||
it.distance = location(it.longitude, it.latitude).distanceTo(surfaceRenderer.lastLocation)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -74,7 +81,7 @@ class PlaceListScreen(
|
||||
.setImage(contactIcon(null, it.category))
|
||||
.setTitle("$street ${it.city}")
|
||||
.setOnClickListener {
|
||||
clickOnPlace(it)
|
||||
clickOnPlace(it)
|
||||
}
|
||||
if (category != CONTACTS) {
|
||||
row.addText(SpannableString(" ").apply {
|
||||
@@ -130,7 +137,7 @@ class PlaceListScreen(
|
||||
if (surfaceRenderer.navigation) {
|
||||
startStopOverScreen(place)
|
||||
} else {
|
||||
starPreviewScreen(place)
|
||||
starPreviewScreen(place)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +149,7 @@ class PlaceListScreen(
|
||||
.pushForResult(
|
||||
RoutePreviewScreen(
|
||||
carContext,
|
||||
if (showAlternativeRoute) RoutePreviewType.MULTI_ROUTE else RoutePreviewType.SINGLE_ROUTE,
|
||||
if (showAlternativeRoute) RoutePreviewType.MULTI_ROUTE else RoutePreviewType.SINGLE_ROUTE,
|
||||
surfaceRenderer,
|
||||
place,
|
||||
navigationViewModel,
|
||||
|
||||
@@ -28,6 +28,7 @@ import kotlin.math.cos
|
||||
import kotlin.math.ln
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.ranges.contains
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
@@ -145,7 +146,7 @@ fun duration(
|
||||
2.seconds
|
||||
} else {
|
||||
val updateDuration = java.time.Duration.between(LocalDateTime.now(), lastLocationUpdate)
|
||||
if (updateDuration.toMillis().absoluteValue < 1000) {
|
||||
if (updateDuration.toMillis().absoluteValue !in 1000..2000) {
|
||||
2.seconds
|
||||
} else {
|
||||
((updateDuration!!.toMillis().absoluteValue * 1.8).toDuration(DurationUnit.MILLISECONDS))
|
||||
|
||||
Reference in New Issue
Block a user