Wegpunkt-Pfeile mit Richtung und Info-Fenster; GPX-Schreib-Performance fix
- TrackDetailActivity: Zeigt zoom-adaptive Richtungspfeile (Bearing) als Marker auf der Karte; Klick öffnet Info-Fenster mit Geschwindigkeit und Kurs - GPXManager: appendLocation schreibt nur noch per appendText statt Datei komplett neu zu schreiben (O(1) statt O(n)) - TrackingService: finalizeSession() beim Stoppen aufrufen, um GPX-Footer korrekt abzuschließen Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,11 @@ class GPXManager(private val context: Context) {
|
||||
return file
|
||||
}
|
||||
|
||||
fun finalizeSession() {
|
||||
currentFile?.appendText(getGpxFooter())
|
||||
currentFile = null
|
||||
}
|
||||
|
||||
fun appendLocation(location: Location) {
|
||||
currentFile?.let { file ->
|
||||
val time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US).apply {
|
||||
@@ -37,8 +42,7 @@ class GPXManager(private val context: Context) {
|
||||
}
|
||||
sb.append("</trkpt>")
|
||||
|
||||
val content = file.readText().removeSuffix(getGpxFooter())
|
||||
file.writeText(content + sb.toString() + getGpxFooter())
|
||||
file.appendText(sb.toString())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,9 @@ class TrackingService : Service() {
|
||||
speedCount = 0
|
||||
_trackingState.value = TrackingData()
|
||||
|
||||
val locationRequest = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 1000)
|
||||
.setMinUpdateIntervalMillis(1000)
|
||||
val locationRequest = LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 5000)
|
||||
.setMinUpdateIntervalMillis(5000)
|
||||
.setMinUpdateDistanceMeters(10f)
|
||||
.build()
|
||||
|
||||
try {
|
||||
@@ -122,6 +123,7 @@ class TrackingService : Service() {
|
||||
fun stopTracking() {
|
||||
fusedLocationClient.removeLocationUpdates(locationCallback)
|
||||
job?.cancel()
|
||||
gpxManager.finalizeSession()
|
||||
stopForeground(STOP_FOREGROUND_REMOVE)
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user