use of com.instructure.speedgrader.decorations.DividerItemDecoration in project instructure-android by instructure.
the class ParentFragment method configureRecyclerView.
public PandaRecyclerView configureRecyclerView(View rootView, Context context, final BaseRecyclerAdapter baseRecyclerAdapter, int swipeRefreshLayoutResId, int emptyViewResId, int recyclerViewResId, String emptyViewString, boolean withDivider) {
EmptyViewInterface emptyViewInterface = (EmptyViewInterface) rootView.findViewById(emptyViewResId);
PandaRecyclerView recyclerView = (PandaRecyclerView) rootView.findViewById(recyclerViewResId);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setEmptyView(emptyViewInterface);
emptyViewInterface.emptyViewText(emptyViewString);
emptyViewInterface.setNoConnectionText(getString(R.string.noConnection));
recyclerView.setSelectionEnabled(true);
recyclerView.setAdapter(baseRecyclerAdapter);
if (withDivider) {
recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL_LIST));
}
mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(swipeRefreshLayoutResId);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (!com.instructure.pandautils.utils.Utils.isNetworkAvailable(getContext())) {
mSwipeRefreshLayout.setRefreshing(false);
} else {
baseRecyclerAdapter.refresh();
}
}
});
return recyclerView;
}
Aggregations