Search in sources :

Example 1 with GridSpacingItemDecoration

use of com.hannesdorfmann.mosby3.sample.mvi.view.ui.GridSpacingItemDecoration 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 2 with GridSpacingItemDecoration

use of com.hannesdorfmann.mosby3.sample.mvi.view.ui.GridSpacingItemDecoration 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 3 with GridSpacingItemDecoration

use of com.hannesdorfmann.mosby3.sample.mvi.view.ui.GridSpacingItemDecoration in project mosby by sockeqwe.

the class CategoryFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_category, container, false);
    unbinder = ButterKnife.bind(this, view);
    GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), spanCount);
    adapter = new CategoryAdapter(inflater, this);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(layoutManager);
    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) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) GridSpacingItemDecoration(com.hannesdorfmann.mosby3.sample.mvi.view.ui.GridSpacingItemDecoration) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)3 GridLayoutManager (android.support.v7.widget.GridLayoutManager)3 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 BindView (butterknife.BindView)3 GridSpacingItemDecoration (com.hannesdorfmann.mosby3.sample.mvi.view.ui.GridSpacingItemDecoration)3 TextView (android.widget.TextView)2 RxRecyclerView (com.jakewharton.rxbinding2.support.v7.widget.RxRecyclerView)1 RxSearchView (com.jakewharton.rxbinding2.widget.RxSearchView)1