Search in sources :

Example 66 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project android-parallax-recyclerview by kanytu.

the class HeaderLayoutManagerFixed method recycleViewsFromEnd.

/**
     * Recycles views that went out of bounds after scrolling towards the start of the layout.
     *
     * @param recycler Recycler instance of {@link android.support.v7.widget.RecyclerView}
     * @param dt       This can be used to add additional padding to the visible area. This is used
     *                 to detect children that will go out of bounds after scrolling, without
     *                 actually moving them.
     */
private void recycleViewsFromEnd(RecyclerView.Recycler recycler, int dt) {
    final int childCount = getChildCount();
    if (dt < 0) {
        if (DEBUG) {
            Log.d(TAG, "Called recycle from end with a negative value. This might happen" + " during layout changes but may be sign of a bug");
        }
        return;
    }
    final int limit = mOrientationHelper.getEndAfterPadding() - dt + mHeaderIncrementFixer;
    if (mShouldReverseLayout) {
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (mOrientationHelper.getDecoratedStart(child) < limit) {
                // stop here
                recycleChildren(recycler, 0, i);
                return;
            }
        }
    } else {
        for (int i = childCount - 1; i >= 0; i--) {
            View child = getChildAt(i);
            if (mOrientationHelper.getDecoratedStart(child) < limit) {
                // stop here
                recycleChildren(recycler, childCount - 1, i);
                return;
            }
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 67 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project android-parallax-recyclerview by kanytu.

the class HeaderLayoutManagerFixed method recycleViewsFromStart.

/**
     * Recycles views that went out of bounds after scrolling towards the end of the layout.
     *
     * @param recycler Recycler instance of {@link android.support.v7.widget.RecyclerView}
     * @param dt       This can be used to add additional padding to the visible area. This is used
     *                 to
     *                 detect children that will go out of bounds after scrolling, without actually
     *                 moving them.
     */
private void recycleViewsFromStart(RecyclerView.Recycler recycler, int dt) {
    if (dt < 0) {
        if (DEBUG) {
            Log.d(TAG, "Called recycle from start with a negative value. This might happen" + " during layout changes but may be sign of a bug");
        }
        return;
    }
    final int limit = mOrientationHelper.getStartAfterPadding() + dt - mHeaderIncrementFixer;
    final int childCount = getChildCount();
    if (mShouldReverseLayout) {
        for (int i = childCount - 1; i >= 0; i--) {
            View child = getChildAt(i);
            if (mOrientationHelper.getDecoratedEnd(child) > limit) {
                // stop here if
                recycleChildren(recycler, childCount - 1, i);
                return;
            }
        }
    } else {
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (mOrientationHelper.getDecoratedEnd(child) > limit) {
                // stop here
                recycleChildren(recycler, 0, i);
                return;
            }
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 68 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project UltimateAndroid by cymcsg.

the class TwoWayLayoutManager method makeAndAddView.

private View makeAndAddView(int position, Direction direction, Recycler recycler) {
    final View child = recycler.getViewForPosition(position);
    final boolean isItemRemoved = ((LayoutParams) child.getLayoutParams()).isItemRemoved();
    if (!isItemRemoved) {
        addView(child, (direction == Direction.END ? -1 : 0));
    }
    setupChild(child, direction);
    if (!isItemRemoved) {
        updateLayoutEdgesFromNewChild(child);
    }
    return child;
}
Also used : LayoutParams(android.support.v7.widget.RecyclerView.LayoutParams) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 69 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project UltimateAndroid by cymcsg.

the class TwoWayLayoutManager method recycleChildrenFromStart.

private void recycleChildrenFromStart(Direction direction, Recycler recycler) {
    final int childCount = getChildCount();
    final int childrenStart = getStartWithPadding();
    int detachedCount = 0;
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        final int childEnd = getChildEnd(child);
        if (childEnd >= childrenStart) {
            break;
        }
        detachedCount++;
        detachChild(child, direction);
    }
    while (--detachedCount >= 0) {
        final View child = getChildAt(0);
        removeAndRecycleView(child, recycler);
        updateLayoutEdgesFromRemovedChild(child, direction);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 70 with Recycler

use of android.support.v7.widget.RecyclerView.Recycler in project UltimateAndroid by cymcsg.

the class SpannableGridLayoutManager method moveLayoutToPosition.

@Override
protected void moveLayoutToPosition(int position, int offset, Recycler recycler, State state) {
    final boolean isVertical = isVertical();
    final Lanes lanes = getLanes();
    lanes.reset(0);
    for (int i = 0; i <= position; i++) {
        SpannableItemEntry entry = (SpannableItemEntry) getItemEntryForPosition(i);
        if (entry == null) {
            final View child = recycler.getViewForPosition(i);
            entry = (SpannableItemEntry) cacheChildLaneAndSpan(child, Direction.END);
        }
        mTempLaneInfo.set(entry.startLane, entry.anchorLane);
        // removed item. See BaseLayoutManager.invalidateItemLanes().
        if (mTempLaneInfo.isUndefined()) {
            lanes.findLane(mTempLaneInfo, getLaneSpanForPosition(i), Direction.END);
            entry.setLane(mTempLaneInfo);
        }
        lanes.getChildFrame(mTempRect, getChildWidth(entry.colSpan), getChildHeight(entry.rowSpan), mTempLaneInfo, Direction.END);
        if (i != position) {
            pushChildFrame(entry, mTempRect, entry.startLane, getLaneSpan(entry, isVertical), Direction.END);
        }
    }
    lanes.getLane(mTempLaneInfo.startLane, mTempRect);
    lanes.reset(Direction.END);
    lanes.offset(offset - (isVertical ? mTempRect.bottom : mTempRect.right));
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)108 View (android.view.View)102 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)20 TextView (android.widget.TextView)19 ImageView (android.widget.ImageView)13 OrientationHelper (android.support.v7.widget.OrientationHelper)12 GridLayoutManager (android.support.v7.widget.GridLayoutManager)10 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)10 Point (android.graphics.Point)7 Bundle (android.os.Bundle)7 VirtualLayoutManager (com.alibaba.android.vlayout.VirtualLayoutManager)7 SuppressLint (android.annotation.SuppressLint)6 Context (android.content.Context)6 ViewGroup (android.view.ViewGroup)6 ActivityManager (android.app.ActivityManager)5 AccessibilityNodeInfoCompat (android.support.v4.view.accessibility.AccessibilityNodeInfoCompat)5 SpanSizeLookup (android.support.v7.widget.GridLayoutManager.SpanSizeLookup)5 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)5 Recycler (android.support.v7.widget.RecyclerView.Recycler)5 RecyclerListener (android.support.v7.widget.RecyclerView.RecyclerListener)5