use of com.instructure.candroid.decorations.DividerItemDecoration in project instructure-android by instructure.
the class ParentFragment method configureRecyclerView.
@Override
public PandaRecyclerView configureRecyclerView(View rootView, Context context, final BaseRecyclerAdapter baseRecyclerAdapter, int swipeRefreshLayoutResId, int emptyViewResId, int recyclerViewResId, String emptyViewString, boolean withDivider) {
EmptyViewInterface emptyViewInterface = rootView.findViewById(emptyViewResId);
PandaRecyclerView recyclerView = rootView.findViewById(recyclerViewResId);
baseRecyclerAdapter.setSelectedItemId(getDefaultSelectedId());
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 = rootView.findViewById(swipeRefreshLayoutResId);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (!NetworkUtils.isNetworkAvailable()) {
mSwipeRefreshLayout.setRefreshing(false);
} else {
baseRecyclerAdapter.refresh();
}
}
});
return recyclerView;
}
Aggregations