use of android.support.v7.widget.GridLayoutManager in project xRecyclerViewF by Dsiner.
the class ItemTouchRvActivity method setLayoutManager.
private void setLayoutManager() {
if (isllayoutManager) {
//网格布局
if (itemDecoration == null) {
itemDecoration = new SpaceItemDecoration(10);
}
recyclerView.addItemDecoration(itemDecoration);
recyclerView.setLayoutManager(new GridLayoutManager(this, 4));
} else {
//线性布局
recyclerView.removeItemDecoration(itemDecoration);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
isllayoutManager = !isllayoutManager;
}
use of android.support.v7.widget.GridLayoutManager in project xRecyclerViewF by Dsiner.
the class XRecyclerView method setLayoutManager.
@Override
public void setLayoutManager(LayoutManager layout) {
super.setLayoutManager(layout);
if (wrapAdapter != null) {
if (layout instanceof GridLayoutManager) {
final GridLayoutManager gridManager = ((GridLayoutManager) layout);
gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
return (wrapAdapter.isHeader(position) || wrapAdapter.isFooter(position) || wrapAdapter.isRefreshHeader(position)) ? gridManager.getSpanCount() : 1;
}
});
}
}
}
use of android.support.v7.widget.GridLayoutManager in project AdMoney by ErnestoGonAr.
the class Gastos method setRecyclerViewLayoutManager.
public void setRecyclerViewLayoutManager(LayoutManagerType layoutManagerType) {
int scrollPosition = 0;
// If a layout manager has already been set, get current scroll position.
if (mRecyclerView.getLayoutManager() != null) {
scrollPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
}
switch(layoutManagerType) {
case GRID_LAYOUT_MANAGER:
mLayoutManager = new GridLayoutManager(getActivity(), SPAN_COUNT);
mCurrentLayoutManagerType = LayoutManagerType.GRID_LAYOUT_MANAGER;
break;
case LINEAR_LAYOUT_MANAGER:
mLayoutManager = new LinearLayoutManager(getActivity());
mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
break;
default:
mLayoutManager = new LinearLayoutManager(getActivity());
mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
}
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.scrollToPosition(scrollPosition);
}
use of android.support.v7.widget.GridLayoutManager in project AdMoney by ErnestoGonAr.
the class Deudas method setRecyclerViewLayoutManager.
public void setRecyclerViewLayoutManager(LayoutManagerType layoutManagerType) {
int scrollPosition = 0;
// If a layout manager has already been set, get current scroll position.
if (mRecyclerView.getLayoutManager() != null) {
scrollPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
}
switch(layoutManagerType) {
case GRID_LAYOUT_MANAGER:
mLayoutManager = new GridLayoutManager(getActivity(), SPAN_COUNT);
mCurrentLayoutManagerType = LayoutManagerType.GRID_LAYOUT_MANAGER;
break;
case LINEAR_LAYOUT_MANAGER:
mLayoutManager = new LinearLayoutManager(getActivity());
mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
break;
default:
mLayoutManager = new LinearLayoutManager(getActivity());
mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
}
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.scrollToPosition(scrollPosition);
}
use of android.support.v7.widget.GridLayoutManager in project AdMoney by ErnestoGonAr.
the class Saldo method setRecyclerViewLayoutManager.
public void setRecyclerViewLayoutManager(LayoutManagerType layoutManagerType) {
int scrollPosition = 0;
// If a layout manager has already been set, get current scroll position.
if (mRecyclerView.getLayoutManager() != null) {
scrollPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
}
switch(layoutManagerType) {
case GRID_LAYOUT_MANAGER:
mLayoutManager = new GridLayoutManager(getActivity(), SPAN_COUNT);
mCurrentLayoutManagerType = LayoutManagerType.GRID_LAYOUT_MANAGER;
break;
case LINEAR_LAYOUT_MANAGER:
mLayoutManager = new LinearLayoutManager(getActivity());
mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
break;
default:
mLayoutManager = new LinearLayoutManager(getActivity());
mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;
}
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.scrollToPosition(scrollPosition);
}
Aggregations