Search in sources :

Example 1 with AssignmentGroup

use of com.instructure.canvasapi2.models.AssignmentGroup 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)

Example 2 with AssignmentGroup

use of com.instructure.canvasapi2.models.AssignmentGroup in project instructure-android by instructure.

the class AssignmentDateListRecyclerAdapter method addAndSortAssignments.

private void addAndSortAssignments(List<AssignmentGroup> assignmentGroups) {
    Date today = new Date();
    for (AssignmentGroup assignmentGroup : assignmentGroups) {
        // endtodo
        for (Assignment assignment : assignmentGroup.getAssignments()) {
            Date dueDate = assignment.getDueAt();
            Submission submission = assignment.getSubmission();
            assignment.setSubmission(submission);
            boolean isWithoutGradedSubmission = submission == null || submission.isWithoutGradedSubmission();
            boolean isOverdue = assignment.isAllowedToSubmit() && isWithoutGradedSubmission;
            if (dueDate == null) {
                addOrUpdateItem(mUndated, assignment);
            } else {
                if (today.before(dueDate)) {
                    addOrUpdateItem(mUpcoming, assignment);
                } else if (isOverdue) {
                    addOrUpdateItem(mOverdue, assignment);
                } else {
                    addOrUpdateItem(mPast, assignment);
                }
            }
        }
    }
    setAllPagesLoaded(true);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) AssignmentGroup(com.instructure.canvasapi2.models.AssignmentGroup) Date(java.util.Date)

Example 3 with AssignmentGroup

use of com.instructure.canvasapi2.models.AssignmentGroup in project instructure-android by instructure.

the class AssignmentAPI method getNextPageAssignmentGroupsWithAssignments.

public static void getNextPageAssignmentGroupsWithAssignments(boolean forceNetwork, @NonNull String nextUrl, @NonNull RestBuilder adapter, @NonNull StatusCallback<List<AssignmentGroup>> callback) {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
    callback.addCall(adapter.build(AssignmentInterface.class, params).getNextPageAssignmentGroupListWithAssignments(nextUrl)).enqueue(callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 4 with AssignmentGroup

use of com.instructure.canvasapi2.models.AssignmentGroup in project instructure-android by instructure.

the class AssignmentAPI method getNextPageAssignmentGroupsWithAssignmentsForGradingPeriod.

public static void getNextPageAssignmentGroupsWithAssignmentsForGradingPeriod(boolean forceNetwork, @NonNull String nextUrl, @NonNull RestBuilder adapter, @NonNull StatusCallback<List<AssignmentGroup>> callback) {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
    callback.addCall(adapter.build(AssignmentInterface.class, params).getNextPageAssignmentGroupListWithAssignmentsForGradingPeriod(nextUrl)).enqueue(callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 5 with AssignmentGroup

use of com.instructure.canvasapi2.models.AssignmentGroup in project instructure-android by instructure.

the class AssignmentManager method getAssignmentGroup.

public static void getAssignmentGroup(long courseId, long assignmentGroupId, boolean forceNetwork, StatusCallback<AssignmentGroup> callback) {
    if (isTesting() || mTesting) {
        AssignmentManager_Test.getAssignmentGroup(courseId, assignmentGroupId, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        AssignmentAPI.getAssignmentGroup(courseId, assignmentGroupId, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Aggregations

AssignmentGroup (com.instructure.canvasapi2.models.AssignmentGroup)6 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)5 RestParams (com.instructure.canvasapi2.builders.RestParams)5 List (java.util.List)4 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)3 Request (okhttp3.Request)3 Response (okhttp3.Response)3 StatusCallback (com.instructure.canvasapi2.StatusCallback)2 Assignment (com.instructure.canvasapi2.models.Assignment)2 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)2 ArrayList (java.util.ArrayList)2 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 Course (com.instructure.canvasapi2.models.Course)1 Submission (com.instructure.canvasapi2.models.Submission)1