use of com.chad.baserecyclerviewadapterhelper.decoration.GridSectionAverageGapItemDecoration 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