public void RecycleCell(NativeCell view, FastCell newCell) { if (CellItemsByCoreCells.ContainsKey(view)) { var reusedItem = CellItemsByCoreCells[view]; if (OriginalBindingContextsForReusedItems.ContainsKey(newCell)) { reusedItem.BindingContext = OriginalBindingContextsForReusedItems[newCell]; } else { reusedItem.BindingContext = newCell.BindingContext; } } }
public bool IsCached(NativeCell view) { return(CellItemsByCoreCells.ContainsKey(view)); }
public void CacheCell(FastCell cell, NativeCell view) { CellItemsByCoreCells[view] = cell; OriginalBindingContextsForReusedItems[cell] = cell.BindingContext; }
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv) { cellId = cellId ?? new NSString(item.GetType().FullName); var cellCache = FastCellCache.Instance.GetCellCache(tv); var fastCell = item as FastCell; var nativeCell = reusableCell as NativeCell; var view = item as FastCell; if (reusableCell != null && cellCache.IsCached(nativeCell)) { cellCache.RecycleCell(nativeCell, fastCell); if (fastCell.SelectionMode) { nativeCell.SelectedBackgroundView = new UIView { BackgroundColor = view.SelectedBackgroundColor.ToUIColor(), }; } else { //nativeCell.SelectedBackgroundView = new UIView //{ // BackgroundColor = UIColor.Clear, //}; nativeCell.SelectionStyle = UITableViewCellSelectionStyle.None; } } else { var newCell = (FastCell)Activator.CreateInstance(item.GetType()); newCell.BindingContext = item.BindingContext; newCell.Parent = item.Parent; if (!newCell.IsInitialized) { newCell.PrepareCell(); } nativeCell = new NativeCell(cellId, newCell); cellCache.CacheCell(newCell, nativeCell); if (fastCell.SelectionMode) { nativeCell.SelectedBackgroundView = new UIView { BackgroundColor = view.SelectedBackgroundColor.ToUIColor(), }; } else { nativeCell.SelectionStyle = UITableViewCellSelectionStyle.None; } } var parentListview = fastCell.Parent as MvvmAspire.Controls.ListView; if (parentListview != null) { parentListview.Raise("ItemAppearing", new ItemVisibilityEventArgs(item.BindingContext)); } return(nativeCell); }