Search in sources :

Example 1 with MessageAdapter

use of me.yluo.ruisiapp.adapter.MessageAdapter in project Ruisi by freedom10086.

the class FrageMessage method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    messageList = mRootView.findViewById(R.id.recycler_view);
    tab1 = mRootView.findViewById(R.id.btn_1);
    tab2 = mRootView.findViewById(R.id.btn_2);
    tab3 = mRootView.findViewById(R.id.btn_3);
    // 设置可以滑出底栏
    messageList.setClipToPadding(false);
    messageList.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.bottombarHeight));
    refreshLayout = mRootView.findViewById(R.id.refresh_layout);
    refreshLayout.setColorSchemeResources(R.color.red_light, R.color.green_light, R.color.blue_light, R.color.orange_light);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    messageList.setLayoutManager(layoutManager);
    messageList.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
    messageList.addOnScrollListener(new LoadMoreListener(layoutManager, this, 8));
    adapter = new MessageAdapter(getActivity(), datas);
    if (!App.ISLOGIN(getActivity())) {
        adapter.changeLoadMoreState(BaseAdapter.STATE_NEED_LOGIN);
    }
    messageList.setAdapter(adapter);
    refreshLayout.setOnRefreshListener(() -> pullRefresh());
    RadioGroup swictchMes = mRootView.findViewById(R.id.btn_change);
    swictchMes.setOnCheckedChangeListener((radioGroup, id) -> {
        int pos = 2;
        if (id == R.id.btn_1) {
            pos = 0;
        } else if (id == R.id.btn_2) {
            pos = 1;
        }
        if (pos != index) {
            index = pos;
            getData(true);
        }
    });
    return mRootView;
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) MessageAdapter(me.yluo.ruisiapp.adapter.MessageAdapter) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) RadioGroup(android.widget.RadioGroup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RadioGroup (android.widget.RadioGroup)1 MessageAdapter (me.yluo.ruisiapp.adapter.MessageAdapter)1 LoadMoreListener (me.yluo.ruisiapp.listener.LoadMoreListener)1 MyListDivider (me.yluo.ruisiapp.widget.MyListDivider)1