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;
}
}
}
}
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;
}
}
}
}
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;
}
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);
}
}
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));
}
Aggregations