use of android.support.v7.widget.RecyclerView.LayoutManager in project vlayout by alibaba.
the class BaseLayoutHelper method nextView.
/**
* Retrieve next view and add it into layout, this is to make sure that view are added by order
*
* @param recycler recycler generate views
* @param layoutState current layout state
* @param helper helper to add views
* @param result chunk result to tell layoutManager whether layout process goes end
* @return next view to render, null if no more view available
*/
@Nullable
public final View nextView(RecyclerView.Recycler recycler, LayoutStateWrapper layoutState, LayoutManagerHelper helper, LayoutChunkResult result) {
View view = layoutState.next(recycler);
if (view == null) {
// no more items to layout.
if (DEBUG && !layoutState.hasScrapList()) {
throw new RuntimeException("received null view when unexpected");
}
// if there is no more views can be retrieved, this layout process is finished
result.mFinished = true;
return null;
}
helper.addChildView(layoutState, view);
return view;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project vlayout by alibaba.
the class StaggeredGridLayoutHelper method hasGapsToFix.
/**
* Checks for gaps if we've reached to the top of the list.
* <p/>
* Intermediate gaps created by full span items are tracked via mLaidOutInvalidFullSpan field.
*/
private View hasGapsToFix(VirtualLayoutManager layoutManager, final int position, final int alignLine) {
View view = layoutManager.findViewByPosition(position);
if (view == null)
return null;
BitSet mSpansToCheck = new BitSet(mNumLanes);
mSpansToCheck.set(0, mNumLanes, true);
for (Span span : mSpans) {
if (span.mViews.size() != 0 && checkSpanForGap(span, layoutManager, alignLine)) {
return layoutManager.getReverseLayout() ? span.mViews.get(span.mViews.size() - 1) : span.mViews.get(0);
}
}
// everything looks good
return null;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project Onboarding by eoinfogarty.
the class SceneThreeFragment method scrollRecycleViewTo.
private void scrollRecycleViewTo(RecyclerView recyclerView, int offset) {
LinearLayoutManager layoutManager = ((LinearLayoutManager) recyclerView.getLayoutManager());
layoutManager.scrollToPositionWithOffset(2, offset);
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project UltimateRecyclerView by cymcsg.
the class UltimateRecyclerView method onRestoreInstanceState.
@Override
public void onRestoreInstanceState(Parcelable state) {
SavedStateScrolling ss = (SavedStateScrolling) state;
mPrevFirstVisiblePosition = ss.prevFirstVisiblePosition;
mPrevFirstVisibleChildHeight = ss.prevFirstVisibleChildHeight;
mPrevScrolledChildrenHeight = ss.prevScrolledChildrenHeight;
mPrevScrollY = ss.prevScrollY;
mScrollY = ss.scrollY;
mChildrenHeights = ss.childrenHeights;
RecyclerView.LayoutManager layoutManager = getLayoutManager();
/**
* enhanced and store the previous scroll position
*/
if (layoutManager != null) {
int count = layoutManager.getChildCount();
if (mPrevScrollY != RecyclerView.NO_POSITION && mPrevScrollY < count) {
layoutManager.scrollToPosition(mPrevScrollY);
}
}
super.onRestoreInstanceState(ss.getSuperState());
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project MultiType by drakeet.
the class MultiSelectActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multi_select);
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
final GridLayoutManager layoutManager = new GridLayoutManager(this, SPAN_COUNT);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return (items.get(position) instanceof Category) ? SPAN_COUNT : 1;
}
});
selectedSet = new TreeSet<>();
recyclerView.setLayoutManager(layoutManager);
adapter = new MultiTypeAdapter();
adapter.applyGlobalMultiTypePool();
adapter.register(Square.class, new SquareViewBinder(selectedSet));
loadData();
assertAllRegistered(adapter, items);
recyclerView.setAdapter(adapter);
setupFAB();
}
Aggregations