public IrDataWrapper this[int index]
        {
            get
            {
                var info = PositionalViewSelector?.GetInfo(index);

                if (info == null)
                {
                    return(default);
Ejemplo n.º 2
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var info = positionalViewSelector.GetInfo(position);

            if (info == null)
            {
                return;
            }

            // The template selector doesn't infer selected properly
            // so we need to ask the listview which tracks selections about the state
            info.IsSelected = info.Kind == PositionKind.Item &&
                              (handler?.VirtualView?.IsItemSelected(info.SectionIndex, info.ItemIndex) ?? false);

            if (holder is RvItemHolder itemHolder)
            {
                var data = info.Kind switch {
                    PositionKind.Item =>
                    positionalViewSelector?.Adapter?.Item(info.SectionIndex, info.ItemIndex),
                    PositionKind.SectionHeader =>
                    positionalViewSelector?.Adapter?.Section(info.SectionIndex),
                    PositionKind.SectionFooter =>
                    positionalViewSelector?.Adapter?.Section(info.SectionIndex),
                    _ => null
                };

                if (!itemHolder.HasView)
                {
                    var view = positionalViewSelector?.ViewSelector?.CreateView(info, data);
                    itemHolder.SwapView(view);
                }

                itemHolder.Update(info);

                positionalViewSelector?.ViewSelector?.RecycleView(info, data, itemHolder.ViewContainer.VirtualView);
            }
        }

        List <string> cachedReuseIds = new List <string>();