Ejemplo n.º 1
0
        /// <summary>
        /// Send view that was unbuffered or scrolled out of view to the intermediate cache.
        /// </summary>
        private void SendToIntermediateCache(RecyclerView.Recycler recycler, ElementViewRecord viewRecord)
        {
            if (viewRecord.IsEmpty)
            {
                if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                {
                    this.Log().Debug("Discarding empty record.");
                }
                return;
            }

            NotifyViewRecycled(viewRecord.ViewHolder);

            // Send to intermediate cache
            var views = _intermediateCache.FindOrCreate(viewRecord.ViewHolder.ItemViewType, () => new List <UnoViewHolder>());

            if (!viewRecord.ViewHolder.IsRecyclable)
            {
                //Item is probably animating, we throw it back to the recycler rather than just detaching it to prevent the following error: "java.lang.IllegalArgumentException: Tmp detached view should be removed from RecyclerView before it can be recycled"
                Layout.RemoveAndRecycleView(viewRecord.View, recycler);
                return;
            }

            Layout.TryDetachView(viewRecord.View);

            views.Add(viewRecord.ViewHolder);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Detach view that was visible and send it to the cache.
        /// </summary>
        public void DetachAndCacheView(View view, RecyclerView.Recycler recycler)
        {
            var holder = _owner.GetChildViewHolder(view) as UnoViewHolder;
            var record = new ElementViewRecord(holder.LayoutPosition, holder);

            Layout.TryDetachView(view);
            SendToIntermediateCache(recycler, record);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Send view that was unbuffered or scrolled out of view to the intermediate cache.
        /// </summary>
        private void SendToIntermediateCache(RecyclerView.Recycler recycler, ElementViewRecord viewRecord)
        {
            if (viewRecord.IsEmpty)
            {
                if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                {
                    this.Log().Debug("Discarding empty record.");
                }
                return;
            }

            var isGenerated = (viewRecord.View as ContentControl)?.IsGeneratedContainer ?? false;

            if (!isGenerated)
            {
                // If it's not a generated container then it must be an item that returned true for IsItemItsOwnContainerOverride (eg an
                // explicitly-defined ListViewItem), and shouldn't be recycled for a different item.
                Layout.RemoveView(viewRecord.View);
                return;
            }

            NotifyViewRecycled(viewRecord.ViewHolder);

            // Send to intermediate cache
            var views = _intermediateCache.FindOrCreate(viewRecord.ViewHolder.ItemViewType, () => new List <UnoViewHolder>());

            if (!viewRecord.ViewHolder.IsRecyclable)
            {
                //Item is probably animating, we throw it back to the recycler rather than just detaching it to prevent the following error: "java.lang.IllegalArgumentException: Tmp detached view should be removed from RecyclerView before it can be recycled"
                Layout.RemoveAndRecycleView(viewRecord.View, recycler);
                return;
            }

            Layout.TryDetachView(viewRecord.View);

            views.Add(viewRecord.ViewHolder);
        }