Click or drag to resize

GridAdapterTParams, TCellVH Class

An optimized adapter for a GridView

Implements SRIATParams, TItemViewsHolder to simulate a grid by using

a runtime-generated "row" prefab (or "colum" prefab, if horizontal ScrollRect), having a Horizontal (or Vertical, respectively) LayoutGroup component, inside which its corresponding cells will lie.

This prefab is represented by a CellGroupViewsHolderTCellVH, which nicely abstractizes the mechanism to using cell prefabs. This views holder is managed internally and is no concern for most users.

The cell prefab is used the same way as the "item prefab", for those already familiarized with the ListView examples. It is represented

by a CellViewsHolder, which are the actual views holders you need to create/update and nothing else.

Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          frame8.Logic.Misc.Visual.UI.ScrollRectItemsAdapterSRIATParams, CellGroupViewsHolderTCellVH
            frame8.ScrollRectItemsAdapter.Util.GridViewGridAdapterTParams, TCellVH
              frame8.ScrollRectItemsAdapter.GridExampleGridExample
              frame8.ScrollRectItemsAdapter.SelectionExampleSelectionExample

Namespace:  frame8.ScrollRectItemsAdapter.Util.GridView
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
C#
public abstract class GridAdapter<TParams, TCellVH> : SRIA<TParams, CellGroupViewsHolder<TCellVH>>
where TParams : GridParams
where TCellVH : new(), CellViewsHolder

Type Parameters

TParams
Must inherit from GridParams. See also Parameters
TCellVH
The views holder type to use for the cell. Must inherit from CellViewsHolder

The GridAdapterTParams, TCellVH type exposes the following members.

Constructors
Properties
Methods
  NameDescription
Public methodChangeItemCountTo (Overrides ScrollRectItemsAdapter8TParams, TItemViewsHolderChangeItemCountTo(Int32).)
Public methodChangeItemsCount
Overridden in order to convert the cellsCount to groupsCount before passing it to the base's implementation
(Overrides SRIATParams, TItemViewsHolderChangeItemsCount(ItemCountChangeMode, Int32, Int32, Boolean, Boolean).)
Protected methodCreateViewHolder (Overrides ScrollRectItemsAdapter8TParams, TItemViewsHolderCreateViewHolder(Int32).)
Protected methodCreateViewsHolder
Creates the Group viewsholder which instantiates the group prefab using the provided params in [!:ScrollRectItemsAdapter8<TParams, TItemViewsHolder>.Init(TParams)]
(Overrides SRIATParams, TItemViewsHolderCreateViewsHolder(Int32).)
Public methodGetCellGroupsCount
Public methodGetCellViewsHolder

Retrieve the views holder of a cell with speciffic index in view. For example, one can iterate from 0 to GetNumVisibleCells

in order to do something with each visible cell. Not to be mistaken for GetCellViewsHolderIfVisible(Int32),

which retrieves a cell by the index of its corresponding model in your data list (ItemIndex)

Public methodGetCellViewsHolderIfVisible

Retrieve the views holder of a cell whose associated model's index in your data list is withCellItemIndex.

Not to be mistaken for GetCellViewsHolder(Int32) which retrieves a cell by its index _VisibleItems

Protected methodGetItemHeight (Overrides ScrollRectItemsAdapter8TParams, TItemViewsHolderGetItemHeight(Int32).)
Public methodGetItemsCount
Overriding base's implementation to return the cells count, instead of the groups count
(Overrides SRIATParams, TItemViewsHolderGetItemsCount.)
Protected methodGetItemWidth (Overrides ScrollRectItemsAdapter8TParams, TItemViewsHolderGetItemWidth(Int32).)
Public methodGetNumVisibleCells
The number of visible cells
Public methodGetViewsHolderOfClosestItemToViewportPoint
Tha base implementation finds the group. Here, we're narrowing the search in the group iself in order to return the CellViewsHolder
(Overrides SRIATParams, TItemViewsHolderGetViewsHolderOfClosestItemToViewportPoint(Single, Single, Single).)
Protected methodInitOrUpdateItemViewHolder (Overrides ScrollRectItemsAdapter8TParams, TItemViewsHolderInitOrUpdateItemViewHolder(TItemViewsHolder).)
Public methodInsertItems
Not currently implemented fir GridAdapters
(Overrides SRIATParams, TItemViewsHolderInsertItems(Int32, Int32, Boolean, Boolean).)
Protected methodOnBeforeRecycleOrDisableCellViewsHolder
The only important callback for inheritors. It provides cell's views holder which has just become visible and whose views should be updated from its corresponding data model. viewsHolder.ItemIndex(ItemIndex) can be used to know what data model is associated with.
Protected methodOnBeforeRecycleOrDisableViewsHolder
Overridden in order to call OnBeforeRecycleOrDisableCellViewsHolder(TCellVH, Int32) for each active cell in the group
(Overrides SRIATParams, TItemViewsHolderOnBeforeRecycleOrDisableViewsHolder(TItemViewsHolder, Int32).)
Public methodRefresh
Overriding base's implementation so that we pass the cells count to our own implementation which converts them to group count before further passing it to the base impl.
(Overrides SRIATParams, TItemViewsHolderRefresh.)
Public methodRefresh(Boolean, Boolean)
Public methodRemoveItems
Not currently implemented fir GridAdapters
(Overrides SRIATParams, TItemViewsHolderRemoveItems(Int32, Int32, Boolean, Boolean).)
Public methodScrollTo
Scrolls to the specified cell. Use ScrollToGroup(Int32, Single, Single) if that was intended instead
(Overrides SRIATParams, TItemViewsHolderScrollTo(Int32, Single, Single).)
Public methodScrollToGroup
Scroll to the specified GROUP. Use ScrollTo(Int32, Single, Single) if scrolling to a CELL was intended instead
Public methodSmoothScrollTo
Scrolls to the specified cell. Use [!:SmoothScrollToGroup(int, float, float, float, Func<float, bool>)] if that was intended instead
(Overrides SRIATParams, TItemViewsHolderSmoothScrollTo(Int32, Single, Single, Single, FuncSingle, Boolean, Boolean).)
Public methodSmoothScrollToGroup
Protected methodUpdateCellViewHolder
Protected methodUpdateCellViewsHolder
The only important callback for inheritors. It provides cell's views holder which has just become visible and whose views should be updated from its corresponding data model. viewsHolder.ItemIndex(ItemIndex) can be used to know what data model is associated with.
Protected methodUpdateViewsHolder
Here the grid adapter checks if new groups need to be created or if old ones need to be disabled or destroyed, after which it calls UpdateCellViewsHolder(TCellVH) for each remaining cells
(Overrides SRIATParams, TItemViewsHolderUpdateViewsHolder(TItemViewsHolder).)
Top
Fields
  NameDescription
Protected field_CellsCount
Top
Version Information

Optimized ScrollView Adapter

Supported in: 3.1, 2.5.2
See Also