Table of Contents

Class ViewsAdapter

Namespace
DrawnUi.Draw
Assembly
DrawnUi.Maui.dll

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

parent SkiaLayout

Fields

IsDisposed

public bool IsDisposed

Field Value

bool

LogEnabled

public static bool LogEnabled

Field Value

bool

TemplatesBusy

public bool TemplatesBusy

Field Value

bool

TemplesInvalidating

public bool TemplesInvalidating

Field Value

bool

_lockTemplates

protected readonly object _lockTemplates

Field Value

object

Properties

AddedMore

public int AddedMore { get; protected set; }

Property Value

int

PoolMaxSize

public int PoolMaxSize { get; }

Property Value

int

PoolSize

public int PoolSize { get; }

Property Value

int

TemplatesAvailable

An important check to consider before consuming templates especially if you initialize templates in background

public bool TemplatesAvailable { get; }

Property Value

bool

TemplatesInvalidated

public bool TemplatesInvalidated { get; set; }

Property Value

bool

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

oversize int

AttachView(SkiaControl, int, bool)

protected virtual void AttachView(SkiaControl view, int index, bool isMeasuring)

Parameters

view SkiaControl
index int
isMeasuring bool

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

size int

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

size int
context IList

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

size int

Target pool size

cancellationToken CancellationToken

Optional 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

size int

Number 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

int

GetDebugInfo()

public string GetDebugInfo()

Returns

string

GetOrCreateViewForIndexInternal(int, float, SkiaControl)

public SkiaControl GetOrCreateViewForIndexInternal(int index, float height = 0, SkiaControl template = null)

Parameters

index int
height float
template SkiaControl

Returns

SkiaControl

GetTemplateInstance()

public SkiaControl GetTemplateInstance()

Returns

SkiaControl

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

index int
template SkiaControl
height float
isMeasuring bool

Returns

SkiaControl

GetViewsIterator()

public ViewsIterator GetViewsIterator()

Returns

ViewsIterator

InitializeSoft(bool, IList, int)

public void InitializeSoft(bool layoutChanged, IList dataContexts, int poolSize)

Parameters

layoutChanged bool
dataContexts IList
poolSize int

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

args NotifyCollectionChangedEventArgs
template Func<object>
dataContexts IList
poolSize int
reserve int

Pre-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

index int

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

viewModel SkiaControl
reset bool

ReleaseViewInUse(int, SkiaControl)

public void ReleaseViewInUse(int index, SkiaControl view)

Parameters

index int
view SkiaControl

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

view SkiaControl
reset bool

UpdateViews(IEnumerable<SkiaControl>)

public void UpdateViews(IEnumerable<SkiaControl> views = null)

Parameters

views IEnumerable<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

args NotifyCollectionChangedEventArgs
newDataContexts IList
poolSize int
reserve int

Returns

bool