Search in sources :

Example 1 with MLinearLayoutManager

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;
            }
        }
    });
}
Also used : CalendarAdapter(com.muzi.library.adapter.CalendarAdapter) MLinearLayoutManager(com.muzi.library.manager.MLinearLayoutManager) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) OnItemChildClickListener(com.chad.library.adapter.base.listener.OnItemChildClickListener) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 TextView (android.widget.TextView)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 OnItemChildClickListener (com.chad.library.adapter.base.listener.OnItemChildClickListener)1 CalendarAdapter (com.muzi.library.adapter.CalendarAdapter)1 MLinearLayoutManager (com.muzi.library.manager.MLinearLayoutManager)1