Click or drag to resize

IncrementalItemFetch Class

This class demonstrates how items can be appended at the bottom as needed (i.e. when the user acually scrolls there), as opposed to directly downloading all of them. This is useful if the number of items can't be known beforehand (because of reasons). Also, here it's demonstrated how items can be set custom sizes by overriding CollectItemsSizes(ItemCountChangeMode, Int32, Int32, ItemsDescriptor) Use this approach if it's impossible to know the total number of items in advance or there's simply too much overhead. If the number of items IS known, consider using placeholder prefabs with a "Loading..." text on them (which may also make for a nicer UX) while they're being downloaded/processed. The placeholder approach is implemented in GridExample - be sure to check it out if interested.
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          frame8.Logic.Misc.Visual.UI.ScrollRectItemsAdapterSRIAMyParams, MyItemViewsHolder
            frame8.ScrollRectItemsAdapter.IncrementalItemFetchExampleIncrementalItemFetch

Namespace:  frame8.ScrollRectItemsAdapter.IncrementalItemFetchExample
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
C#
public class IncrementalItemFetch : SRIA<MyParams, MyItemViewsHolder>

The IncrementalItemFetch type exposes the following members.

Constructors
  NameDescription
Public methodIncrementalItemFetch
Top
Methods
  NameDescription
Protected methodCollectItemsSizes (Overrides SRIATParams, TItemViewsHolderCollectItemsSizes(ItemCountChangeMode, Int32, Int32, ItemsDescriptor).)
Protected methodCreateViewsHolder

Called when there are no recyclable views for itemIndex. Provide a new viewsholder instance for itemIndex. This is the place where you must initialize the viewsholder

via Init(GameObject, Int32, Boolean, Boolean) shortcut or manually set its itemIndex, instantiate the prefab and call its CollectViews

(Overrides SRIATParams, TItemViewsHolderCreateViewsHolder(Int32).)
Protected methodStart (Overrides SRIATParams, TItemViewsHolderStart.)
Protected methodUpdate (Overrides SRIATParams, TItemViewsHolderUpdate.)
Public methodUpdateCapacity
Protected methodUpdateViewsHolder

Here the data in your model should be bound to the views. Use newOrRecycled.ItemIndex (ItemIndex) to retrieve its associated model

Note that views holders are re-used (this is the main purpose of this adapter), so a views holder's views will contain data from its previously associated model and if,

for example, you're downloading an image to be set as an icon, it makes sense to first clear the previous one (and probably temporarily replace it with a generic "Loading" image)

(Overrides SRIATParams, TItemViewsHolderUpdateViewsHolder(TItemViewsHolder).)
Top
Version Information

Optimized ScrollView Adapter

Supported in: 3.1
See Also