Search in sources :

Example 1 with AssignmentGroupListRecyclerAdapter

use of com.instructure.speedgrader.adapters.AssignmentGroupListRecyclerAdapter in project instructure-android by instructure.

the class AssignmentListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    if (savedInstanceState != null) {
        loadSavedInstanceState(savedInstanceState);
    }
    mAdapterToFragmentCallback = new AssignmentAdapterToFragmentCallback() {

        @Override
        public void onRowClicked(Assignment assignment) {
            if (mSectionsSpinner.getSelectedItem() != null) {
                startActivityForResult(DocumentActivity.createIntent(getContext(), getCanvasContext(), assignment, ((Section) mSectionsSpinner.getSelectedItem()).getId()), Const.UPDATED_ASSIGNMENT_FLAGS);
            } else {
                startActivityForResult(DocumentActivity.createIntent(getContext(), getCanvasContext(), assignment, getAllSectionsItem().getId()), Const.UPDATED_ASSIGNMENT_FLAGS);
            }
        }

        @Override
        public void onRefreshFinished() {
            setRefreshing(false);
        }

        @Override
        public Section getCurrentSection() {
            if (mSectionsSpinner == null || mSectionsSpinner.getSelectedItem() == null) {
                return getAllSectionsItem();
            }
            return (Section) mSectionsSpinner.getSelectedItem();
        }

        @Override
        public void onSectionsLoaded(List<Section> sections) {
            if (!isAdded()) {
                return;
            }
            mSections = sections;
            if (mSectionsSpinner != null) {
                createSectionsSpinner();
            }
        }
    };
    if (mRecyclerAdapter == null) {
        mRecyclerAdapter = new AssignmentGroupListRecyclerAdapter(getContext(), getCanvasContext(), mAdapterToFragmentCallback);
    }
    if (getActivity() instanceof HomeActivity) {
        ((HomeActivity) getActivity()).hideDrawer();
    }
    handleActionBarColor();
    setTitle(getCanvasContext().getName());
    configureRecyclerViewAsGrid(mRootView, mRecyclerAdapter, R.id.swipeRefreshLayout, R.id.emptyPandaView, R.id.listView);
    if (isRouting) {
        isRouting = false;
        startActivityForResult(DocumentActivity.createIntent(getContext(), getCanvasContext(), mRoutedAssignment, getAllSectionsItem().getId()), Const.UPDATED_ASSIGNMENT_FLAGS);
        getActivity().overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
    }
    return mRootView;
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) HomeActivity(com.instructure.speedgrader.activities.HomeActivity) AssignmentGroupListRecyclerAdapter(com.instructure.speedgrader.adapters.AssignmentGroupListRecyclerAdapter) AssignmentAdapterToFragmentCallback(com.instructure.speedgrader.interfaces.AssignmentAdapterToFragmentCallback) Section(com.instructure.canvasapi.model.Section)

Aggregations

Assignment (com.instructure.canvasapi.model.Assignment)1 Section (com.instructure.canvasapi.model.Section)1 HomeActivity (com.instructure.speedgrader.activities.HomeActivity)1 AssignmentGroupListRecyclerAdapter (com.instructure.speedgrader.adapters.AssignmentGroupListRecyclerAdapter)1 AssignmentAdapterToFragmentCallback (com.instructure.speedgrader.interfaces.AssignmentAdapterToFragmentCallback)1