Search in sources :

Example 1 with AssignmentDateListRecyclerAdapter

use of com.instructure.candroid.adapter.AssignmentDateListRecyclerAdapter in project instructure-android by instructure.

the class AssignmentListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.assignment_list_layout, container, false);
    mToolbar = mRootView.findViewById(R.id.toolbar);
    setUpCallbacks();
    mAdapterToAssignmentsCallback = new AdapterToAssignmentsCallback() {

        @Override
        public void setTermSpinnerState(boolean isEnabled) {
            mTermSpinner.setEnabled(isEnabled);
            if (mTermAdapter != null) {
                if (isEnabled) {
                    mTermAdapter.setIsLoading(false);
                } else {
                    mTermAdapter.setIsLoading(true);
                }
                mTermAdapter.notifyDataSetChanged();
            }
        }

        @Override
        public void onRowClicked(Assignment assignment, int position, boolean isOpenDetail) {
            Navigation navigation = getNavigation();
            if (navigation != null) {
                Bundle bundle = AssignmentFragment.Companion.createBundle((Course) getCanvasContext(), assignment);
                navigation.addFragment(FragUtils.getFrag(AssignmentFragment.class, bundle));
            }
        }

        @Override
        public void onRefreshFinished() {
            setRefreshing(false);
        }
    };
    // Just load the AssignmentGroup list in the case that its a Group
    mRecyclerAdapter = new AssignmentDateListRecyclerAdapter(getContext(), getCanvasContext(), mGradingPeriodsCallback, mAdapterToAssignmentsCallback);
    configureRecyclerView(mRootView, getContext(), mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
    mTermSpinner = mRootView.findViewById(R.id.termSpinner);
    mTermSpinnerLayout = mRootView.findViewById(R.id.termSpinnerLayout);
    AppBarLayout appBarLayout = mRootView.findViewById(R.id.appbar);
    View shadow = mRootView.findViewById(R.id.shadow);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        shadow.setVisibility(View.GONE);
    } else {
        shadow.setVisibility(View.VISIBLE);
    }
    appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
            // workaround for Toolbar not showing with swipe to refresh
            if (i == 0) {
                setRefreshingEnabled(true);
            } else {
                setRefreshingEnabled(false);
            }
        }
    });
    return mRootView;
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Navigation(com.instructure.interactions.Navigation) Bundle(android.os.Bundle) AdapterToAssignmentsCallback(com.instructure.candroid.interfaces.AdapterToAssignmentsCallback) AssignmentDateListRecyclerAdapter(com.instructure.candroid.adapter.AssignmentDateListRecyclerAdapter) AppBarLayout(android.support.design.widget.AppBarLayout) Course(com.instructure.canvasapi2.models.Course) View(android.view.View) AdapterView(android.widget.AdapterView) PageView(com.instructure.canvasapi2.utils.pageview.PageView) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

Bundle (android.os.Bundle)1 AppBarLayout (android.support.design.widget.AppBarLayout)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 AssignmentDateListRecyclerAdapter (com.instructure.candroid.adapter.AssignmentDateListRecyclerAdapter)1 AdapterToAssignmentsCallback (com.instructure.candroid.interfaces.AdapterToAssignmentsCallback)1 Assignment (com.instructure.canvasapi2.models.Assignment)1 Course (com.instructure.canvasapi2.models.Course)1 PageView (com.instructure.canvasapi2.utils.pageview.PageView)1 Navigation (com.instructure.interactions.Navigation)1