Esempio n. 1
0
 /// <summary>
 /// Called to update the views from the specified model.
 /// Overriden by inheritors to update their own views after casting the model to its known type.
 /// </summary>
 public virtual void UpdateViews(SimpleBaseModel model)
 {
     if (titleText)
     {
         titleText.text = "#" + ItemIndex;
     }
 }
Esempio n. 2
0
        /// <inheritdoc/>
        public override void UpdateViews(SimpleBaseModel model)
        {
            base.UpdateViews(model);

            var adModel = model as AdModel;

            adImage.texture = adModel.adTexture;
        }
Esempio n. 3
0
        /// <inheritdoc/>
        public override void UpdateViews(SimpleBaseModel model)
        {
            base.UpdateViews(model);

            var greenModel = model as GreenModel;

            contentText.text = greenModel.textContent;
        }
Esempio n. 4
0
        /// <inheritdoc/>
        public override void UpdateViews(SimpleBaseModel model)
        {
            base.UpdateViews(model);

            var orangeModel = model as OrangeModel;

            valueSlider.value = orangeModel.value;
        }
Esempio n. 5
0
        /// <inheritdoc/>
        protected override void UpdateViewsHolder(SimpleBaseVH newOrRecycled)
        {
            // Initialize/update the views from the associated model.
            // If the VH needs additional information for updating the view (for example, something from the _Params),
            // you can either add new parameters to the SimpleBaseVH.UpdateViews() method or pass those
            // parameters at the moment the VH is created so it'll always have access to them.
            SimpleBaseModel model = Data[newOrRecycled.ItemIndex];

            newOrRecycled.UpdateViews(model);

            // This allows items to have different sizes by calling UpdateItemSizeOnTwinPass() for each of them after the current ComputeVisibility pass.
            // We're always calling it just for simplicity, but usually you'd only call it if you detect the item's size has changed (in our case
            // this can only happen with the Ad items, whose sizes depend on their image)
            ScheduleComputeVisibilityTwinPass();
        }
Esempio n. 6
0
        protected override void OnItemCountChangeRequested(SimpleMultiplePrefabsExample adapter, int count)
        {
            base.OnItemCountChangeRequested(adapter, count);

            // Generating some random models
            var newModels = new SimpleBaseModel[count];

            for (int i = 0; i < count; ++i)
            {
                int modelType;
                if ((i + 1) % ADS_INTERVAL == 0)
                {
                    modelType = 2;                     // ad
                }
                else
                {
                    modelType = UnityEngine.Random.Range(0, 2);                     // random between orange and green
                }
                newModels[i] = CreateRandomModel(i, modelType);
            }

            adapter.Data.ResetItems(newModels);
        }
Esempio n. 7
0
        /// <summary>
        /// Overriding the base implementation, which always returns true.
        /// In this case, a views holder is recyclable only if its <see cref="SimpleBaseVH.CanPresentModelType(Type)"/> returns
        /// true for the model at index <paramref name="indexOfItemThatWillBecomeVisible"/></summary>
        /// <seealso cref="OSA{TParams, TItemViewsHolder}.IsRecyclable(TItemViewsHolder, int, double)"/>
        protected override bool IsRecyclable(SimpleBaseVH potentiallyRecyclable, int indexOfItemThatWillBecomeVisible, double sizeOfItemThatWillBecomeVisible)
        {
            SimpleBaseModel model = Data[indexOfItemThatWillBecomeVisible];

            return(potentiallyRecyclable.CanPresentModelType(model.CachedType));
        }