mirror of
https://github.com/ev-map/EVMap.git
synced 2026-04-19 21:58:09 -04:00
fix highlighted charger after moving map
This commit is contained in:
@@ -496,15 +496,14 @@ class MapFragment : Fragment(), OnMapReadyCallback, MapsActivity.FragmentCallbac
|
||||
// remove markers that disappeared
|
||||
markers.entries.toList().forEach {
|
||||
if (!chargepointIds.contains(it.value.id)) {
|
||||
val tint = getMarkerTint(it.value)
|
||||
if (it.key.isVisible) {
|
||||
animator.animateMarkerDisappear(it.key, tint)
|
||||
val tint = getMarkerTint(it.value)
|
||||
val highlight = it.value == vm.chargerSparse.value
|
||||
animator.animateMarkerDisappear(it.key, tint, highlight)
|
||||
} else {
|
||||
it.key.remove()
|
||||
}
|
||||
markers.remove(it.key)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
// add new markers
|
||||
@@ -512,14 +511,15 @@ class MapFragment : Fragment(), OnMapReadyCallback, MapsActivity.FragmentCallbac
|
||||
!markers.containsValue(it)
|
||||
}.forEach { charger ->
|
||||
val tint = getMarkerTint(charger)
|
||||
val highlight = charger == vm.chargerSparse.value
|
||||
val marker = map.addMarker(
|
||||
MarkerOptions()
|
||||
.position(LatLng(charger.coordinates.lat, charger.coordinates.lng))
|
||||
.icon(
|
||||
chargerIconGenerator.getBitmapDescriptor(tint)
|
||||
chargerIconGenerator.getBitmapDescriptor(tint, highlight = highlight)
|
||||
)
|
||||
)
|
||||
animator.animateMarkerAppear(marker, tint)
|
||||
animator.animateMarkerAppear(marker, tint, highlight)
|
||||
markers[marker] = charger
|
||||
}
|
||||
clusterMarkers = clusters.map { cluster ->
|
||||
|
||||
@@ -23,7 +23,8 @@ class MarkerAnimator(val gen: ChargerIconGenerator) {
|
||||
|
||||
fun animateMarkerAppear(
|
||||
marker: Marker,
|
||||
tint: Int
|
||||
tint: Int,
|
||||
highlight: Boolean
|
||||
) {
|
||||
animatingMarkers[marker]?.cancel()
|
||||
animatingMarkers.remove(marker)
|
||||
@@ -39,7 +40,7 @@ class MarkerAnimator(val gen: ChargerIconGenerator) {
|
||||
}
|
||||
val scale = animationState.animatedValue as Int
|
||||
marker.setIcon(
|
||||
gen.getBitmapDescriptor(tint, scale = scale)
|
||||
gen.getBitmapDescriptor(tint, scale = scale, highlight = highlight)
|
||||
)
|
||||
}
|
||||
addListener(onEnd = {
|
||||
@@ -52,7 +53,8 @@ class MarkerAnimator(val gen: ChargerIconGenerator) {
|
||||
|
||||
fun animateMarkerDisappear(
|
||||
marker: Marker,
|
||||
tint: Int
|
||||
tint: Int,
|
||||
highlight: Boolean
|
||||
) {
|
||||
animatingMarkers[marker]?.cancel()
|
||||
animatingMarkers.remove(marker)
|
||||
@@ -68,7 +70,7 @@ class MarkerAnimator(val gen: ChargerIconGenerator) {
|
||||
}
|
||||
val scale = animationState.animatedValue as Int
|
||||
marker.setIcon(
|
||||
gen.getBitmapDescriptor(tint, scale = scale)
|
||||
gen.getBitmapDescriptor(tint, scale = scale, highlight = highlight)
|
||||
)
|
||||
}
|
||||
addListener(onEnd = {
|
||||
|
||||
Reference in New Issue
Block a user