items and container is not cleared after view disposed.
fix collectionView and item dispose properly.
// Unrealize and caching the item.
internal override void UnrealizeItem(RecyclerViewItem item, bool recycle = true)
{
+ if (item == null) return;
if (item == Header)
{
item.Hide();
if (type == DisposeTypes.Explicit)
{
- disposed = true;
-
// From now on, no need to use this properties,
// so remove reference, to push it into garbage collector.
- if (InternalItemSource != null)
- {
- InternalItemSource.Dispose();
- InternalItemSource = null;
- }
+ // Arugable to disposing user-created members.
+ /*
if (Header != null)
{
Utility.Dispose(Header);
Utility.Dispose(Footer);
Footer = null;
}
+ */
+
groupHeaderTemplate = null;
groupFooterTemplate = null;
selectedItems.Clear();
selectedItems = null;
}
+ if (InternalItemSource != null)
+ {
+ InternalItemSource.Dispose();
+ InternalItemSource = null;
+ }
+ if (recycleGroupHeaderCache != null)
+ {
+ foreach(RecyclerViewItem item in recycleGroupHeaderCache)
+ {
+ UnrealizeItem(item, false);
+ }
+ recycleGroupHeaderCache.Clear();
+ }
+ if (recycleGroupFooterCache != null)
+ {
+ foreach(RecyclerViewItem item in recycleGroupFooterCache)
+ {
+ UnrealizeItem(item, false);
+ }
+ recycleGroupFooterCache.Clear();
+ }
}
base.Dispose(type);
{
//Extension : Extension?.OnDispose(this);
+ // Arugable to disposing user-created members.
+ /*
+ if (itemBadge != null)
+ {
+ Utility.Dispose(itemBadge);
+ }
+ */
+
if (itemImage != null)
{
Utility.Dispose(itemImage);
+ itemImage = null;
}
if (itemCaption != null)
{
Utility.Dispose(itemCaption);
+ itemCaption = null;
}
- if (itemBadge != null)
- {
- Utility.Dispose(itemBadge);
- }
+
}
base.Dispose(type);
{
//Extension : Extension?.OnDispose(this);
+ // Arugable to disposing user-created members.
+ /*
if (itemIcon != null)
{
Utility.Dispose(itemIcon);
{
Utility.Dispose(itemExtra);
}
+ */
if (itemLabel != null)
{
Utility.Dispose(itemLabel);
+ itemLabel = null;
}
if (itemSubLabel != null)
{
Utility.Dispose(itemSubLabel);
+ itemSubLabel = null;
}
if (itemSeperator != null)
{
Utility.Dispose(itemSeperator);
+ itemSeperator = null;
}
}
{
//Extension : Extension?.OnDispose(this);
+ // Arugable to disposing user-created members.
+ /*
if (itemIcon != null)
{
Utility.Dispose(itemIcon);
}
+ */
if (itemLabel != null)
{
Utility.Dispose(itemLabel);
+ itemLabel = null;
}
if (itemSeperator != null)
{
Utility.Dispose(itemSeperator);
+ itemSeperator = null;
}
}
/// <param name="recycle"> Allow recycle. default is true </param>
internal virtual void UnrealizeItem(RecyclerViewItem item, bool recycle = true)
{
+ if (item == null) return;
item.Index = -1;
item.ParentItemsView = null;
item.BindingContext = null;
if (type == DisposeTypes.Explicit)
{
- disposed = true;
// call the clear!
if (RecycleCache != null)
{
foreach (RecyclerViewItem item in RecycleCache)
{
- //ContentContainer.Remove(item);
- Utility.Dispose(item);
+ UnrealizeItem(item, false);
}
RecycleCache.Clear();
}
InternalItemsLayouter = null;
ItemsSource = null;
ItemTemplate = null;
- if (InternalItemSource != null) InternalItemSource.Dispose();
+ if (InternalItemSource != null)
+ {
+ InternalItemSource.Dispose();
+ InternalItemSource = null;
+ }
//
}