Search in sources :

Example 11 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project FlexibleAdapter by davideas.

the class FragmentExpandableSections method createNewGridLayoutManager.

@Override
protected GridLayoutManager createNewGridLayoutManager() {
    GridLayoutManager gridLayoutManager = new SmoothScrollGridLayoutManager(getActivity(), mColumnCount);
    gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            // here, you should use them and not Layout integers
            switch(mAdapter.getItemViewType(position)) {
                case R.layout.recycler_scrollable_layout_item:
                case R.layout.recycler_scrollable_uls_item:
                case R.layout.recycler_header_item:
                case R.layout.recycler_expandable_header_item:
                case R.layout.recycler_expandable_item:
                    return mColumnCount;
                default:
                    return 1;
            }
        }
    });
    return gridLayoutManager;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)

Example 12 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project FlexibleAdapter by davideas.

the class FragmentHeadersSections method createNewGridLayoutManager.

@Override
protected GridLayoutManager createNewGridLayoutManager() {
    GridLayoutManager gridLayoutManager = new SmoothScrollGridLayoutManager(getActivity(), mColumnCount);
    gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            //noinspection ConstantConditions
            return mAdapter.getItem(position).getSpanSize(mColumnCount, position);
        }
    });
    return gridLayoutManager;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)

Example 13 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project FlexibleAdapter by davideas.

the class ExampleAdapter method showLayoutInfo.

/*
	 * HEADER VIEW
	 * This method shows how to add Header View as it was for ListView.
	 * Same Header item is enqueued for removal with a delay.
	 * The view is represented by a custom Item type to better represent any dynamic content.
	 */
public void showLayoutInfo(boolean scrollToPosition) {
    if (!hasSearchText()) {
        final ScrollableLayoutItem item = new ScrollableLayoutItem("LAY-L");
        if (mRecyclerView.getLayoutManager() instanceof StaggeredGridLayoutManager) {
            item.setId("LAY-S");
            item.setTitle(mRecyclerView.getContext().getString(R.string.staggered_layout));
        } else if (mRecyclerView.getLayoutManager() instanceof GridLayoutManager) {
            item.setId("LAY-G");
            item.setTitle(mRecyclerView.getContext().getString(R.string.grid_layout));
        } else {
            item.setTitle(mRecyclerView.getContext().getString(R.string.linear_layout));
        }
        item.setSubtitle(mRecyclerView.getContext().getString(R.string.columns, String.valueOf(Utils.getSpanCount(mRecyclerView.getLayoutManager()))));
        // NOTE: If you have to change at runtime the LayoutManager AND add
        // Scrollable Headers, consider to add them in post, using a delay >= 0
        // otherwise scroll animations on all items will not start correctly.
        addScrollableHeaderWithDelay(item, 1200L, scrollToPosition);
        removeScrollableHeaderWithDelay(item, 4000L);
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ScrollableLayoutItem(eu.davidea.samples.flexibleadapter.items.ScrollableLayoutItem) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager)

Example 14 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project SeriesGuide by UweTrottmann.

the class ShowsNowFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_now, container, false);
    unbinder = ButterKnife.bind(this, v);
    swipeRefreshLayout.setSwipeableChildren(R.id.scrollViewNow, R.id.recyclerViewNow);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            refreshStream();
        }
    });
    swipeRefreshLayout.setProgressViewOffset(false, getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_start_margin), getResources().getDimensionPixelSize(R.dimen.swipe_refresh_progress_bar_end_margin));
    emptyView.setText(R.string.now_empty);
    showError(null);
    snackbarButton.setText(R.string.refresh);
    snackbarButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            refreshStream();
        }
    });
    // recycler view layout manager
    final int spanCount = getResources().getInteger(R.integer.grid_column_count);
    final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), spanCount);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            if (adapter == null) {
                return 1;
            }
            if (position >= adapter.getItemCount()) {
                return 1;
            }
            // make headers and more links span all columns
            int type = adapter.getItem(position).type;
            return (type == NowAdapter.ItemType.HEADER || type == NowAdapter.ItemType.MORE_LINK) ? spanCount : 1;
        }
    });
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(new GridInsetDecoration(getResources()));
    recyclerView.setHasFixedSize(true);
    return v;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridInsetDecoration(com.battlelancer.seriesguide.util.GridInsetDecoration) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) EmptyViewSwipeRefreshLayout(com.battlelancer.seriesguide.widgets.EmptyViewSwipeRefreshLayout) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Example 15 with GridLayoutManager

use of android.support.v7.widget.GridLayoutManager in project Carbon by ZieIony.

the class WidgetsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    Samples.initToolbar(this, getString(R.string.widgetsActivity_title));
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    ViewModel[] items = new ViewModel[] { new ViewModel(CheckBoxRadioActivity.class, getString(R.string.checkBoxRadioActivity_title)), new ViewModel(ButtonsActivity.class, getString(R.string.buttonsActivity_title)), new ViewModel(CircularProgressActivity.class, getString(R.string.circularProgressActivity_title)), new ViewModel(ProgressBarsActivity.class, getString(R.string.progressBarsActivity_title)), new ViewModel(SnackbarActivity.class, getString(R.string.snackbarActivity_title)), new ViewModel(SVGActivity.class, getString(R.string.svgActivity_title)), new ViewModel(TextFieldsActivity.class, getString(R.string.textFieldsActivity_title)), new ViewModel(TabsActivity.class, getString(R.string.tabsActivity_title)), new ViewModel(ScrollViewActivity.class, getString(R.string.scrollViewActivity_title)), new ViewModel(RecyclerActivity.class, getString(R.string.recyclerViewActivity_title)), new ViewModel(ExpandableRecyclerActivity.class, getString(R.string.expandableRecyclerActivity_title)), new ViewModel(DropDownActivity.class, getString(R.string.dropDownActivityActivity_title)), new ViewModel(NavigationViewActivity.class, getString(R.string.navigationViewActivity_title)), new ViewModel(SeekBarActivity.class, getString(R.string.seekBarActivity_title)), new ViewModel(ToolbarActivity.class, getString(R.string.toolbarActivity_title)), new ViewModel(FlowLayoutActivity.class, getString(R.string.flowLayoutActivity_title)), new ViewModel(TableLayoutActivity.class, getString(R.string.tableLayoutActivity_title)), new ViewModel(FloatingActionMenuActivity.class, getString(R.string.floatingActionMenuActivity_title)), new ViewModel(BottomBarActivity.class, getString(R.string.bottomBarActivity_title), true), new ViewModel(BottomSheetActivity.class, getString(R.string.bottomSheetActivity_title), true) };
    recyclerView.setLayoutManager(getResources().getBoolean(R.bool.tablet) ? new GridLayoutManager(this, 2, LinearLayoutManager.VERTICAL, false) : new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(new MainListAdapter(items));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

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