public void AddLine(Line newLine, GeneratorDirection fillDirection) { if (fillDirection == GeneratorDirection.Forward) { _lines.AddToBack(newLine); } else { _lines.AddToFront(newLine); Start -= newLine.Extent; } }
public void AddLine(Line newLine, GeneratorDirection fillDirection) { Debug.Assert(_lines.None(l => l.FirstItem == newLine.FirstItem), "Duplicate line detected"); if (fillDirection == GeneratorDirection.Forward) { _lines.AddToBack(newLine); } else { _lines.AddToFront(newLine); Start -= newLine.Extent; } }
/// <summary> /// Prefetch views in the target range that aren't yet in the buffer. /// </summary> private void PrefetchViews(RecyclerView.Recycler recycler, RecyclerView.State state) { if (Layout.ItemCount == 0 || CacheHalfLength == 0) { return; } PrefetchTrailing(); PrefetchLeading(); if (!_isInitiallyPopulated // The leading buffer may be empty if the previous prefetch ended early, eg because it found an unrecyclable item && LeadingBufferEnd > -1) { PrefetchExtra(); _isInitiallyPopulated = true; } CheckValidSteadyState(); void PrefetchTrailing() { if (TrailingBufferTargetSize == 0) { return; } // Seed buffer; otherwise succeeding logic fails if (_trailingBuffer.Count == 0) { if (PrefetchView(recycler, state, TrailingBufferTargetStart) is { } record) { _trailingBuffer.AddToBack(record); } else { // List is animating, etc, so forgo populating the buffer at this time return; } CheckValidState(); } while (TrailingBufferStart > TrailingBufferTargetStart) { if (PrefetchView(recycler, state, TrailingBufferStart - 1) is { } record) { _trailingBuffer.AddToFront(record); }