Search in sources :

Example 11 with StaggeredGridLayoutManager

use of androidx.recyclerview.widget.StaggeredGridLayoutManager 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 12 with StaggeredGridLayoutManager

use of androidx.recyclerview.widget.StaggeredGridLayoutManager in project UltimateRecyclerView by cymcsg.

the class BasicFunctions method configStaggerLayoutManager.

protected final void configStaggerLayoutManager(UltimateRecyclerView rv, easyRegularAdapter ad) {
    StaggeredGridLayoutManager gaggeredGridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
    rv.setLayoutManager(gaggeredGridLayoutManager);
}
Also used : StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager)

Example 13 with StaggeredGridLayoutManager

use of androidx.recyclerview.widget.StaggeredGridLayoutManager in project BGARefreshLayout-Android by bingoogolapple.

the class RefreshStaggeredRecyclerViewFragment method processLogic.

@Override
protected void processLogic(Bundle savedInstanceState) {
    mRefreshLayout.setCustomHeaderView(DataEngine.getCustomHeaderView(mApp), true);
    mRefreshLayout.setRefreshViewHolder(new BGANormalRefreshViewHolder(mApp, true));
    StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
    mDataRv.setLayoutManager(layoutManager);
    mDataRv.setAdapter(mAdapter);
}
Also used : BGANormalRefreshViewHolder(cn.bingoogolapple.refreshlayout.BGANormalRefreshViewHolder) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager)

Example 14 with StaggeredGridLayoutManager

use of androidx.recyclerview.widget.StaggeredGridLayoutManager in project SherlockAdapter by EvilBT.

the class MultiItemActivity method initView.

private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mGridLayoutManager = new GridLayoutManager(this, 3);
    mStaggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    final SwipeRefreshLayout refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
    mRecyclerView = (RecyclerView) findViewById(R.id.list);
    mRecyclerView.setLayoutManager(mGridLayoutManager);
    mIsGrid = true;
    mAdapter = new MyMultiAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mAdapter.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(@NonNull View view, final int adapterPosition) {
            new AlertDialog.Builder(MultiItemActivity.this).setTitle("是否删除第" + adapterPosition + "项").setPositiveButton("确定", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mAdapter.removeData(adapterPosition);
                }
            }).setNegativeButton("取消", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).create().show();
            return true;
        }
    });
    mData = new ArrayList<>();
    initGridData();
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            refreshLayout.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mAdapter.setData(mData);
                    refreshLayout.setRefreshing(false);
                }
            }, 500);
        }
    });
}
Also used : DialogInterface(android.content.DialogInterface) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) OnItemLongClickListener(xyz.zpayh.adapter.OnItemLongClickListener) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) MyMultiAdapter(xyz.zpayh.myadapter.adapter.MyMultiAdapter) Toolbar(androidx.appcompat.widget.Toolbar)

Example 15 with StaggeredGridLayoutManager

use of androidx.recyclerview.widget.StaggeredGridLayoutManager in project LiYuJapanese by 54wall.

the class FavLessonFragment method setData.

@Override
public void setData(List<LessonFav> data) {
    Log.e(TAG, "setData!!!!!!");
    lessonFavList = data;
    staggeredGridAdapter = new StaggeredGridAdapter(getActivity(), data);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.setAdapter(staggeredGridAdapter);
    staggeredGridAdapter.setOnItemClickLitener(new OnItemClickLitener() {

        @Override
        public void onItemClick(View view, int position) {
            staggeredGridAdapter.notifyItemRemoved(position);
            ((MainActivity) getActivity()).switchFavWord(staggeredGridAdapter.getItemLessonId(position), false);
        }

        @Override
        public void onItemLongClick(View view, final int position) {
        }
    });
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(mRecyclerView);
}
Also used : OnItemClickLitener(pri.weiqiang.liyujapanese.ui.adapter.stagger.OnItemClickLitener) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) StaggeredGridAdapter(pri.weiqiang.liyujapanese.ui.adapter.StaggeredGridAdapter) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) FavLessonFragmentView(pri.weiqiang.liyujapanese.mvp.view.dic.FavLessonFragmentView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)36 RecyclerView (androidx.recyclerview.widget.RecyclerView)25 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)16 View (android.view.View)14 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)9 Toolbar (androidx.appcompat.widget.Toolbar)6 AbsListView (android.widget.AbsListView)5 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)4 WebView (android.webkit.WebView)3 ScrollView (android.widget.ScrollView)3 BindView (butterknife.BindView)3 OnItemLongClickListener (xyz.zpayh.adapter.OnItemLongClickListener)3 DialogInterface (android.content.DialogInterface)2 Adapter (android.widget.Adapter)2 FrameLayout (android.widget.FrameLayout)2 TextView (android.widget.TextView)2 Nullable (androidx.annotation.Nullable)2 ContentLoadingProgressBar (androidx.core.widget.ContentLoadingProgressBar)2 SimpleItemAnimator (androidx.recyclerview.widget.SimpleItemAnimator)2 FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)2