Exemple #1
0
        private ListViewCell GetUsableBuffer(int index)
        {
            ListViewCell        buffer      = null;
            int                 prefabIndex = this.Adapter.GetCellPrefabIndex(index);
            List <ListViewCell> buffers     = this.buffersArray[prefabIndex];

            for (int i = 0; i < buffers.Count; i++)
            {
                if (!buffers[i].IsUsing)
                {
                    buffer = buffers[i];
                    break;
                }
            }

            if (buffer == null)
            {
                buffer = GameObject.Instantiate <GameObject>(this.prefabs[prefabIndex]).GetComponent <ListViewCell>();
                if (buffer != null)
                {
                    buffer.gameObject.SetActive(true);
                    buffer.transform.SetParent(transform);
                    buffer.transform.localScale = Vector3.one;
                    this.buffersArray[prefabIndex].Add(buffer);
                }
            }

            return(buffer);
        }
Exemple #2
0
 public override void FillItemData(ListViewCell item, int cellindex)
 {
     base.FillItemData(item, cellindex);
     luaFunc.BeginPCall();
     luaFunc.Call <ListViewCell, int>(item, cellindex);
     luaFunc.EndPCall();
     //Debug.Log("LuaListViewAdapter.FillItemData " + cellindex);
 }
Exemple #3
0
        protected override void FillData(Vector2 vec2)
        {
            RecycleBuffers();
            if (this.scrollRect.horizontal)
            {
                float currentPos = -this.rectTransform.localPosition.x;

                var etor = this.cellInfoMapper.GetEnumerator();
                while (etor.MoveNext())
                {
                    CellInfo cellInfo = etor.Current.Value;
                    if (cellInfo.CanShow())
                    {
                        float distance2Mid = Mathf.Abs(cellInfo.localPos.x - currentPos);
                        if (distance2Mid <= this.visualDIA && !cellInfo.IsShowing())
                        {
                            ListViewCell buffer = GetUsableBuffer(cellInfo.index);
                            if (buffer != null)
                            {
                                buffer.SetCellInfo(cellInfo, this);
                                this.Adapter.FillItemData(buffer, cellInfo.index);
                            }
                        }
                    }
                }
                etor.Dispose();
            }
            else if (this.scrollRect.vertical)
            {
                float currentPos = -this.rectTransform.localPosition.y;

                var etor = this.cellInfoMapper.GetEnumerator();
                while (etor.MoveNext())
                {
                    CellInfo cellInfo = etor.Current.Value;
                    if (cellInfo.CanShow())
                    {
                        float distance2Mid = Mathf.Abs(cellInfo.localPos.y - currentPos);
                        if (distance2Mid <= this.visualDIA && !cellInfo.IsShowing())
                        {
                            ListViewCell buffer = GetUsableBuffer(cellInfo.index);
                            if (buffer != null)
                            {
                                buffer.SetCellInfo(cellInfo, this);
                                this.Adapter.FillItemData(buffer, cellInfo.index);
                            }
                        }
                    }
                }
                etor.Dispose();
            }
        }
        protected override float CalculateSizeAndCellPos(float beyondDistance)
        {
            for (int i = 0; i < this.CellsCount; i++)
            {
                CellInfo     cellInfo    = this.Adapter.GetCellInfo(i);
                int          prefabIndex = this.Adapter.GetCellPrefabIndex(i);
                ListViewCell cell        = GameObject.Instantiate <GameObject>(this.prefabs[prefabIndex]).GetComponent <ListViewCell>();
                cell.gameObject.SetActive(true);
                cell.transform.SetParent(transform);
                cell.transform.localScale = Vector3.one;
                this.Adapter.FillItemData(cell, i);
            }

            return(this.CellsCount);
        }
Exemple #5
0
 private void ForceRecycleAllBuffers()
 {
     for (int i = 0; i < this.buffersArray.Length; i++)
     {
         List <ListViewCell> buffers = this.buffersArray[i];
         for (int j = 0; j < buffers.Count; j++)
         {
             ListViewCell buffer = buffers[j];
             if (buffer.IsUsing)
             {
                 buffer.Recycle();
             }
         }
     }
 }
Exemple #6
0
 private void RecycleBuffers()
 {
     if (this.scrollRect.horizontal)
     {
         float currentPos = -this.rectTransform.localPosition.x;
         for (int i = 0; i < this.buffersArray.Length; i++)
         {
             List <ListViewCell> buffers = this.buffersArray[i];
             for (int j = 0; j < buffers.Count; j++)
             {
                 ListViewCell buffer       = buffers[j];
                 float        distance2Mid = Mathf.Abs(buffer.CellInfo.localPos.x - currentPos);
                 if (buffer.IsUsing && distance2Mid > this.visualDIA)
                 {
                     buffer.Recycle();
                 }
             }
         }
     }
     else if (this.scrollRect.vertical)
     {
         float currentPos = -this.rectTransform.localPosition.y;
         for (int i = 0; i < this.buffersArray.Length; i++)
         {
             List <ListViewCell> buffers = this.buffersArray[i];
             for (int j = 0; j < buffers.Count; j++)
             {
                 ListViewCell buffer       = buffers[j];
                 float        distance2Mid = Mathf.Abs(buffer.CellInfo.localPos.y - currentPos);
                 if (buffer.IsUsing && distance2Mid > this.visualDIA)
                 {
                     buffer.Recycle();
                 }
             }
         }
     }
 }
Exemple #7
0
 public virtual void FillItemData(ListViewCell item, int cellindex)
 {
     item.FillData(cellindex);
 }