本文整理汇总了Java中android.support.v7.widget.RecyclerView.Recycler类的典型用法代码示例。如果您正苦于以下问题:Java Recycler类的具体用法?Java Recycler怎么用?Java Recycler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Recycler类属于android.support.v7.widget.RecyclerView包,在下文中一共展示了Recycler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixLayoutEndGap
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
private int fixLayoutEndGap(int endOffset, Recycler recycler, State state, boolean canOffsetChildren) {
int gap = this.mOrientationHelper.getEndAfterPadding() - endOffset;
if (gap <= 0) {
return 0;
}
int fixOffset = -scrollBy(-gap, recycler, state);
endOffset += fixOffset;
if (canOffsetChildren) {
gap = this.mOrientationHelper.getEndAfterPadding() - endOffset;
if (gap > 0) {
this.mOrientationHelper.offsetChildren(gap);
return gap + fixOffset;
}
}
return fixOffset;
}
示例2: onInitializeAccessibilityNodeInfoForItem
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
public void onInitializeAccessibilityNodeInfoForItem(Recycler recycler, State state, View host, AccessibilityNodeInfoCompat info) {
android.view.ViewGroup.LayoutParams lp = host.getLayoutParams();
if (lp instanceof LayoutParams) {
LayoutParams glp = (LayoutParams) lp;
int spanGroupIndex = getSpanGroupIndex(recycler, state, glp.getViewLayoutPosition());
if (this.mOrientation == 0) {
int spanIndex = glp.getSpanIndex();
int spanSize = glp.getSpanSize();
boolean z = this.mSpanCount > 1 && glp.getSpanSize() == this.mSpanCount;
info.setCollectionItemInfo(CollectionItemInfoCompat.obtain(spanIndex, spanSize, spanGroupIndex, 1, z, false));
return;
}
int spanIndex2 = glp.getSpanIndex();
int spanSize2 = glp.getSpanSize();
boolean z2 = this.mSpanCount > 1 && glp.getSpanSize() == this.mSpanCount;
info.setCollectionItemInfo(CollectionItemInfoCompat.obtain(spanGroupIndex, 1, spanIndex2, spanSize2, z2, false));
return;
}
super.onInitializeAccessibilityNodeInfoForItem(host, info);
}
示例3: ensureAnchorIsInCorrectSpan
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
private void ensureAnchorIsInCorrectSpan(Recycler recycler, State state, AnchorInfo anchorInfo, int itemDirection) {
boolean layingOutInPrimaryDirection = true;
if (itemDirection != 1) {
layingOutInPrimaryDirection = false;
}
int span = getSpanIndex(recycler, state, anchorInfo.mPosition);
if (layingOutInPrimaryDirection) {
while (span > 0 && anchorInfo.mPosition > 0) {
anchorInfo.mPosition--;
span = getSpanIndex(recycler, state, anchorInfo.mPosition);
}
return;
}
int indexLimit = state.getItemCount() - 1;
int pos = anchorInfo.mPosition;
int bestSpan = span;
while (pos < indexLimit) {
int next = getSpanIndex(recycler, state, pos + 1);
if (next <= bestSpan) {
break;
}
pos++;
bestSpan = next;
}
anchorInfo.mPosition = pos;
}
示例4: recycleViewsFromStart
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
private void recycleViewsFromStart(Recycler recycler, int dt) {
if (dt >= 0) {
int limit = dt;
int childCount = getChildCount();
int i;
if (this.mShouldReverseLayout) {
for (i = childCount - 1; i >= 0; i--) {
if (this.mOrientationHelper.getDecoratedEnd(getChildAt(i)) > limit) {
recycleChildren(recycler, childCount - 1, i);
return;
}
}
return;
}
for (i = 0; i < childCount; i++) {
if (this.mOrientationHelper.getDecoratedEnd(getChildAt(i)) > limit) {
recycleChildren(recycler, 0, i);
return;
}
}
}
}
示例5: fixLayoutStartGap
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
private int fixLayoutStartGap(int startOffset, Recycler recycler, State state, boolean canOffsetChildren) {
int gap = startOffset - this.mOrientationHelper.getStartAfterPadding();
if (gap <= 0) {
return 0;
}
int fixOffset = -scrollBy(gap, recycler, state);
startOffset += fixOffset;
if (canOffsetChildren) {
gap = startOffset - this.mOrientationHelper.getStartAfterPadding();
if (gap > 0) {
this.mOrientationHelper.offsetChildren(-gap);
return fixOffset - gap;
}
}
return fixOffset;
}
示例6: scrollBy
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
int scrollBy(int dy, Recycler recycler, State state) {
int i = 0;
if (!(getChildCount() == 0 || dy == 0)) {
this.mLayoutState.mRecycle = true;
ensureLayoutState();
int layoutDirection = dy > 0 ? 1 : -1;
int absDy = Math.abs(dy);
updateLayoutState(layoutDirection, absDy, true, state);
int consumed = this.mLayoutState.mScrollingOffset + fill(recycler, this.mLayoutState, state, false);
if (consumed >= 0) {
if (absDy > consumed) {
i = layoutDirection * consumed;
} else {
i = dy;
}
this.mOrientationHelper.offsetChildren(-i);
this.mLayoutState.mLastScrollDelta = i;
}
}
return i;
}
示例7: recycleViewsFromEnd
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
private void recycleViewsFromEnd(Recycler recycler, int dt) {
int childCount = getChildCount();
if (dt >= 0) {
int limit = this.mOrientationHelper.getEnd() - dt;
int i;
if (this.mShouldReverseLayout) {
for (i = 0; i < childCount; i++) {
if (this.mOrientationHelper.getDecoratedStart(getChildAt(i)) < limit) {
recycleChildren(recycler, 0, i);
return;
}
}
return;
}
for (i = childCount - 1; i >= 0; i--) {
if (this.mOrientationHelper.getDecoratedStart(getChildAt(i)) < limit) {
recycleChildren(recycler, childCount - 1, i);
return;
}
}
}
}
示例8: getSpanIndex
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
private int getSpanIndex(SpanSizeLookup spanSizeLookup, int spanCount, RecyclerView.Recycler recycler, RecyclerView.State state, int pos) {
if (!state.isPreLayout()) {
return spanSizeLookup.getCachedSpanIndex(pos, spanCount);
}
final int adapterPosition = recycler.convertPreLayoutPositionToPostLayout(pos);
if (adapterPosition == -1) {
return 0;
}
return spanSizeLookup.getCachedSpanIndex(adapterPosition, spanCount);
}
示例9: getSpanSize
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
private int getSpanSize(SpanSizeLookup spanSizeLookup, RecyclerView.Recycler recycler, RecyclerView.State state, int pos) {
if (!state.isPreLayout()) {
return spanSizeLookup.getSpanSize(pos);
}
final int adapterPosition = recycler.convertPreLayoutPositionToPostLayout(pos);
if (adapterPosition == -1) {
return 0;
}
return spanSizeLookup.getSpanSize(adapterPosition);
}
示例10: assignSpans
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
private void assignSpans(GridRangeStyle rangeStyle, RecyclerView.Recycler recycler, RecyclerView.State state, int count,
int consumedSpanCount, boolean layingOutInPrimaryDirection, LayoutManagerHelper helper) {
int span, spanDiff, start, end, diff;
// make sure we traverse from min position to max position
if (layingOutInPrimaryDirection) {
start = 0;
end = count;
diff = 1;
} else {
start = count - 1;
end = -1;
diff = -1;
}
if (helper.getOrientation() == VERTICAL && helper.isDoLayoutRTL()) { // start from last span
span = consumedSpanCount - 1;
spanDiff = -1;
} else {
span = 0;
spanDiff = 1;
}
for (int i = start; i != end; i += diff) {
View view = rangeStyle.mSet[i];
int spanSize = getSpanSize(rangeStyle.mSpanSizeLookup, recycler, state, helper.getPosition(view));
if (spanDiff == -1 && spanSize > 1) {
rangeStyle.mSpanIndices[i] = span - (spanSize - 1);
} else {
rangeStyle.mSpanIndices[i] = span;
}
span += spanDiff * spanSize;
}
}
示例11: layoutViews
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
@Override
public void layoutViews(RecyclerView.Recycler recycler, RecyclerView.State state,
LayoutStateWrapper layoutState, LayoutChunkResult result, LayoutManagerHelper helper) {
mTempLayoutHelper = helper;
doLayoutView(recycler, state, layoutState, result, helper);
mTempLayoutHelper = null;
}
示例12: getColumnCountForAccessibility
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
public int getColumnCountForAccessibility(Recycler recycler, State state) {
if (this.mOrientation == 1) {
return this.mSpanCount;
}
if (state.getItemCount() < 1) {
return 0;
}
return getSpanGroupIndex(recycler, state, state.getItemCount() - 1) + 1;
}
示例13: onLayoutChildren
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
public void onLayoutChildren(Recycler recycler, State state) {
if (state.isPreLayout()) {
cachePreLayoutSpanMapping();
}
super.onLayoutChildren(recycler, state);
clearPreLayoutSpanMappingCache();
if (!state.isPreLayout()) {
this.mPendingSpanCountChange = false;
}
}
示例14: onAnchorReady
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
void onAnchorReady(Recycler recycler, State state, AnchorInfo anchorInfo, int itemDirection) {
super.onAnchorReady(recycler, state, anchorInfo, itemDirection);
updateMeasurements();
if (state.getItemCount() > 0 && !state.isPreLayout()) {
ensureAnchorIsInCorrectSpan(recycler, state, anchorInfo, itemDirection);
}
ensureViewSet();
}
示例15: next
import android.support.v7.widget.RecyclerView.Recycler; //导入依赖的package包/类
View next(Recycler recycler) {
if (this.mScrapList != null) {
return nextViewFromScrapList();
}
View view = recycler.getViewForPosition(this.mCurrentPosition);
this.mCurrentPosition += this.mItemDirection;
return view;
}