зеркало из https://github.com/DeGsoft/maui-linux.git
* Ensure that the ListViewAdapter is no longer being used by the ListView before disposing it * Remove `RemoveAllViews` from `Dispose`
This commit is contained in:
Родитель
aeca07c097
Коммит
16a4e91aac
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче