mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: map cluster crash (#4317)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
4d7af80389
commit
7ffd5bc9f2
5 changed files with 101 additions and 60 deletions
|
|
@ -246,10 +246,15 @@ fun EditWaypointDialog(
|
|||
DatePickerDialog(
|
||||
context,
|
||||
{ _: DatePicker, selectedYear: Int, selectedMonth: Int, selectedDay: Int ->
|
||||
calendar.clear()
|
||||
calendar.set(selectedYear, selectedMonth, selectedDay, hour, minute)
|
||||
val tempCal = Calendar.getInstance()
|
||||
if (waypointInput.expire != 0 && waypointInput.expire != Int.MAX_VALUE) {
|
||||
tempCal.timeInMillis = waypointInput.expire * 1000L
|
||||
} else {
|
||||
tempCal.add(Calendar.HOUR_OF_DAY, 8)
|
||||
}
|
||||
tempCal.set(selectedYear, selectedMonth, selectedDay)
|
||||
waypointInput =
|
||||
waypointInput.copy { expire = (calendar.timeInMillis / 1000).toInt() }
|
||||
waypointInput.copy { expire = (tempCal.timeInMillis / 1000).toInt() }
|
||||
},
|
||||
year,
|
||||
month,
|
||||
|
|
@ -262,7 +267,11 @@ fun EditWaypointDialog(
|
|||
{ _: TimePicker, selectedHour: Int, selectedMinute: Int ->
|
||||
// Keep the existing date part
|
||||
val tempCal = Calendar.getInstance()
|
||||
tempCal.timeInMillis = waypointInput.expire * 1000L
|
||||
if (waypointInput.expire != 0 && waypointInput.expire != Int.MAX_VALUE) {
|
||||
tempCal.timeInMillis = waypointInput.expire * 1000L
|
||||
} else {
|
||||
tempCal.add(Calendar.HOUR_OF_DAY, 8)
|
||||
}
|
||||
tempCal.set(Calendar.HOUR_OF_DAY, selectedHour)
|
||||
tempCal.set(Calendar.MINUTE, selectedMinute)
|
||||
waypointInput =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2025 Meshtastic LLC
|
||||
* Copyright (c) 2025-2026 Meshtastic LLC
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -14,12 +14,19 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.meshtastic.feature.map.component
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.key
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.findViewTreeLifecycleOwner
|
||||
import androidx.lifecycle.setViewTreeLifecycleOwner
|
||||
import androidx.savedstate.SavedStateRegistryOwner
|
||||
import androidx.savedstate.findViewTreeSavedStateRegistryOwner
|
||||
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
||||
import com.google.maps.android.clustering.Cluster
|
||||
import com.google.maps.android.clustering.view.DefaultClusterRenderer
|
||||
import com.google.maps.android.compose.Circle
|
||||
|
|
@ -37,6 +44,23 @@ fun NodeClusterMarkers(
|
|||
navigateToNodeDetails: (Int) -> Unit,
|
||||
onClusterClick: (Cluster<NodeClusterItem>) -> Boolean,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
// Workaround for https://github.com/googlemaps/android-maps-compose/issues/858
|
||||
// Ensure owners are set on the Activity decor view so the internal ComposeView created by
|
||||
// the clustering renderer can find them when walking up the view tree.
|
||||
LaunchedEffect(Unit) {
|
||||
val activity = context as? android.app.Activity
|
||||
if (activity != null) {
|
||||
val decorView = activity.window.decorView
|
||||
if (decorView.findViewTreeLifecycleOwner() == null && activity is LifecycleOwner) {
|
||||
decorView.setViewTreeLifecycleOwner(activity)
|
||||
}
|
||||
if (decorView.findViewTreeSavedStateRegistryOwner() == null && activity is SavedStateRegistryOwner) {
|
||||
decorView.setViewTreeSavedStateRegistryOwner(activity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mapFilterState.showPrecisionCircle) {
|
||||
nodeClusterItems.forEach { clusterItem ->
|
||||
key(clusterItem.node.num) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue