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);
}
}
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);
}
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);
}
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);
}
});
}
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);
}
Aggregations