/// <inheritdoc/>
        protected override void UpdateViewsHolder(ChildAdapterViewsHolder newOrRecycled)
        {
            // Initialize the views from the associated model
            ChildAdapterModel childAdapterModel = Data[newOrRecycled.ItemIndex];

            newOrRecycled.UpdateViews(childAdapterModel);

            if (childAdapterModel.items == null)             // first time updating the child scroll view => download initial items
            {
                CreteRandomItemsForChildScrollView(newOrRecycled, childAdapterModel, UnityEngine.Random.Range(1, MAX_ITEMS_ALLOWED_IN_CHILD));
            }
            else
            {
                newOrRecycled.childGrid.SetItemsAndUpdate(childAdapterModel.items);                 // already having the items => update directly
            }
        }
        void CreteRandomItemsForChildScrollView(ChildAdapterViewsHolder viewsHolder, ChildAdapterModel childScrollViewModel, int count)
        {
            int nextFreeId = viewsHolder.childGrid.GetItemsCount();             // the "id" (used only to show it in TitleText) for the first created item is the current items count;
            var list       = new List <MyCellModel>(count);

            for (int i = 0; i < count; i++)
            {
                var cellModel = new MyCellModel()
                {
                    title = nextFreeId + "",
                    color = DemosUtil.GetRandomColor(false)
                };
                ++nextFreeId;
                list.Add(cellModel);
            }

            // The childScrollViewModel keeps track of items, because the
            // child script is not a "persistent storage" - it's being constantly recycled
            childScrollViewModel.items = new List <MyCellModel>(list);
            viewsHolder.childGrid.SetItemsAndUpdate(list);
        }
 public void UpdateViews(ChildAdapterModel model)
 {
     titleText.text = model.title;
 }