summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Maps.Android
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-09-27 10:51:22 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-09-27 10:51:22 (GMT)
commit6aa96a43915edaa8fa03ab9bf5abf00fd424f3f1 (patch)
tree51b81383a24596e09000c1d609c8967d0a3d9300 /Xamarin.Forms.Maps.Android
parent2d5785731ed0062af80a0e85763316a63f64afa8 (diff)
downloadxamarin-forms-6aa96a43915edaa8fa03ab9bf5abf00fd424f3f1.zip
xamarin-forms-6aa96a43915edaa8fa03ab9bf5abf00fd424f3f1.tar.gz
xamarin-forms-6aa96a43915edaa8fa03ab9bf5abf00fd424f3f1.tar.bz2
Clean up listeners and tag on ButtonRenderer during disposal (#360)
Clean up OnFocusChangeListener on ViewRenderer during disposal Prevent memory leak of PageContainer/FragmentContainer when animating fragment transitions Call Destroy() on Map during disposal Rebasing
Diffstat (limited to 'Xamarin.Forms.Maps.Android')
-rw-r--r--Xamarin.Forms.Maps.Android/MapRenderer.cs32
1 files changed, 19 insertions, 13 deletions
diff --git a/Xamarin.Forms.Maps.Android/MapRenderer.cs b/Xamarin.Forms.Maps.Android/MapRenderer.cs
index dc1b46c..f83b6fa 100644
--- a/Xamarin.Forms.Maps.Android/MapRenderer.cs
+++ b/Xamarin.Forms.Maps.Android/MapRenderer.cs
@@ -59,25 +59,30 @@ namespace Xamarin.Forms.Maps.Android
protected override void Dispose(bool disposing)
{
- if (disposing && !_disposed)
+ if (_disposed)
{
- _disposed = true;
+ return;
+ }
- Map mapModel = Element;
- if (mapModel != null)
+ _disposed = true;
+
+ if (disposing)
+ {
+ if (Element != null)
{
MessagingCenter.Unsubscribe<Map, MapSpan>(this, MoveMessageName);
- ((ObservableCollection<Pin>)mapModel.Pins).CollectionChanged -= OnCollectionChanged;
+ ((ObservableCollection<Pin>)Element.Pins).CollectionChanged -= OnCollectionChanged;
}
- GoogleMap gmap = NativeMap;
- if (gmap == null)
- {
- return;
- }
- gmap.MyLocationEnabled = false;
- gmap.InfoWindowClick -= MapOnMarkerClick;
- gmap.Dispose();
+ if (NativeMap != null)
+ {
+ NativeMap.MyLocationEnabled = false;
+ NativeMap.SetOnCameraChangeListener(null);
+ NativeMap.InfoWindowClick -= MapOnMarkerClick;
+ NativeMap.Dispose();
+ }
+
+ Control?.OnDestroy();
}
base.Dispose(disposing);
@@ -265,6 +270,7 @@ namespace Xamarin.Forms.Maps.Android
catch (IllegalStateException exc)
{
System.Diagnostics.Debug.WriteLine("MoveToRegion exception: " + exc);
+ Log.Warning("Xamarin.Forms MapRenderer", $"MoveToRegion exception: {exc}");
}
}