Recent Places Sort by navigations, DEVIATION Maximum
This commit is contained in:
@@ -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