Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/Core/maps/src/Handlers/Map/MapHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public partial class MapHandler : ViewHandler<IMap, MapView>
List<APolygon>? _polygons;
List<ACircle>? _circles;
Dictionary<string, IMapElement>? _trackedMapElements;
HashSet<IMapPin>? _subscribedPins;

public GoogleMap? Map { get; private set; }

Expand Down Expand Up @@ -503,7 +504,8 @@ void AddPins(IList pins)
_markers.Add(marker!);
}

if (pin is INotifyPropertyChanged observable)
_subscribedPins ??= new HashSet<IMapPin>();
if (_subscribedPins.Add(pin) && pin is INotifyPropertyChanged observable)
Comment thread
SubhikshaSf4851 marked this conversation as resolved.
{
observable.PropertyChanged += PinOnPropertyChanged;
}
Expand Down Expand Up @@ -556,17 +558,18 @@ void PinOnPropertyChanged(object? sender, PropertyChangedEventArgs e)

void DisconnectPins()
{
if (VirtualView == null)
return;

for (int i = 0; i < VirtualView.Pins.Count; i++)
if (_subscribedPins is not null)
{
var pin = VirtualView.Pins[i];
if (pin is INotifyPropertyChanged observable)
foreach (var pin in _subscribedPins)
{
observable.PropertyChanged -= PinOnPropertyChanged;
if (pin is INotifyPropertyChanged observable)
{
observable.PropertyChanged -= PinOnPropertyChanged;
}

pin?.Handler?.DisconnectHandler();
}
pin?.Handler?.DisconnectHandler();
_subscribedPins = null;
}
}

Expand Down
Loading