Recent Places Sort by navigations, DEVIATION Maximum
This commit is contained in:
@@ -479,7 +479,7 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
|
||||
checkArrival()
|
||||
}
|
||||
val end = System.currentTimeMillis()
|
||||
Log.d(TAG, "UpdateLocation ${end-start} ms")
|
||||
//Log.d(TAG, "UpdateLocation ${end-start} ms")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,8 +492,7 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
|
||||
): Boolean {
|
||||
val distance = location.distanceTo(snappedLocation)
|
||||
when {
|
||||
distance > MAXIMAL_ROUTE_DEVIATION -> {
|
||||
Log.d(TAG, "Recalculate $distance ")
|
||||
distance > MAXIMAL_ROUTE_DEVIATION && distance < MAXIMAL_ROUTE_DEVIATION * 10-> {
|
||||
stopNavigation()
|
||||
navigationScreen.calculateNewRoute(routeModel.navState.destination)
|
||||
return false
|
||||
@@ -549,7 +548,6 @@ class NavigationSession : CarSession(), NavigationListener, NavigationObserverCa
|
||||
* Checks for arrival
|
||||
*/
|
||||
fun checkArrival() {
|
||||
Log.d(TAG, "maneuverType ${routeModel.navState.maneuverType} Distance ${routeModel.routeCalculator.leftStepDistance()}")
|
||||
if (routeModel.isManeuverArrival()
|
||||
&& routeModel.routeCalculator.leftStepDistance() < DESTINATION_ARRIVAL_DISTANCE
|
||||
) {
|
||||
|
||||
@@ -189,7 +189,7 @@ open class NavigationScreen(
|
||||
.setActionStrip(actionStripBuilder.build())
|
||||
.setMapActionStrip(mapActionStrip)
|
||||
.setPanModeListener { isInPanMode: Boolean ->
|
||||
Log.d(TAG, "PanMode $isInPanMode")
|
||||
|
||||
}
|
||||
.build()
|
||||
}
|
||||
|
||||
@@ -126,21 +126,10 @@ class PlaceListScreen(
|
||||
* Creates an Action to navigate to a specific place.
|
||||
*/
|
||||
private fun clickOnPlace(itPlace: Place) {
|
||||
place = Place(
|
||||
0,
|
||||
itPlace.name,
|
||||
itPlace.category,
|
||||
itPlace.latitude,
|
||||
itPlace.longitude,
|
||||
itPlace.postalCode,
|
||||
itPlace.city,
|
||||
itPlace.street,
|
||||
// avatar = null
|
||||
)
|
||||
if (surfaceRenderer.navigation) {
|
||||
startStopOverScreen(place)
|
||||
startStopOverScreen(itPlace)
|
||||
} else {
|
||||
starPreviewScreen(place)
|
||||
starPreviewScreen(itPlace)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ data class Place(
|
||||
var postalCode: String = "",
|
||||
var city: String = "",
|
||||
var street: String = "",
|
||||
var navigations: Int = 0,
|
||||
@Transient
|
||||
var distance: Float = 0F,
|
||||
//var avatar: Uri? = null,
|
||||
@@ -139,9 +140,9 @@ object Constants {
|
||||
val isarring = location( 11.609696, 48.155116)
|
||||
const val NEXT_STEP_THRESHOLD = 500.0
|
||||
|
||||
const val MAXIMAL_SNAP_CORRECTION = 50.0
|
||||
const val MAXIMAL_SNAP_CORRECTION = 40.0
|
||||
|
||||
const val MAXIMAL_ROUTE_DEVIATION = 150.0
|
||||
const val MAXIMAL_ROUTE_DEVIATION = 100.0
|
||||
|
||||
const val DESTINATION_ARRIVAL_DISTANCE = 10.0
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kouros.navigation.model
|
||||
|
||||
import android.content.Context
|
||||
import android.location.Location
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||
import androidx.compose.runtime.toMutableStateList
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
@@ -13,6 +14,7 @@ import com.kouros.navigation.data.Constants
|
||||
import com.kouros.navigation.data.Constants.FAVORITES
|
||||
import com.kouros.navigation.data.Constants.SPEED_BEARING_DEVIATION
|
||||
import com.kouros.navigation.data.Constants.SPEED_UPDATE_DISTANCE
|
||||
import com.kouros.navigation.data.Constants.TAG
|
||||
import com.kouros.navigation.data.Constants.TANKER_KOENIG_DELAY
|
||||
import com.kouros.navigation.data.NavigationRepository
|
||||
import com.kouros.navigation.data.Place
|
||||
@@ -183,11 +185,15 @@ class NavigationViewModel(private val repository: NavigationRepository) : ViewMo
|
||||
place.id = id
|
||||
id += 1
|
||||
}
|
||||
pl.add(place)
|
||||
if (place.distance == 0F || place.distance > 500F) {
|
||||
pl.add(place)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
recentPlaces.postValue(pl.sortedBy { it.distance })
|
||||
val sortedList = pl.sortedWith(compareByDescending<Place> { it.navigations }
|
||||
.thenByDescending { it.distance })
|
||||
recentPlaces.postValue(sortedList)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
@@ -647,6 +653,7 @@ class NavigationViewModel(private val repository: NavigationRepository) : ViewMo
|
||||
val current = LocalDateTime.now(ZoneOffset.UTC)
|
||||
place.lastDate = current.atZone(ZoneOffset.UTC).toEpochSecond()
|
||||
place.route = ""
|
||||
place.navigations += 1
|
||||
places.add(place)
|
||||
recentPlaces.postValue(places)
|
||||
settingsRepository.setRecentPlaces(gson.toJson(Places(places)))
|
||||
|
||||
Reference in New Issue
Block a user