summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/VisualElementTracker.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/VisualElementTracker.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/VisualElementTracker.cs24
1 files changed, 17 insertions, 7 deletions
diff --git a/Xamarin.Forms.Platform.Android/VisualElementTracker.cs b/Xamarin.Forms.Platform.Android/VisualElementTracker.cs
index 2b9815d..7ade459 100644
--- a/Xamarin.Forms.Platform.Android/VisualElementTracker.cs
+++ b/Xamarin.Forms.Platform.Android/VisualElementTracker.cs
@@ -45,18 +45,28 @@ namespace Xamarin.Forms.Platform.Android
public void Dispose()
{
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
if (_disposed)
return;
- _disposed = true;
- SetElement(_element, null);
+ _disposed = true;
- if (_renderer != null)
+ if (disposing)
{
- _renderer.ElementChanged -= RendererOnElementChanged;
- _renderer.ViewGroup.RemoveOnAttachStateChangeListener(AttachTracker.Instance);
- _renderer = null;
- _context = null;
+ SetElement(_element, null);
+
+ if (_renderer != null)
+ {
+ _renderer.ElementChanged -= RendererOnElementChanged;
+ _renderer.ViewGroup.RemoveOnAttachStateChangeListener(AttachTracker.Instance);
+ _renderer = null;
+ _context = null;
+ }
}
}