void SetTouchAbilityForCellHolder(UITableViewCellHolder cellHolder) { IUITableViewTouchable touchableTarget = DelegateTarget as IUITableViewTouchable; if (touchableTarget != null) { cellHolder.Cell.onTouched += OnTouchedForRow; } }
void EnqueueReusableCell(UITableViewCellHolder cellHolder) { if (cellHolder.Cell == null/* || _reusableCellQueueDictionary == null*/) { return; } DataSource.CellForRowWillBeKilled(this, cellHolder.Cell.Index); int alreadyReuseCellNum = 0; if (_reusableCellQueueDictionary != null) { foreach (var queue in _reusableCellQueueDictionary.Values) { alreadyReuseCellNum += queue.Count; } } //destory directly then return if (alreadyReuseCellNum >= MaxReusableCellNumber || cellHolder.Cell.ReuseIndentifier == null || _reusableCellQueueDictionary == null) { DestoryCellWithoutCache(cellHolder); return; } //Add to queue bool isHasCachePool = _reusableCellQueueDictionary.ContainsKey(cellHolder.Cell.ReuseIndentifier); Queue<UITableViewCell> cachePool = null; if (!isHasCachePool) { cachePool = new Queue<UITableViewCell>(); _reusableCellQueueDictionary.Add(cellHolder.Cell.ReuseIndentifier, cachePool); } else { cachePool = _reusableCellQueueDictionary[cellHolder.Cell.ReuseIndentifier]; } cachePool.Enqueue(cellHolder.Cell); cellHolder.Cell.Index = UITableViewCell.DEFAULT_INDEX; cellHolder.Cell.onTouched = null; cellHolder.Cell.onDelete = null; cellHolder.Cell.IsDeletable = true; cellHolder.Cell.gameObject.SetActive(false); cellHolder.Cell = null; }
void SetDeletabilityForCellHolder(UITableViewCellHolder cellHolder) { IUITableViewEditable deletableTarget = DelegateTarget as IUITableViewEditable; if (deletableTarget != null) { cellHolder.Cell.onDelete += OnDeleteCellForRow; cellHolder.Cell.ChangeToStatus(_cellStatus); } }
void DestoryCellWithoutCache(UITableViewCellHolder cellHolder) { cellHolder.Cell.onTouched = null; cellHolder.Cell.onDelete = null; cellHolder.Cell.IsDeletable = true; UITableViewCell cell = cellHolder.Cell; cellHolder.Cell = null; NGUITools.Destroy(cell.gameObject); }