internal override FlexibleViewViewHolder OnFocusSearchFailed(FlexibleViewViewHolder focused, FlexibleViewLayoutManager.Direction direction, FlexibleViewRecycler recycler) { if (ChildCount == 0) { return(null); } int layoutDir = ConvertFocusDirectionToLayoutDirection(direction); if (layoutDir == LayoutState.INVALID_LAYOUT) { return(null); } int maxScroll = (int)(MAX_SCROLL_FACTOR * orientationHelper.GetTotalSpace()); UpdateLayout(layoutDir, maxScroll, false); mLayoutState.ScrollingOffset = LayoutState.SCROLLING_OFFSET_NaN; mLayoutState.Recycle = false; Fill(recycler, mLayoutState, true, true); FlexibleViewViewHolder nextFocus; if (layoutDir == LayoutState.LAYOUT_START) { nextFocus = GetChildAt(0); } else { nextFocus = GetChildAt(ChildCount - 1); } return(nextFocus); }
private void ScrapOrRecycleView(FlexibleViewRecycler recycler, FlexibleViewViewHolder itemView) { recycler.ScrapView(itemView); }
private float Fill(FlexibleViewRecycler recycler, LayoutState layoutState, bool stopOnFocusable, bool immediate) { float start = layoutState.Available; if (layoutState.ScrollingOffset != LayoutState.SCROLLING_OFFSET_NaN) { // TODO ugly bug fix. should not happen if (layoutState.Available < 0) { layoutState.ScrollingOffset += layoutState.Available; } if (immediate == true) { RecycleByLayoutState(recycler, layoutState, true); } } float remainingSpace = layoutState.Available + layoutState.Extra; LayoutChunkResult layoutChunkResult = mLayoutChunkResult; while ((remainingSpace > 0) && layoutState.HasMore(ItemCount)) { layoutChunkResult.ResetInternal(); LayoutChunk(recycler, layoutState, layoutChunkResult); if (layoutChunkResult.Finished) { break; } layoutState.Offset += layoutChunkResult.Consumed * layoutState.LayoutDirection; // Consume the available space if: // layoutChunk did not request to be ignored // OR we are laying out scrap children // OR we are not doing pre-layout if (!layoutChunkResult.IgnoreConsumed) { layoutState.Available -= layoutChunkResult.Consumed; // we keep a separate remaining space because mAvailable is important for recycling remainingSpace -= layoutChunkResult.Consumed; } if (layoutState.ScrollingOffset != LayoutState.SCROLLING_OFFSET_NaN) { layoutState.ScrollingOffset += layoutChunkResult.Consumed; if (layoutState.Available < 0) { layoutState.ScrollingOffset += layoutState.Available; } if (immediate == true) { RecycleByLayoutState(recycler, layoutState, true); } } if (stopOnFocusable && layoutChunkResult.Focusable) { break; } } if (immediate == false) { RecycleByLayoutState(recycler, layoutState, false); } return(start - layoutState.Available); }
public abstract void OnLayoutChildren(FlexibleViewRecycler recycler);
internal virtual FlexibleViewViewHolder OnFocusSearchFailed(FlexibleViewViewHolder focused, FlexibleViewLayoutManager.Direction direction, FlexibleViewRecycler recycler) { return(null); }
internal bool GetRectOfVisibleChild(FlexibleView parent, FlexibleViewViewHolder child, FlexibleViewRecycler recycler, bool immediate) { Vector2 amounts = GetRectOfVisibleChildScrollAmount(parent, child); float dx = amounts[0]; float dy = amounts[1]; amounts.Dispose(); if (dx != 0 || dy != 0) { if (dx != 0 && CanScrollHorizontally()) { ScrollHorizontallyBy(dx, recycler, immediate); } else if (dy != 0 && CanScrollVertically()) { ScrollVerticallyBy(dy, recycler, immediate); } return(true); } return(false); }
public virtual float ScrollVerticallyBy(float dy, FlexibleViewRecycler recycler, bool immediate) { return(0); }
/** * Requests that the given child of the FlexibleViewRecyclerView be positioned onto the screen. This * method can be called for both unfocusable and focusable child views. For unfocusable * child views, focusedChildVisible is typically true in which case, layout manager * makes the child view visible only if the currently focused child stays in-bounds of RV. * @param parent The parent FlexibleViewRecyclerView. * @param child The direct child making the request. * @param rect The rectangle in the child's coordinates the child * wishes to be on the screen. * @param immediate True to forbid animated or delayed scrolling, * false otherwise * @param focusedChildVisible Whether the currently focused view must stay visible. * @return Whether the group scrolled to handle the operation */ internal bool RequestChildRectangleOnScreen(FlexibleView parent, FlexibleViewViewHolder child, FlexibleViewRecycler recycler, bool immediate) { Vector2 scrollAmount = GetChildRectangleOnScreenScrollAmount(parent, child); float dx = scrollAmount[0]; float dy = scrollAmount[1]; if (dx != 0 || dy != 0) { if (dx != 0 && CanScrollHorizontally()) { ScrollHorizontallyBy(dx, recycler, immediate); } else if (dy != 0 && CanScrollVertically()) { ScrollVerticallyBy(dy, recycler, immediate); } return(true); } return(false); }
internal override void LayoutChunk(FlexibleViewRecycler recycler, LayoutState layoutState, LayoutChunkResult result) { bool layingOutInPrimaryDirection = layoutState.ItemDirection == LayoutState.ITEM_DIRECTION_TAIL; int count = spanCount; for (int i = 0; i < count; i++) { FlexibleViewViewHolder holder = layoutState.Next(recycler); if (holder == null) { result.Finished = true; return; } if (layingOutInPrimaryDirection) { AddView(holder); } else { AddView(holder, 0); } result.Consumed = orientationHelper.GetViewHolderMeasurement(holder); float left, top, width, height; if (Orientation == VERTICAL) { width = (Width - PaddingLeft - PaddingRight) / count; height = result.Consumed; if (layoutState.LayoutDirection == LayoutState.LAYOUT_END) { left = PaddingLeft + width * i; top = layoutState.Offset; } else { left = PaddingLeft + width * (count - 1 - i); top = layoutState.Offset - height; } LayoutChild(holder, left, top, width, height); } else { width = result.Consumed; height = (Height - PaddingTop - PaddingBottom) / count; if (layoutState.LayoutDirection == LayoutState.LAYOUT_END) { top = PaddingTop + height * i; left = layoutState.Offset; } else { top = PaddingTop + height * (count - 1 - i); left = layoutState.Offset - width; } LayoutChild(holder, left, top, width, height); } } }
internal virtual void EnsureAnchorReady(FlexibleViewRecycler recycler, AnchorInfo anchorInfo, int itemDirection) { }