Click or drag to resize

LoopingSpinnerExample Class

Very basic example with a spinner that loops its items, similarly to a time picker in an alarm app. Minimal implementation of the adapter that initializes and updates the viewsholders. The size of each item is fixed in this case and it's the same as the prefab's
Inheritance Hierarchy
SystemObject
  Object
    Component
      Behaviour
        MonoBehaviour
          Com.ForbiddenByte.OSA.CoreOSAMyParams, MyItemViewsHolder
            Com.ForbiddenByte.OSA.Demos.LoopingSpinnersLoopingSpinnerExample

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

The LoopingSpinnerExample type exposes the following members.

Constructors
  NameDescription
Public methodLoopingSpinnerExample
Top
Methods
  NameDescription
Public methodChangeItemsCountWithChecks
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).)
Protected methodUpdate (Overrides OSATParams, TItemViewsHolderUpdate.)
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 fieldStatic memberMIN_ITEMS
Top
Version Information

Optimized ScrollView Adapter

Supported in: 4.1
See Also