Search in sources :

Example 1 with DividerItemDecoration

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;
}
Also used : PandaRecyclerView(com.instructure.pandarecycler.PandaRecyclerView) EmptyViewInterface(com.instructure.pandarecycler.interfaces.EmptyViewInterface) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.instructure.candroid.decorations.DividerItemDecoration) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 DividerItemDecoration (com.instructure.candroid.decorations.DividerItemDecoration)1 PandaRecyclerView (com.instructure.pandarecycler.PandaRecyclerView)1 EmptyViewInterface (com.instructure.pandarecycler.interfaces.EmptyViewInterface)1