/// <summary>
        /// Gets the cell.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="reusableCell">The reusable TableView cell.</param>
        /// <param name="tv">The TableView.</param>
        /// <returns>UITableViewCell.</returns>
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
		{
			var extendedCell = (ExtendedTextCell)item;

			TextCell textCell = (TextCell)item;
			UITableViewCellStyle style = UITableViewCellStyle.Subtitle;
			if (extendedCell.DetailLocation == TextCellDetailLocation.Right)
				style = UITableViewCellStyle.Value1;

			string fullName = item.GetType ().FullName;
			CellTableViewCell cell = tv.DequeueReusableCell (fullName) as CellTableViewCell;
			if (cell == null) {
				cell = new CellTableViewCell (style, fullName);
			}
			else {
				cell.Cell.PropertyChanged -= new PropertyChangedEventHandler (cell.HandlePropertyChanged);
			}
			cell.Cell = textCell;
			textCell.PropertyChanged += new PropertyChangedEventHandler (cell.HandlePropertyChanged);
			cell.PropertyChanged = new Action<object, PropertyChangedEventArgs> (HandlePropertyChanged);
			cell.TextLabel.Text = textCell.Text;
			cell.DetailTextLabel.Text = textCell.Detail;
			cell.TextLabel.TextColor = textCell.TextColor.ToUIColor (DefaultTextColor);
			cell.DetailTextLabel.TextColor = textCell.DetailColor.ToUIColor (DefaultDetailColor);

			UpdateBackground (cell, item);

			if (cell != null) {
				cell.BackgroundColor = extendedCell.BackgroundColor.ToUIColor ();
				cell.SeparatorInset = new UIEdgeInsets ((float)extendedCell.SeparatorPadding.Top, (float)extendedCell.SeparatorPadding.Left,
					(float)extendedCell.SeparatorPadding.Bottom, (float)extendedCell.SeparatorPadding.Right);

				if (extendedCell.ShowDisclousure) {
					cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
					if (!string.IsNullOrEmpty (extendedCell.DisclousureImage)) {
						var detailDisclosureButton = UIButton.FromType (UIButtonType.Custom);
						detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Normal);
						detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Selected);

						detailDisclosureButton.Frame = new CGRect (0f, 0f, 30f, 30f);
						detailDisclosureButton.TouchUpInside += (object sender, EventArgs e) => {
							var index = tv.IndexPathForCell (cell);
							tv.SelectRow (index, true, UITableViewScrollPosition.None);
							tv.Source.AccessoryButtonTapped (tv, index);
						};
						cell.AccessoryView = detailDisclosureButton;
					}
				}
			}

			if(!extendedCell.ShowSeparator)
				tv.SeparatorStyle = UITableViewCellSeparatorStyle.None;

			tv.SeparatorColor = extendedCell.SeparatorColor.ToUIColor();

			return cell;
		}
 public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
 {
     var tvc = reusableCell as CellTableViewCell;
     if (tvc == null) {
         tvc = new CellTableViewCell (UITableViewCellStyle.Value1, item.GetType().FullName);
     }
     tvc.Cell = item;
     var cell = base.GetCell(item, tvc, tv);
     cell.SetDisclosure(item.StyleId);
     return cell;
 }
Ejemplo n.º 3
0
        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;

            if (reusableCell != null && cellCache.IsCached (nativeCell, fastCell.ReuseIdentifier)) {
                cellCache.RecycleCell (nativeCell, fastCell);
            } 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);
            }
            return nativeCell;
        }
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            cellId = cellId ?? new NSString (item.GetType ().FullName);
            var nativeCell = reusableCell as NativeCell;
            var viewCell = item as FastCell;

            Device.BeginInvokeOnMainThread (new Action (viewCell.SendAppearing));

            if (reusableCell == null) {
                nativeCell = new NativeCell (cellId, viewCell);
            } else {
                nativeCell.RecycleCell (viewCell);
            }

            return nativeCell;
        }
        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;

            if (reusableCell != null && cellCache.IsCached (nativeCell)) {
                cellCache.RecycleCell (nativeCell, fastCell);
            } else {
                if (!fastCell.IsInitialized) {
                    fastCell.PrepareCell ();
                }
                nativeCell = new NativeCell (cellId, fastCell);
                cellCache.CacheCell (fastCell, nativeCell);
            }
            return nativeCell;
        }
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            EntryCellEx entryCell = (EntryCellEx)item;
            EntryCellTableViewCell entryCellTableViewCell = reusableCell as EntryCellTableViewCell;
            if (entryCellTableViewCell != null)
            {
                entryCellTableViewCell.Cell.PropertyChanged -= OnCellPropertyChanged;
                entryCellTableViewCell.TextFieldTextChanged -= OnTextFieldTextChanged;
                entryCellTableViewCell.KeyboardDoneButtonPressed -= OnKeyBoardDoneButtonPressed;

                var oldCell = entryCellTableViewCell.Cell as EntryCellEx;
                if (oldCell != null)
                {
                    oldCell.FocusRequested -= EntryCell_FocusRequested;
                }
            }
            else
            {
                entryCellTableViewCell = new EntryCellTableViewCell(item.GetType().FullName);
            }

            SetMyRealCell(item, entryCellTableViewCell);
            entryCellTableViewCell.Cell = item;
            entryCellTableViewCell.Cell.PropertyChanged += OnCellPropertyChanged;
            entryCell.FocusRequested += EntryCell_FocusRequested;
            entryCellTableViewCell.TextFieldTextChanged += OnTextFieldTextChanged;
            entryCellTableViewCell.KeyboardDoneButtonPressed += OnKeyBoardDoneButtonPressed;
            base.UpdateBackground(entryCellTableViewCell, entryCell);
            UpdateLabel(entryCellTableViewCell, entryCell);
            UpdateText(entryCellTableViewCell, entryCell);
            UpdateKeyboard(entryCellTableViewCell, entryCell);
            UpdatePlaceholder(entryCellTableViewCell, entryCell);
            UpdateLabelColor(entryCellTableViewCell, entryCell);
            UpdateXAlign(entryCellTableViewCell, entryCell);
            UpdateIsEnabled(entryCellTableViewCell, entryCell);

            if (entryCell.RequestInitialFocus)
            {
                entryCellTableViewCell.TextField.BecomeFirstResponder();
                entryCell.RequestInitialFocus = false;
            }

            return entryCellTableViewCell;
        }
        //TODO add a lookup for the cells we piggy back of.
        protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context)
        {
            var cellCache = FastCellCache.Instance.GetCellCache (parent);
            var fastCell = item as FastCell;

            Android.Views.View cellCore = convertView;

            if (cellCore != null && cellCache.IsCached (cellCore)) {
                cellCache.RecycleCell (cellCore, fastCell);
            } else {
                var newCell = (FastCell) Activator.CreateInstance (item.GetType ());
                newCell.BindingContext = item.BindingContext;
                newCell.Parent = item.Parent;

                if (!newCell.IsInitialized) {
                    newCell.PrepareCell ();
                }
                cellCore = base.GetCellCore (newCell, convertView, parent, context);
                cellCache.CacheCell (newCell, cellCore);
            }
            return cellCore;
        }