Click or drag to resize

SimpleExample Class

Old name "SimpleTutorial". Class (initially) implemented during this YouTube tutorial: https://youtu.be/aoqq_j-aV8I (which is now too old to relate). It demonstrates a simple use case with items that expand/collapse on click
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          Com.ForbiddenByte.OSA.CoreOSAMyParams, MyItemViewsHolder
            Com.ForbiddenByte.OSA.Demos.SimpleSimpleExample

Namespace:  Com.ForbiddenByte.OSA.Demos.Simple
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
C#
public class SimpleExample : OSA<MyParams, MyItemViewsHolder>, 
	ExpandCollapseOnClickISizeChangesHandler

The SimpleExample type exposes the following members.

Constructors
  NameDescription
Public methodSimpleExample
Top
Properties
  NameDescription
Public propertyLazyData
Top
Methods
  NameDescription
Public methodChangeItemsCount

Self-explanatory. See ItemCountChangeMode in order to understand how change modes differ from each other.

Every count change operation (Refresh(Boolean, Boolean), InsertItems(Int32, Int32, Boolean, Boolean) etc.) ultimately calls this method, so it's a good place for example to fire a custom "ItemsChanged" event, if you need to

(Overrides OSATParams, TItemViewsHolderChangeItemsCount(ItemCountChangeMode, Int32, Int32, Boolean, Boolean).)
Public methodCreateRandomModel
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 OSATParams, TItemViewsHolderCreateViewsHolder(Int32).)
Public methodOnExpandedStateChanged
Protected methodOnItemIndexChangedDueInsertOrRemove

This is overidden only so that the items' title will be updated to reflect its new index in case of Insert/Remove, because the index is not stored in the model

If you don't store/care about the index of each item, you can omit this

For more info, see OnItemIndexChangedDueInsertOrRemove(TItemViewsHolder, Int32, Boolean, Int32)

(Overrides OSATParams, TItemViewsHolderOnItemIndexChangedDueInsertOrRemove(TItemViewsHolder, Int32, Boolean, Int32).)
Protected methodStart (Overrides OSATParams, TItemViewsHolderStart.)
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)

Note that this is not called for items that will remain visible after an Insert or Remove operation is done

(Overrides OSATParams, TItemViewsHolderUpdateViewsHolder(TItemViewsHolder).)
Top
Fields
  NameDescription
Public fieldOnItemsUpdated
Fired when the number of items changes or refreshes
Top
Version Information

Optimized ScrollView Adapter

Supported in: 4.1
See Also