Esempio n. 1
0
        void BindContentView(ContentViewHolder holder, Cell formsCell, int position)
        {
            AView nativeCell = null;
            AView layout     = holder.ItemView;

            holder.SectionIndex = CellCaches[position].SectionIndex;
            holder.RowIndex     = CellCaches[position].RowIndex;

            nativeCell = holder.Body.GetChildAt(0);
            if (nativeCell != null)
            {
                holder.Body.RemoveViewAt(0);
            }

            nativeCell = CellFactory.GetCell(formsCell, nativeCell, _recyclerView, _context, _settingsView);

            if (position == _selectedIndex)
            {
                DeselectRow();
                nativeCell.Selected = true;

                _preSelectedCell = nativeCell;
            }

            var minHeight = (int)Math.Max(_context.ToPixels(_settingsView.RowHeight), MinRowHeight);

            //it is neccesary to set both
            layout.SetMinimumHeight(minHeight);
            nativeCell.SetMinimumHeight(minHeight);

            if (!_settingsView.HasUnevenRows)
            {
                //if not Uneven, set the larger one of RowHeight and MinRowHeight.
                layout.LayoutParameters.Height = minHeight;
            }
            else if (formsCell.Height > -1)
            {
                //if the cell itself was specified height, set it.
                layout.SetMinimumHeight((int)_context.ToPixels(formsCell.Height));
                layout.LayoutParameters.Height = (int)_context.ToPixels(formsCell.Height);
            }
            else
            {
                layout.LayoutParameters.Height = -2; //wrap_content
            }

            if (!CellCaches[position].IsLastCell || _settingsView.ShowSectionTopBottomBorder)
            {
                holder.Border.SetBackgroundColor(_settingsView.SeparatorColor.ToAndroid());
            }
            else
            {
                holder.Border.SetBackgroundColor(Android.Graphics.Color.Transparent);
            }

            holder.Body.AddView(nativeCell, 0);
        }
        void BindContentView(ContentViewHolder holder, int position)
        {
            var   formsCell  = holder.RowInfo.Cell;
            AView nativeCell = null;
            AView layout     = holder.ItemView;

            holder.RowInfo = _proxy[position];

            nativeCell = holder.Body.GetChildAt(0);
            if (nativeCell != null)
            {
                holder.Body.RemoveViewAt(0);
            }

            nativeCell = CellFactory.GetCell(formsCell, nativeCell, _recyclerView, _context, _settingsView);

            if (position == _selectedIndex)
            {
                DeselectRow();
                nativeCell.Selected = true;

                _preSelectedCell = nativeCell;
            }

            var minHeight = (int)Math.Max(_context.ToPixels(_settingsView.RowHeight), MinRowHeight);

            //it is neccesary to set both
            layout.SetMinimumHeight(minHeight);
            nativeCell.SetMinimumHeight(minHeight);

            if (!_settingsView.HasUnevenRows)
            {
                // if not Uneven, set the larger one of RowHeight and MinRowHeight.
                layout.LayoutParameters.Height = minHeight;
            }
            else if (formsCell.Height > -1)
            {
                // if the cell itself was specified height, set it.
                layout.SetMinimumHeight((int)_context.ToPixels(formsCell.Height));
                layout.LayoutParameters.Height = (int)_context.ToPixels(formsCell.Height);
            }
            else if (formsCell is ViewCell viewCell)
            {
                // if used a viewcell, calculate the size and layout it.
                var size = viewCell.View.Measure(_settingsView.Width, double.PositiveInfinity);
                viewCell.View.Layout(new Rectangle(0, 0, size.Request.Width, size.Request.Height));
                layout.LayoutParameters.Height = (int)_context.ToPixels(size.Request.Height);
            }
            else
            {
                layout.LayoutParameters.Height = -2; //wrap_content
            }

            holder.Body.AddView(nativeCell, 0);
        }
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            var container  = new ContentCellContainer(_context);
            var viewHolder = new ContentViewHolder(_collectionViewRenderer, container);

            if (viewType < DefaultGroupHeaderTemplateId)
            {
                viewHolder.ItemView.SetOnClickListener(this);
                viewHolder.ItemView.SetOnLongClickListener(this);
            }

            _viewHolders.Add(viewHolder);

            return(viewHolder);
        }
        /// <summary>
        /// Ons the create view holder.
        /// </summary>
        /// <returns>The create view holder.</returns>
        /// <param name="parent">Parent.</param>
        /// <param name="viewType">View type.</param>
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            ViewHolder viewHolder;

            var inflater = LayoutInflater.FromContext(_context);

            switch ((ViewType)viewType)
            {
            case ViewType.TextHeader:
                viewHolder = new HeaderViewHolder(inflater.Inflate(Resource.Layout.HeaderCell, parent, false));
                break;

            case ViewType.TextFooter:
                viewHolder = new FooterViewHolder(inflater.Inflate(Resource.Layout.FooterCell, parent, false));
                break;

            case ViewType.CustomHeader:
                var hContainer = new HeaderFooterContainer(_context);
                viewHolder = new CustomHeaderViewHolder(hContainer);
                break;

            case ViewType.CustomFooter:
                var fContainer = new HeaderFooterContainer(_context);
                viewHolder = new CustomFooterViewHolder(fContainer);
                break;

            default:
                viewHolder = new ContentViewHolder(inflater.Inflate(Resource.Layout.ContentCell, parent, false));
                viewHolder.ItemView.SetOnClickListener(this);
                viewHolder.ItemView.SetOnLongClickListener(this);
                break;
            }

            _viewHolders.Add(viewHolder);

            inflater.Dispose();

            return(viewHolder);
        }
Esempio n. 5
0
        /// <summary>
        /// Ons the create view holder.
        /// </summary>
        /// <returns>The create view holder.</returns>
        /// <param name="parent">Parent.</param>
        /// <param name="viewType">View type.</param>
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            ViewHolder viewHolder;

            switch (viewType)
            {
            case ViewTypeHeader:
                viewHolder = new HeaderViewHolder(LayoutInflater.FromContext(_context).Inflate(Resource.Layout.HeaderCell, parent, false), _settingsView);
                break;

            case ViewTypeFooter:
                viewHolder = new FooterViewHolder(LayoutInflater.FromContext(_context).Inflate(Resource.Layout.FooterCell, parent, false), _settingsView);
                break;

            default:
                viewHolder = new ContentViewHolder(LayoutInflater.FromContext(_context).Inflate(Resource.Layout.ContentCell, parent, false));
                viewHolder.ItemView.SetOnClickListener(this);
                break;
            }

            _viewHolders.Add(viewHolder);

            return(viewHolder);
        }