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;
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations