summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs
diff options
context:
space:
mode:
authorjacobmcgoogan <jacob.mcgoogan@allscripts.com>2017-05-04 14:20:50 (GMT)
committerRui Marinho <me@ruimarinho.net>2017-05-04 14:20:50 (GMT)
commitc20ec49ad3849c756b9fbc2e99d002e7fa0d4238 (patch)
tree3ae74bf67907ec74af47a7c00e38c22f2a330778 /Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs
parentda0a9d421c9d1dbb9aa73bf578cf463763168961 (diff)
downloadxamarin-forms-c20ec49ad3849c756b9fbc2e99d002e7fa0d4238.zip
xamarin-forms-c20ec49ad3849c756b9fbc2e99d002e7fa0d4238.tar.gz
xamarin-forms-c20ec49ad3849c756b9fbc2e99d002e7fa0d4238.tar.bz2
Unsubscribe OnModelChanged event when TableViewModelRenderer is disposed (#879)
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs15
1 files changed, 10 insertions, 5 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs
index 7d21511..b5c49a1 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs
@@ -51,11 +51,7 @@ namespace Xamarin.Forms.Platform.Android
_view = view;
Context = context;
- Controller.ModelChanged += (sender, args) =>
- {
- InvalidateCellCache();
- NotifyDataSetChanged();
- };
+ Controller.ModelChanged += OnModelChanged;
listView.OnItemClickListener = this;
listView.OnItemLongClickListener = this;
@@ -255,10 +251,19 @@ namespace Xamarin.Forms.Platform.Android
_nextIsHeaderCache = null;
}
+ void OnModelChanged(object sender, EventArgs e)
+ {
+ InvalidateCellCache();
+ NotifyDataSetChanged();
+ }
+
protected override void Dispose(bool disposing)
{
if (disposing)
+ {
InvalidateCellCache();
+ Controller.ModelChanged -= OnModelChanged;
+ }
base.Dispose(disposing);
}