Search in sources :

Example 46 with GridLayoutManager

use of androidx.recyclerview.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) {
            return mAdapter.getItem(position).getSpanSize(mColumnCount, position);
        }
    });
    return gridLayoutManager;
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)

Example 47 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project FlexibleAdapter by davideas.

the class FragmentEndlessScrolling method onPrepareOptionsMenu.

@Override
public void onPrepareOptionsMenu(Menu menu) {
    Log.v(TAG, "onPrepareOptionsMenu called!");
    MenuItem gridMenuItem = menu.findItem(R.id.action_list_type);
    if (mRecyclerView.getLayoutManager() instanceof GridLayoutManager) {
        gridMenuItem.setIcon(R.drawable.ic_view_agenda_white_24dp);
        gridMenuItem.setTitle(R.string.linear_layout);
    } else {
        gridMenuItem.setIcon(R.drawable.ic_view_grid_white_24dp);
        gridMenuItem.setTitle(R.string.grid_layout);
    }
    MenuItem endlessMenuItem = menu.findItem(R.id.action_top_scrolling);
    endlessMenuItem.setChecked(mAdapter.isTopEndless());
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager) MenuItem(android.view.MenuItem)

Example 48 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project FlexibleAdapter by davideas.

the class OverallAdapter method showLayoutInfo.

/*
     * HEADER/FOOTER VIEW
     * This method show how to add Header/Footer View as it was for ListView.
     * The secret is the position! 0 for Header; itemCount for Footer ;-)
     * The view is represented by a custom Item type to better represent any dynamic content.
     */
public void showLayoutInfo(boolean scrollToPosition) {
    if (!hasFilter()) {
        // Define Example View
        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(getFlexibleLayoutManager().getSpanCount())));
        addScrollableHeaderWithDelay(item, 300L, scrollToPosition);
        removeScrollableHeaderWithDelay(item, 2000L);
    }
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) ScrollableLayoutItem(eu.davidea.samples.flexibleadapter.items.ScrollableLayoutItem) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager)

Example 49 with GridLayoutManager

use of androidx.recyclerview.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 (!hasFilter()) {
        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(getFlexibleLayoutManager().getSpanCount())));
        // 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(androidx.recyclerview.widget.GridLayoutManager) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) ScrollableLayoutItem(eu.davidea.samples.flexibleadapter.items.ScrollableLayoutItem) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager)

Example 50 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project BaseRecyclerViewAdapterHelper by CymChad.

the class SectionQuickUseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_section_uer);
    setBackBtn();
    setTitle("Quick Section Use");
    mRecyclerView = findViewById(R.id.rv_list);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    mRecyclerView.addItemDecoration(new GridSectionAverageGapItemDecoration(10, 10, 20, 15));
    mData = DataServer.getSectionData();
    SectionQuickAdapter adapter = new SectionQuickAdapter(R.layout.item_section_content, R.layout.def_section_head, mData);
    adapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
            MySection mySection = mData.get(position);
            if (mySection.isHeader()) {
                Tips.show((String) mySection.getObject());
            } else {
                Video video = (Video) mySection.getObject();
                Tips.show(video.getName());
            }
        }
    });
    adapter.setOnItemChildClickListener(new OnItemChildClickListener() {

        @Override
        public void onItemChildClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
            Tips.show("onItemChildClick: " + position);
        }
    });
    mRecyclerView.setAdapter(adapter);
}
Also used : MySection(com.chad.baserecyclerviewadapterhelper.entity.MySection) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) OnItemClickListener(com.chad.library.adapter.base.listener.OnItemClickListener) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) Video(com.chad.baserecyclerviewadapterhelper.entity.Video) GridSectionAverageGapItemDecoration(com.chad.baserecyclerviewadapterhelper.decoration.GridSectionAverageGapItemDecoration) SectionQuickAdapter(com.chad.baserecyclerviewadapterhelper.adapter.SectionQuickAdapter) OnItemChildClickListener(com.chad.library.adapter.base.listener.OnItemChildClickListener) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)122 RecyclerView (androidx.recyclerview.widget.RecyclerView)63 View (android.view.View)45 TextView (android.widget.TextView)19 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)16 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 ImageView (android.widget.ImageView)12 Nullable (androidx.annotation.Nullable)11 Toolbar (androidx.appcompat.widget.Toolbar)10 ViewGroup (android.view.ViewGroup)7 SmoothScrollGridLayoutManager (eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)7 SuppressLint (android.annotation.SuppressLint)6 Context (android.content.Context)6 ArrayList (java.util.ArrayList)6 NonNull (androidx.annotation.NonNull)5 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)5 List (java.util.List)5 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)5 Drawable (android.graphics.drawable.Drawable)4 Handler (android.os.Handler)3