Search in sources :

Example 1 with HotNewListAdapter

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

the class FrageHotsNews method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    ((RadioButton) mRootView.findViewById(R.id.btn_1)).setText("新帖");
    mRootView.findViewById(R.id.btn_2).setVisibility(View.GONE);
    ((RadioButton) mRootView.findViewById(R.id.btn_3)).setText("热贴");
    postList = mRootView.findViewById(R.id.recycler_view);
    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);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    postList.setLayoutManager(mLayoutManager);
    postList.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
    // 设置可以滑出底栏
    postList.setClipToPadding(false);
    postList.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.bottombarHeight));
    adapter = new HotNewListAdapter(getActivity(), mydataset, galleryDatas);
    postList.setAdapter(adapter);
    postList.addOnScrollListener(new LoadMoreListener((LinearLayoutManager) mLayoutManager, this, 10));
    refreshLayout.setOnRefreshListener(this::refresh);
    RadioGroup swictchMes = mRootView.findViewById(R.id.btn_change);
    swictchMes.setOnCheckedChangeListener((radioGroup, id) -> {
        int pos = -1;
        if (id == R.id.btn_1) {
            pos = TYPE_NEW;
        } else {
            pos = TYPE_HOT;
        }
        if (pos != currentType) {
            currentType = pos;
            refreshLayout.setRefreshing(true);
            refresh();
        }
    });
    return mRootView;
}
Also used : MyListDivider(me.yluo.ruisiapp.widget.MyListDivider) LoadMoreListener(me.yluo.ruisiapp.listener.LoadMoreListener) HotNewListAdapter(me.yluo.ruisiapp.adapter.HotNewListAdapter) RadioGroup(android.widget.RadioGroup) RecyclerView(android.support.v7.widget.RecyclerView) RadioButton(android.widget.RadioButton) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

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