Esempio n. 1
0
		protected void WireUpForceUpdateSizeRequested(ICellController cell, UITableViewCell nativeCell, UITableView tableView)
		{
			cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested;

			_onForceUpdateSizeRequested = (sender, e) => 
			{
				var index = tableView.IndexPathForCell(nativeCell);
				if (index != null)
					tableView.ReloadRows(new[] { index }, UITableViewRowAnimation.None);
			};

			cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested;
		}
Esempio n. 2
0
        protected void WireUpForceUpdateSizeRequested(Cell cell, AView nativeCell)
        {
            ICellController cellController = cell;

            cellController.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested;

            _onForceUpdateSizeRequested = (sender, e) =>
            {
                if (nativeCell.Handle == IntPtr.Zero)
                {
                    return;
                }
                // RenderHeight may not be changed, but that's okay, since we
                // don't actually use the height argument in the OnMeasure override.
                nativeCell.Measure(nativeCell.Width, (int)cell.RenderHeight);
                nativeCell.SetMinimumHeight(nativeCell.MeasuredHeight);
                nativeCell.SetMinimumWidth(nativeCell.MeasuredWidth);
            };

            cellController.ForceUpdateSizeRequested += _onForceUpdateSizeRequested;
        }
Esempio n. 3
0
        public override AView GetView(int position, AView convertView, ViewGroup parent)
        {
            Cell cell = null;

            Performance.Start();

            ListViewCachingStrategy cachingStrategy = Controller.CachingStrategy;
            var nextCellIsHeader = false;

            if (cachingStrategy == ListViewCachingStrategy.RetainElement || convertView == null)
            {
                if (_listView.IsGroupingEnabled)
                {
                    List <Cell> cells = GetCellsFromPosition(position, 2);
                    if (cells.Count > 0)
                    {
                        cell = cells[0];
                    }

                    if (cells.Count == 2)
                    {
                        nextCellIsHeader = cells[1].GetIsGroupHeader <ItemsView <Cell>, Cell>();
                    }
                }

                if (cell == null)
                {
                    cell = GetCellForPosition(position);
                    if (cell == null)
                    {
                        return(new AView(_context));
                    }
                }
            }

            var cellIsBeingReused = false;
            var layout            = convertView as ConditionalFocusLayout;

            if (layout != null)
            {
                cellIsBeingReused = true;
                convertView       = layout.GetChildAt(0);
            }
            else
            {
                layout = new ConditionalFocusLayout(_context)
                {
                    Orientation = Orientation.Vertical
                }
            };

            if (cachingStrategy == ListViewCachingStrategy.RecycleElement && convertView != null)
            {
                var boxedCell = convertView as INativeElementView;
                if (boxedCell == null)
                {
                    throw new InvalidOperationException($"View for cell must implement {nameof(INativeElementView)} to enable recycling.");
                }
                cell = (Cell)boxedCell.Element;

                // We are going to re-set the Platform here because in some cases (headers mostly) its possible this is unset and
                // when the binding context gets updated the measure passes will all fail. By applying this here the Update call
                // further down will result in correct layouts.
                cell.Platform = _listView.Platform;

                ICellController cellController = cell;
                cellController.SendDisappearing();

                int row            = position;
                var group          = 0;
                var templatedItems = TemplatedItemsView.TemplatedItems;
                if (_listView.IsGroupingEnabled)
                {
                    group = templatedItems.GetGroupIndexFromGlobal(position, out row);
                }

                var templatedList = templatedItems.GetGroup(group);

                if (_listView.IsGroupingEnabled)
                {
                    if (row == 0)
                    {
                        templatedList.UpdateHeader(cell, group);
                    }
                    else
                    {
                        templatedList.UpdateContent(cell, row - 1);
                    }
                }
                else
                {
                    templatedList.UpdateContent(cell, row);
                }

                cellController.SendAppearing();

                if (cell.BindingContext == ActionModeObject)
                {
                    ActionModeContext = cell;
                    ContextView       = layout;
                }

                if (ReferenceEquals(_listView.SelectedItem, cell.BindingContext))
                {
                    Select(_listView.IsGroupingEnabled ? row - 1 : row, layout);
                }
                else if (cell.BindingContext == ActionModeObject)
                {
                    SetSelectedBackground(layout, true);
                }
                else
                {
                    UnsetSelectedBackground(layout);
                }

                Performance.Stop();
                return(layout);
            }

            AView view = CellFactory.GetCell(cell, convertView, parent, _context, _listView);

            Performance.Start("AddView");

            if (cellIsBeingReused)
            {
                if (convertView != view)
                {
                    layout.RemoveViewAt(0);
                    layout.AddView(view, 0);
                }
            }
            else
            {
                layout.AddView(view, 0);
            }

            Performance.Stop("AddView");

            bool isHeader = cell.GetIsGroupHeader <ItemsView <Cell>, Cell>();

            AView bline;

            UpdateSeparatorVisibility(cell, cellIsBeingReused, isHeader, nextCellIsHeader, layout, out bline);

            UpdateSeparatorColor(isHeader, bline);

            if ((bool)cell.GetValue(IsSelectedProperty))
            {
                Select(position, layout);
            }
            else
            {
                UnsetSelectedBackground(layout);
            }

            layout.ApplyTouchListenersToSpecialCells(cell);

            Performance.Stop();

            return(layout);
        }
 public XMLCellModel(XMLWorksheetModel sheet, PartManager manager, CT_Cell cell)
 {
     this._cell       = cell;
     this._controller = new XMLCellController(cell, sheet, manager);
     this.FixCellValue();
 }
Esempio n. 5
0
        public override AView GetView(int position, AView convertView, ViewGroup parent)
        {
            Cell cell = null;

            Performance.Start(out string reference);

            ListViewCachingStrategy cachingStrategy = Controller.CachingStrategy;
            var nextCellIsHeader = false;

            if (cachingStrategy == ListViewCachingStrategy.RetainElement || convertView == null)
            {
                if (_listView.IsGroupingEnabled)
                {
                    List <Cell> cells = GetCellsFromPosition(position, 2);
                    if (cells.Count > 0)
                    {
                        cell = cells[0];
                    }

                    if (cells.Count == 2)
                    {
                        nextCellIsHeader = cells[1].GetIsGroupHeader <ItemsView <Cell>, Cell>();
                    }
                }

                if (cell == null)
                {
                    cell = GetCellForPosition(position);

                    if (cell == null)
                    {
                        Performance.Stop(reference);

                        return(new AView(_context));
                    }
                }
            }

            var cellIsBeingReused = false;
            var layout            = convertView as Handlers.Compatibility.ConditionalFocusLayout;

            if (layout != null)
            {
                cellIsBeingReused = true;
                convertView       = layout.GetChildAt(0);
            }
            else
            {
                layout = new Handlers.Compatibility.ConditionalFocusLayout(_context)
                {
                    Orientation = Orientation.Vertical
                };
                _layoutsCreated.Add(layout);
            }

            if (((cachingStrategy & ListViewCachingStrategy.RecycleElement) != 0) && convertView != null)
            {
                var boxedCell = convertView as INativeElementView;
                if (boxedCell == null)
                {
                    throw new InvalidOperationException($"View for cell must implement {nameof(INativeElementView)} to enable recycling.");
                }
                cell = (Cell)boxedCell.Element;

                ICellController cellController = cell;
                cellController.SendDisappearing();

                int row            = position;
                var group          = 0;
                var templatedItems = TemplatedItemsView.TemplatedItems;
                if (_listView.IsGroupingEnabled)
                {
                    group = templatedItems.GetGroupIndexFromGlobal(position, out row);
                }

                var templatedList = templatedItems.GetGroup(group);

                if (_listView.IsGroupingEnabled)
                {
                    if (row == 0)
                    {
                        templatedList.UpdateHeader(cell, group);
                    }
                    else
                    {
                        templatedList.UpdateContent(cell, row - 1);
                    }
                }
                else
                {
                    templatedList.UpdateContent(cell, row);
                }

                cellController.SendAppearing();

                if (cell.BindingContext == ActionModeObject)
                {
                    ActionModeContext = cell;
                    ContextView       = layout;
                }

                if (ReferenceEquals(_listView.SelectedItem, cell.BindingContext))
                {
                    Select(_listView.IsGroupingEnabled ? row - 1 : row, layout);
                }
                else if (cell.BindingContext == ActionModeObject)
                {
                    SetSelectedBackground(layout, true);
                }
                else
                {
                    UnsetSelectedBackground(layout);
                }

                Performance.Stop(reference);
                return(layout);
            }

            AView view = CellFactory.GetCell(cell, convertView, parent, _context, _listView);

            Performance.Start(reference, "AddView");

            if (cellIsBeingReused)
            {
                if (convertView != view)
                {
                    layout.RemoveViewAt(0);
                    layout.AddView(view, 0);
                }
            }
            else
            {
                layout.AddView(view, 0);
            }

            Performance.Stop(reference, "AddView");

            bool isHeader = cell.GetIsGroupHeader <ItemsView <Cell>, Cell>();

            AView bline;

            bool isSeparatorVisible = _listView.SeparatorVisibility == SeparatorVisibility.Default;

            if (isSeparatorVisible)
            {
                UpdateSeparatorVisibility(cell, cellIsBeingReused, isHeader, nextCellIsHeader, isSeparatorVisible, layout, out bline);

                UpdateSeparatorColor(isHeader, bline);
            }
            else if (layout.ChildCount > 1)
            {
                layout.RemoveViewAt(1);
            }

            if ((bool)cell.GetValue(IsSelectedProperty))
            {
                Select(position, layout);
            }
            else
            {
                UnsetSelectedBackground(layout);
            }

            layout.ApplyTouchListenersToSpecialCells(cell);

            Performance.Stop(reference);

            return(layout);
        }
Esempio n. 6
0
 public ICellControllerEvents(ICellController This)
 {
     this.This = This;
 }
Esempio n. 7
0
 public static ICellControllerEvents Events(this ICellController This)
 {
     return(new ICellControllerEvents(This));
 }
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var         realPosition = GetRealPosition(position);
            ContentCell cell         = null;

            Performance.Start(out string reference);

            var container = holder.ItemView as ContentCellContainer;

            ListViewCachingStrategy cachingStrategy = Controller.CachingStrategy;

            if (cachingStrategy == ListViewCachingStrategy.RetainElement || container.IsEmpty)
            {
                cell = (ContentCell)GetCellFromPosition(realPosition);
            }

            var cellIsBeingReused = false;

            if (container.ChildCount > 0)
            {
                cellIsBeingReused = true;
            }

            if (((cachingStrategy & ListViewCachingStrategy.RecycleElement) != 0) && !container.IsEmpty)
            {
                var boxedCell = container as INativeElementView;
                if (boxedCell == null)
                {
                    throw new InvalidOperationException($"View for cell must implement {nameof(INativeElementView)} to enable recycling.");
                }
                cell = (ContentCell)boxedCell.Element;

                // We are going to re-set the Platform here because in some cases (headers mostly) its possible this is unset and
                // when the binding context gets updated the measure passes will all fail. By applying this here the Update call
                // further down will result in correct layouts.
                cell.Platform = _collectionView.Platform;

                ICellController cellController = cell;
                cellController.SendDisappearing();

                int row            = realPosition;
                var group          = 0;
                var templatedItems = TemplatedItemsView.TemplatedItems;
                if (_collectionView.IsGroupingEnabled)
                {
                    group = templatedItems.GetGroupIndexFromGlobal(realPosition, out row);
                    if (group < 0)
                    {
                        return;
                    }
                }
                var templatedList = templatedItems.GetGroup(group);

                if (_collectionView.IsGroupingEnabled)
                {
                    if (row == 0)
                    {
                        templatedList.UpdateHeader(cell, group);
                    }
                    else
                    {
                        templatedList.UpdateContent(cell, row - 1);
                    }
                }
                else
                {
                    templatedList.UpdateContent(cell, row);
                }

                cellController.SendAppearing();

                Performance.Stop(reference);

                _recyclerView.RequestLayout();
                _recyclerView.Invalidate();

                return;
            }

            if (cell == null)
            {
                return;
            }

            AView view = GetCell(cell, container, _recyclerView, _context, _collectionView);


            Performance.Start(reference, "AddView");

            if (cellIsBeingReused)
            {
                if (container != view)
                {
                    holder.ItemView = view;
                }
            }
            else
            {
                holder.ItemView = view;
            }


            Performance.Stop(reference, "AddView");


            Performance.Stop(reference);
        }