Ensure that the ListViewAdapter is no longer being used by the ListVi… (#3848) fixes #3603

* Ensure that the ListViewAdapter is no longer being used by the ListView before disposing it

* Remove `RemoveAllViews` from `Dispose`
This commit is contained in:
E.Z. Hart 2018-09-24 05:46:32 -06:00 коммит произвёл Rui Marinho
Родитель aeca07c097
Коммит 16a4e91aac
3 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -15,6 +15,7 @@ namespace Xamarin.Forms.Platform.Android
{
internal class ListViewAdapter : CellAdapter
{
bool _disposed;
static readonly object DefaultItemTypeOrDataTemplate = new object();
const int DefaultGroupHeaderTemplateId = 0;
const int DefaultItemTemplateId = 1;
@ -417,6 +418,13 @@ namespace Xamarin.Forms.Platform.Android
protected override void Dispose(bool disposing)
{
if (_disposed)
{
return;
}
_disposed = true;
if (disposing)
{
CloseContextActions();

Просмотреть файл

@ -75,6 +75,12 @@ namespace Xamarin.Forms.Platform.Android
_footerView?.Dispose();
_footerView = null;
// Unhook the adapter from the ListView before disposing of it
if (Control != null)
{
Control.Adapter = null;
}
if (_adapter != null)
{
_adapter.Dispose();
@ -124,6 +130,12 @@ namespace Xamarin.Forms.Platform.Android
if (_adapter != null)
{
// Unhook the adapter from the ListView before disposing of it
if (Control != null)
{
Control.Adapter = null;
}
_adapter.Dispose();
_adapter = null;
}

Просмотреть файл

@ -238,8 +238,6 @@ namespace Xamarin.Forms.Platform.Android
}
}
RemoveAllViews();
if (Element != null)
{
Element.PropertyChanged -= _propertyChangeHandler;