Search in sources :

Example 1 with ModelRecyclerAdapter

use of github.chenupt.multiplemodel.recycler.ModelRecyclerAdapter in project DragTopLayout by chenupt.

the class RecyclerFragment method initViews.

private void initViews() {
    RecyclerView recyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    // init recycler view
    ModelRecyclerAdapter adapter = new ModelRecyclerAdapter(getActivity(), DataService.getInstance().getModelManager());
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(adapter);
    // set data source
    adapter.setList(DataService.getInstance().getList());
    adapter.notifyDataSetChanged();
    // attach top listener
    recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            EventBus.getDefault().post(AttachUtil.isRecyclerViewAttach(recyclerView));
        }
    });
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) ModelRecyclerAdapter(github.chenupt.multiplemodel.recycler.ModelRecyclerAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ModelRecyclerAdapter (github.chenupt.multiplemodel.recycler.ModelRecyclerAdapter)1