Class ViewsAdapter
Top level class for working with ItemTemplates. Holds visible views.
public class ViewsAdapter : IDisposable
- Inheritance
-
ViewsAdapter
- Implements
- Inherited Members
- Extension Methods
Constructors
ViewsAdapter(SkiaLayout)
public ViewsAdapter(SkiaLayout parent)
Parameters
parentSkiaLayout
Fields
IsDisposed
public bool IsDisposed
Field Value
LogEnabled
public static bool LogEnabled
Field Value
TemplatesBusy
public bool TemplatesBusy
Field Value
TemplesInvalidating
public bool TemplesInvalidating
Field Value
_lockTemplates
protected readonly object _lockTemplates
Field Value
Properties
AddedMore
public int AddedMore { get; protected set; }
Property Value
PoolMaxSize
public int PoolMaxSize { get; }
Property Value
PoolSize
public int PoolSize { get; }
Property Value
TemplatesAvailable
An important check to consider before consuming templates especially if you initialize templates in background
public bool TemplatesAvailable { get; }
Property Value
TemplatesInvalidated
public bool TemplatesInvalidated { get; set; }
Property Value
Methods
AddMoreToPool(int)
Keep pool size with n templated more oversized, so when we suddenly need more templates they would already be ready, avoiding lag spike,
This method is likely to reserve templated views once on layout size changed.
public void AddMoreToPool(int oversize)
Parameters
oversizeint
AttachView(SkiaControl, int, bool)
protected virtual void AttachView(SkiaControl view, int index, bool isMeasuring)
Parameters
viewSkiaControlindexintisMeasuringbool
CancelBackgroundPoolFilling()
Cancels any ongoing background pool filling operation
public void CancelBackgroundPoolFilling()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
DisposeViews()
protected void DisposeViews()
DisposeVisibleViews()
protected void DisposeVisibleViews()
DisposeWrapper()
public void DisposeWrapper()
FillPool(int)
Use to manually pre-create views from item templates so when we suddenly need more templates they would already be ready, avoiding lag spike, This will respect pool MaxSize in order not to overpass it.
public void FillPool(int size)
Parameters
sizeint
FillPool(int, IList)
Use to manually pre-create views from item templates so when we suddenly need more templates they would already be ready, avoiding lag spike, This will respect pool MaxSize in order not to overpass it.
public void FillPool(int size, IList context)
Parameters
FillPool(int, CancellationToken)
Use to manually pre-create views from item templates so when we suddenly need more templates they would already be ready, avoiding lag spike, This will respect pool MaxSize in order not to overpass it.
public void FillPool(int size, CancellationToken cancellationToken = default)
Parameters
sizeintTarget pool size
cancellationTokenCancellationTokenOptional cancellation token
FillPoolInBackgroundAsync(int)
Safely fills the pool in background with cancellation support. Cancels any previous background filling operation.
public Task FillPoolInBackgroundAsync(int size)
Parameters
sizeintNumber of views to pre-create in the pool
Returns
- Task
Task that completes when pool filling is done or cancelled
GetChildrenCount()
public int GetChildrenCount()
Returns
GetDebugInfo()
public string GetDebugInfo()
Returns
GetOrCreateViewForIndexInternal(int, float, SkiaControl)
public SkiaControl GetOrCreateViewForIndexInternal(int index, float height = 0, SkiaControl template = null)
Parameters
indexintheightfloattemplateSkiaControl
Returns
GetTemplateInstance()
public SkiaControl GetTemplateInstance()
Returns
GetViewForIndex(int, SkiaControl, float, bool)
Creates view from template and returns already existing view for a specific index. This uses cached views and tends to return same views matching index they already used. When cell recycling is off this will be a perfect match at all times.
public SkiaControl GetViewForIndex(int index, SkiaControl template = null, float height = 0, bool isMeasuring = false)
Parameters
indexinttemplateSkiaControlheightfloatisMeasuringbool
Returns
GetViewsIterator()
public ViewsIterator GetViewsIterator()
Returns
InitializeSoft(bool, IList, int)
public void InitializeSoft(bool layoutChanged, IList dataContexts, int poolSize)
Parameters
InitializeTemplates(NotifyCollectionChangedEventArgs, Func<object>, IList, int, int)
Main method to initialize templates, can use InitializeTemplatesInBackground as an option.
public void InitializeTemplates(NotifyCollectionChangedEventArgs args, Func<object> template, IList dataContexts, int poolSize, int reserve = 0)
Parameters
argsNotifyCollectionChangedEventArgstemplateFunc<object>dataContextsIListpoolSizeintreserveintPre-create number of views to avoid lag spikes later, useful to do in backgound.
InvalidateAllPooledCells()
Invalidates all existing cells currently stored in the recycling pools (generic, sized, and standalone). Use this when container constraints change so pooled cells are forced to re-measure next time they are reused.
public void InvalidateAllPooledCells()
MarkAllViewsAsHidden()
public void MarkAllViewsAsHidden()
MarkViewAsHidden(int)
public void MarkViewAsHidden(int index)
Parameters
indexint
PrintDebugVisible()
public void PrintDebugVisible()
ReleaseTemplateInstance(SkiaControl, bool)
Returns standalone view, used for measuring to its own separate pool.
public void ReleaseTemplateInstance(SkiaControl viewModel, bool reset = false)
Parameters
viewModelSkiaControlresetbool
ReleaseViewInUse(int, SkiaControl)
public void ReleaseViewInUse(int index, SkiaControl view)
Parameters
indexintviewSkiaControl
ReleaseViewToPool(SkiaControl, bool)
Retuns view to the POOL and set parent to null. Doesn't set BindingContext to null !
public void ReleaseViewToPool(SkiaControl view, bool reset = false)
Parameters
viewSkiaControlresetbool
UpdateViews(IEnumerable<SkiaControl>)
public void UpdateViews(IEnumerable<SkiaControl> views = null)
Parameters
viewsIEnumerable<SkiaControl>
UpdateVisibleViews()
protected void UpdateVisibleViews()
_HandleSmartCollectionChange(NotifyCollectionChangedEventArgs, IList, int, int)
Enhanced collection change handling with validation and better error handling
public bool _HandleSmartCollectionChange(NotifyCollectionChangedEventArgs args, IList newDataContexts, int poolSize, int reserve = 0)
Parameters
argsNotifyCollectionChangedEventArgsnewDataContextsIListpoolSizeintreserveint