private void UpdateCurrentLocation(UILongPressGestureRecognizer gesture) { NSIndexPath indexPath = null; var location = new PointF(); // refresh index path location = gesture.LocationInView(this); indexPath = IndexPathForRowAtPoint(location); indexPath = Source.CustomizeMoveTarget(this, initialIndexPath, indexPath); // if (RespondsToSelector(tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:)]) { // indexPath = TargetIndexPathForMoveFromRowAtIndexPath(InitialIndexPath, indexPath); // } var oldHeight = RectForRowAtIndexPath(currentLocationIndexPath).Size.Height; var newHeight = RectForRowAtIndexPath(indexPath).Size.Height; if (indexPath != null && !indexPath.Equals(currentLocationIndexPath) && gesture.LocationInView(CellAt(indexPath)).Y > newHeight - oldHeight) { BeginUpdates(); DeleteRows(new NSIndexPath[] { currentLocationIndexPath }, UITableViewRowAnimation.Automatic); InsertRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic); ((IReorder)Source).MoveRowAtIndexPath(currentLocationIndexPath, indexPath); currentLocationIndexPath = indexPath; EndUpdates(); } }
public UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { var cell = (ScratchCell)collectionView.DequeueReusableCell(ScratchCell.Id, indexPath); cell.HasBananas = indexPath.Equals(bananaPath); return(cell); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { MenuTableViewCell cell = tableView.DequeueReusableCell(MenuTableViewCell.key) as MenuTableViewCell; cell.InitCell(Constants.menuItems[indexPath.Row], Constants.menuItemsImages[indexPath.Row]); if (indexPath.Equals(selectedIndexPath)) { cell.SetSelected(true, false); } return(cell); }
public override UICollectionViewCell GetCell (UICollectionView collectionView, NSIndexPath indexPath) { var cell = (ExistingImageCollectionViewCell)collectionView.DequeueReusableCell (cellReuseIdentifier, indexPath); cell = cell ?? new ExistingImageCollectionViewCell (); cell.ThumbnailImage.Image = view.imageRecords [indexPath.Row].Thumbnail; bool isLoading = indexPath != null && indexPath.Equals (view.currentLoadingIndex); cell.SetLoading (isLoading); return cell; }
internal UITableViewCell CellAt(UITableView view, NSIndexPath path) { if (path == null) { return(null); } if (_lastCreatedCellPath != null && path.Equals(_lastCreatedCellPath)) { return(_lastCreatedCell); } return(view.CellAt(path)); }
public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { var cell = (ExistingImageCollectionViewCell)collectionView.DequeueReusableCell(cellReuseIdentifier, indexPath); cell = cell ?? new ExistingImageCollectionViewCell(); cell.ThumbnailImage.Image = view.imageRecords [indexPath.Row].Thumbnail; bool isLoading = indexPath != null && indexPath.Equals(view.currentLoadingIndex); cell.SetLoading(isLoading); return(cell); }
public static nfloat DefaultGetHeightForRow(this IKeepLastCell content, UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell; if (indexPath.Equals(content.LastIndexPath)) { cell = content.LastCell; } else { cell = content.GetCell(tableView, indexPath); } return(cell.Bounds.Height); }
internal UICollectionViewCell CellForItem(UICollectionView view, NSIndexPath path) { if (path == null) { return(null); } UICollectionViewCell cell = view.CellForItem(path); if (cell != null) { return(cell); } if (_lastCreatedCellPath != null && path.Equals(_lastCreatedCellPath)) { return(_lastCreatedCell); } return(null); }
void WarpToIndexPath(NSIndexPath indexPath) { if (indexPath == null || lastIndexPath.Equals(indexPath)) { return; } lastIndexPath = indexPath; if (this.CollectionView.DataSource.RespondsToSelector(new Selector("collectionView:canMoveItemAtIndexPath:toIndexPath:")) == true && ((UICollectionViewDataSourceDraggable)this.CollectionView.DataSource).CollectionViewCanMoveItemAtIndexPathToIndexPath(this.CollectionView, this.LayoutHelper.FromIndexPath, indexPath) == false) { return; } this.CollectionView.PerformBatchUpdates(delegate() { this.LayoutHelper.HideIndexPath = indexPath; this.LayoutHelper.ToIndexPath = indexPath; }, null); }
internal UICollectionViewCell CellForItem(UICollectionView view, NSIndexPath path) { if (path == null) return null; UICollectionViewCell cell = view.CellForItem(path); if (cell != null) return cell; if (_lastCreatedCellPath != null && path.Equals(_lastCreatedCellPath)) return _lastCreatedCell; return null; }
public ArrayList ModifiedLayoutAttributesForElements(ArrayList elements) { UICollectionView collectionView = this.CollectionViewLayout.CollectionView; NSIndexPath fromIndexPath = this.FromIndexPath; NSIndexPath toIndexPath = this.ToIndexPath; NSIndexPath hideIndexPath = this.HideIndexPath; NSIndexPath indexPathToRemove = null; if (toIndexPath == null) { if (hideIndexPath == null) { return(elements); } foreach (UICollectionViewLayoutAttributes layoutAttributes in elements) { if (layoutAttributes.RepresentedElementCategory != UICollectionElementCategory.Cell) { continue; } if (layoutAttributes.IndexPath.Equals(hideIndexPath)) { layoutAttributes.Hidden = true; } } return(elements); } if (fromIndexPath.Section != toIndexPath.Section) { indexPathToRemove = NSIndexPath.FromItemSection(collectionView.NumberOfItemsInSection(fromIndexPath.Section) - 1, fromIndexPath.Section); } foreach (UICollectionViewLayoutAttributes layoutAttributes in elements) { if (layoutAttributes.RepresentedElementCategory != UICollectionElementCategory.Cell) { continue; } if (layoutAttributes.IndexPath.Equals(indexPathToRemove)) { layoutAttributes.IndexPath = NSIndexPath.FromItemSection(collectionView.NumberOfItemsInSection(toIndexPath.Section), toIndexPath.Section); if (layoutAttributes.IndexPath.Item != 0) { layoutAttributes.Center = this.CollectionViewLayout.LayoutAttributesForItem(layoutAttributes.IndexPath).Center; } } NSIndexPath indexPath = layoutAttributes.IndexPath; if (indexPath.Equals(hideIndexPath)) { layoutAttributes.Hidden = true; } if (indexPath.Equals(toIndexPath)) { layoutAttributes.IndexPath = fromIndexPath; } else if (fromIndexPath.Section != toIndexPath.Section) { if (indexPath.Section == fromIndexPath.Section && indexPath.Item >= fromIndexPath.Item) { layoutAttributes.IndexPath = NSIndexPath.FromItemSection(indexPath.Item + 1, indexPath.Section); } else if (indexPath.Section == toIndexPath.Section && indexPath.Item >= toIndexPath.Item) { layoutAttributes.IndexPath = NSIndexPath.FromItemSection(indexPath.Item - 1, indexPath.Section); } } else if (indexPath.Section == fromIndexPath.Section) { if (indexPath.Item <= fromIndexPath.Item && indexPath.Item > toIndexPath.Item) { layoutAttributes.IndexPath = NSIndexPath.FromItemSection(indexPath.Item - 1, indexPath.Section); } else if (indexPath.Item >= fromIndexPath.Item && indexPath.Item < toIndexPath.Item) { layoutAttributes.IndexPath = NSIndexPath.FromItemSection(indexPath.Item + 1, indexPath.Section); } } } return(elements); }
internal UITableViewCell CellAt(UITableView view, NSIndexPath path) { if (path == null) return null; if (_lastCreatedCellPath != null && path.Equals(_lastCreatedCellPath)) return _lastCreatedCell; return view.CellAt(path); }