use of com.muzi.library.manager.MLinearLayoutManager in project VerticalCalendar by mzyq.
the class CalendarView method initRecyclerView.
/**
* 初始化RecyclerView
*/
private void initRecyclerView() {
recyclerView.setLayoutManager(new MLinearLayoutManager(getContext()));
calendarAdapter = new CalendarAdapter(getContext(), R.layout.item_month, monthList);
recyclerView.setAdapter(calendarAdapter);
recyclerView.addOnItemTouchListener(new OnItemChildClickListener() {
@Override
public void onSimpleItemChildClick(BaseQuickAdapter adapter, View view, int position) {
if (view.getId() == R.id.rvMonth) {
rvPosition = position;
}
}
});
calendarAdapter.setListener(new CalendarAdapter.OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
if (rvPosition > -1) {
handleClick(rvPosition, position);
// 刷新adapter
calendarAdapter.notifyDataSetChanged();
rvPosition = -1;
}
}
});
}
Aggregations