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,
|
||||
|
||||
Reference in New Issue
Block a user