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));
}
});
}
Aggregations