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 RxImagePicker by qingmei2.
the class AlbumMediaAdapter method refreshSelection.
public void refreshSelection() {
GridLayoutManager layoutManager = (GridLayoutManager) mRecyclerView.getLayoutManager();
int first = layoutManager.findFirstVisibleItemPosition();
int last = layoutManager.findLastVisibleItemPosition();
if (first == -1 || last == -1) {
return;
}
Cursor cursor = getCursor();
for (int i = first; i <= last; i++) {
RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(first);
if (holder instanceof MediaViewHolder) {
if (cursor.moveToPosition(i)) {
setCheckStatus(Item.valueOf(cursor), ((MediaViewHolder) holder).mMediaGrid);
}
}
}
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project easy by MehdiBenmesa.
the class Utils method scrollTo.
public static void scrollTo(Object scroll, float yOffset) {
if (scroll instanceof RecyclerView) {
// RecyclerView.scrollTo : UnsupportedOperationException
// Moved to the RecyclerView.LayoutManager.scrollToPositionWithOffset
// Have to be instanceOf RecyclerView.LayoutManager to work (so work with RecyclerView.GridLayoutManager)
final RecyclerView.LayoutManager layoutManager = ((RecyclerView) scroll).getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
linearLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
staggeredGridLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
}
} else if (scroll instanceof NestedScrollView) {
((NestedScrollView) scroll).scrollTo(0, (int) yOffset);
}
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project easy by MehdiBenmesa.
the class MaterialViewPagerHeaderDecorator method getItemOffsets.
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView recyclerView, RecyclerView.State state) {
final RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
final Context context = recyclerView.getContext();
if (!registered) {
MaterialViewPagerHelper.registerRecyclerView(context, recyclerView);
registered = true;
}
int headerCells = 1;
// don't work with stagged
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
headerCells = gridLayoutManager.getSpanCount();
}
MaterialViewPagerAnimator animator = MaterialViewPagerHelper.getAnimator(context);
if (animator != null) {
if (holder.getAdapterPosition() < headerCells) {
outRect.top = Math.round(Utils.dpToPx(animator.getHeaderHeight() + 10, context));
}
}
}
Aggregations