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