Search in sources :

Example 36 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project mosby by sockeqwe.

the class SearchFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_search, container, false);
    unbinder = ButterKnife.bind(this, view);
    adapter = new SearchAdapter(inflater, this);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), spanCount));
    recyclerView.addItemDecoration(new GridSpacingItemDecoration(spanCount, getResources().getDimensionPixelSize(R.dimen.grid_spacing), true));
    return view;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) BindView(butterknife.BindView) View(android.view.View) RxSearchView(com.jakewharton.rxbinding2.widget.RxSearchView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) GridSpacingItemDecoration(com.hannesdorfmann.mosby3.sample.mvi.view.ui.GridSpacingItemDecoration) Nullable(android.support.annotation.Nullable)

Example 37 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project mosby by sockeqwe.

the class HomeFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_home, container, false);
    unbinder = ButterKnife.bind(this, view);
    adapter = new HomeAdapter(inflater, this);
    layoutManager = new GridLayoutManager(getActivity(), spanCount);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            int viewType = adapter.getItemViewType(position);
            if (viewType == HomeAdapter.VIEW_TYPE_LOADING_MORE_NEXT_PAGE || viewType == HomeAdapter.VIEW_TYPE_SECTION_HEADER) {
                return spanCount;
            }
            return 1;
        }
    });
    recyclerView.addItemDecoration(new GridSpacingItemDecoration(spanCount, getResources().getDimensionPixelSize(R.dimen.grid_spacing), true));
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(layoutManager);
    return view;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) BindView(butterknife.BindView) View(android.view.View) RxRecyclerView(com.jakewharton.rxbinding2.support.v7.widget.RxRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) GridSpacingItemDecoration(com.hannesdorfmann.mosby3.sample.mvi.view.ui.GridSpacingItemDecoration) Nullable(android.support.annotation.Nullable)

Example 38 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project platform_frameworks_base by android.

the class NekoLand method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.neko_activity);
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setLogo(Cat.create(this));
        actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setDisplayShowHomeEnabled(true);
    }
    mPrefs = new PrefState(this);
    mPrefs.setListener(this);
    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.holder);
    mAdapter = new CatAdapter();
    recyclerView.setAdapter(mAdapter);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    int numCats = updateCats();
    MetricsLogger.histogram(this, "egg_neko_visit_gallery", numCats);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) ActionBar(android.app.ActionBar)

Example 39 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project QuickReturn by lawloretienne.

the class QuickReturnHeaderRecyclerViewFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mValues = getResources().getStringArray(R.array.countries);
    if (mLayoutManagerType.equals("linear")) {
        CountriesLinearLayoutAdapter countriesLinearLayoutAdapter = new CountriesLinearLayoutAdapter(Arrays.asList(mValues));
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), null));
        mRecyclerView.setAdapter(countriesLinearLayoutAdapter);
    } else if (mLayoutManagerType.equals("grid")) {
        CountriesGridLayoutAdapter countriesGridLayoutAdapter = new CountriesGridLayoutAdapter(Arrays.asList(mValues));
        RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), 2);
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.addItemDecoration(new GridSpacesItemDecoration(QuickReturnUtils.dp2px(getActivity(), 8)));
        mRecyclerView.setAdapter(countriesGridLayoutAdapter);
    }
    int headerHeight = getActivity().getResources().getDimensionPixelSize(R.dimen.header_height2);
    switch(mQuickReturnAnimationType) {
        case TRANSLATION_SIMPLE:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).columnCount(2).build();
            } else {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener);
            break;
        case TRANSLATION_SNAP:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).columnCount(2).isSnappable(true).build();
            } else {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).isSnappable(true).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener);
            break;
        case TRANSLATION_ANTICIPATE_OVERSHOOT:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener2 = new SpeedyQuickReturnRecyclerViewOnScrollListener.Builder(getActivity(), QuickReturnViewType.HEADER).header(mQuickReturnTextView).columnCount(2).build();
            } else {
                mScrollListener2 = new SpeedyQuickReturnRecyclerViewOnScrollListener.Builder(getActivity(), QuickReturnViewType.HEADER).header(mQuickReturnTextView).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener2);
            break;
        default:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).columnCount(2).build();
            } else {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener);
            break;
    }
}
Also used : QuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.QuickReturnRecyclerViewOnScrollListener) SpeedyQuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.SpeedyQuickReturnRecyclerViewOnScrollListener) SpeedyQuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.SpeedyQuickReturnRecyclerViewOnScrollListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.etiennelawlor.quickreturn.itemdecorations.DividerItemDecoration) GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridLayoutManager(android.support.v7.widget.GridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CountriesGridLayoutAdapter(com.etiennelawlor.quickreturn.adapters.CountriesGridLayoutAdapter) CountriesLinearLayoutAdapter(com.etiennelawlor.quickreturn.adapters.CountriesLinearLayoutAdapter) RecyclerView(android.support.v7.widget.RecyclerView) GridSpacesItemDecoration(com.etiennelawlor.quickreturn.itemdecorations.GridSpacesItemDecoration)

Example 40 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project boilerplate by koush.

the class GridRecyclerView method setNumColumns.

private void setNumColumns(Context context, int numColumns) {
    if (gridLayoutManager == null) {
        gridLayoutManager = new GridLayoutManager(context, numColumns);
        typeToSpan = new Hashtable<Integer, Integer>();
        gridLayoutManager.setSpanSizeLookup(spanSizeLookup = new GridLayoutManager.SpanSizeLookup() {

            @Override
            public int getSpanSize(int position) {
                int viewType = getAdapter().getItemViewType(position);
                Integer span = typeToSpan.get(viewType);
                if (span != null)
                    return span;
                ViewHolder vh = getAdapter().createViewHolder(GridRecyclerView.this, viewType);
                int foundSpan;
                if (vh instanceof SpanningViewHolder)
                    foundSpan = ((SpanningViewHolder) vh).getSpanSize(gridLayoutManager.getSpanCount());
                else
                    foundSpan = 1;
                typeToSpan.put(viewType, foundSpan);
                return foundSpan;
            }
        });
        setLayoutManager(gridLayoutManager);
    } else {
        gridLayoutManager.setSpanCount(numColumns);
    }
    typeToSpan.clear();
    spanSizeLookup.invalidateSpanIndexCache();
    requestLayout();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)264 RecyclerView (android.support.v7.widget.RecyclerView)118 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)68 View (android.view.View)60 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)38 TextView (android.widget.TextView)32 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)15 MaterialViewPagerHeaderDecorator (com.github.florent37.materialviewpager.header.MaterialViewPagerHeaderDecorator)14 BindView (butterknife.BindView)13 ArrayList (java.util.ArrayList)13 Handler (android.os.Handler)12 Toolbar (android.support.v7.widget.Toolbar)12 ImageView (android.widget.ImageView)12 Context (android.content.Context)11 Intent (android.content.Intent)11 Point (android.graphics.Point)9 Nullable (android.support.annotation.Nullable)9 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)9 SuppressLint (android.annotation.SuppressLint)8 AdapterView (android.widget.AdapterView)8