Search in sources :

Example 31 with LayoutManager

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;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 32 with LayoutManager

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;
}
Also used : BitSet(java.util.BitSet) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 33 with LayoutManager

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);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 34 with LayoutManager

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());
}
Also used : SavedStateScrolling(com.marshalchen.ultimaterecyclerview.uiUtils.SavedStateScrolling) RecyclerView(android.support.v7.widget.RecyclerView)

Example 35 with LayoutManager

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();
}
Also used : Category(me.drakeet.multitype.sample.common.Category) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)205 RecyclerView (android.support.v7.widget.RecyclerView)202 View (android.view.View)151 GridLayoutManager (android.support.v7.widget.GridLayoutManager)73 TextView (android.widget.TextView)66 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)47 ImageView (android.widget.ImageView)44 Bundle (android.os.Bundle)24 Nullable (android.support.annotation.Nullable)24 BindView (butterknife.BindView)22 ArrayList (java.util.ArrayList)21 ViewGroup (android.view.ViewGroup)20 Context (android.content.Context)17 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)16 Intent (android.content.Intent)15 Handler (android.os.Handler)15 Toolbar (android.support.v7.widget.Toolbar)15 List (java.util.List)12 Point (android.graphics.Point)10 Drawable (android.graphics.drawable.Drawable)10