use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.
the class ModuleUtilityTest method testGetFragment_assignment.
@Test
public void testGetFragment_assignment() {
String url = "https://mobile.canvas.net/api/v1/courses/222/assignments/123456789";
ModuleItem moduleItem = new ModuleItem();
moduleItem.setType("Assignment");
moduleItem.setId(4567);
moduleItem.setUrl(url);
Course course = new Course();
Bundle expectedBundle = new Bundle();
expectedBundle.putSerializable(Const.CANVAS_CONTEXT, course);
expectedBundle.putLong(Const.ASSIGNMENT_ID, 123456789);
ParentFragment parentFragment = callGetFragment(moduleItem, course, null);
assertNotNull(parentFragment);
assertEquals(AssignmentFragment.class, parentFragment.getClass());
assertEquals(expectedBundle.toString(), parentFragment.getArguments().toString());
}
use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.
the class AssignmentAPI method getNextPageAssignments.
public static void getNextPageAssignments(@NonNull String nextUrl, @NonNull RestBuilder adapter, boolean forceNetwork, @NonNull StatusCallback<List<Assignment>> callback) {
RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
callback.addCall(adapter.build(AssignmentInterface.class, params).getNextPageAssignments(nextUrl)).enqueue(callback);
}
use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.
the class SyllabusBinder method bind.
public static void bind(final Context context, final SyllabusViewHolder holder, final int courseColor, final ScheduleItem item, final AdapterToFragmentCallback<ScheduleItem> adapterToFragmentCallback) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
adapterToFragmentCallback.onRowClicked(item, holder.getAdapterPosition(), false);
}
});
switch(item.getItemType()) {
case TYPE_CALENDAR:
case TYPE_ASSIGNMENT:
holder.title.setText(item.getTitle());
Drawable drawable;
Assignment assignment = item.getAssignment();
if (assignment != null) {
int drawableResId = getAssignmentIcon(assignment);
drawable = ColorKeeper.getColoredDrawable(context, drawableResId, courseColor);
holder.icon.setImageDrawable(drawable);
Date dueDate = assignment.getDueAt();
holder.date.setTextColor(context.getResources().getColor(R.color.secondaryText));
if (dueDate != null) {
String dateString = DateHelper.createPrefixedDateTimeString(context, R.string.toDoDue, dueDate);
holder.date.setText(dateString);
} else {
holder.date.setText(context.getResources().getString(R.string.toDoNoDueDate));
}
String description = getHtmlAsText(assignment.getDescription());
setCleanText(holder.description, description);
if (TextUtils.isEmpty(description))
holder.description.setVisibility(View.GONE);
else
holder.description.setVisibility(View.VISIBLE);
// currently submissions aren't returned for the syllabus fragment, so points will be null.
setGone(holder.points);
} else {
drawable = ColorKeeper.getColoredDrawable(context, R.drawable.vd_calendar, courseColor);
holder.icon.setImageDrawable(drawable);
setCleanText(holder.date, item.getStartDateString(context));
String description = getHtmlAsText(item.getDescription());
setCleanText(holder.description, description);
if (TextUtils.isEmpty(description))
holder.description.setVisibility(View.GONE);
else
holder.description.setVisibility(View.VISIBLE);
holder.points.setText("");
}
break;
default:
Logger.d("UNSUPPORTED TYPE FOUND IN SYLLABUS BINDER");
break;
}
}
use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.
the class ShareFileDestinationDialog method setupCourseSpinners.
private void setupCourseSpinners() {
if (studentEnrollmentsAdapter == null) {
studentEnrollmentsAdapter = new FileUploadCoursesAdapter(getActivity(), getActivity().getLayoutInflater(), FileUploadCoursesAdapter.getFilteredCourseList(courses, FileUploadCoursesAdapter.Type.STUDENT));
studentCoursesSpinner.setAdapter(studentEnrollmentsAdapter);
} else {
studentEnrollmentsAdapter.setCourses(FileUploadCoursesAdapter.getFilteredCourseList(courses, FileUploadCoursesAdapter.Type.STUDENT));
}
studentCoursesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// make the allowed extensions disappear
Course course = (Course) parent.getAdapter().getItem(position);
// if the user is a teacher, let them know and don't let them select an assignment
if (course.getId() > 0) {
setAssignmentsSpinnerToLoading();
AssignmentManager.getAllAssignments(course.getId(), false, canvasCallbackAssignments);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.
the class ShareFileDestinationDialog method setAssignmentsSpinnerToLoading.
private void setAssignmentsSpinnerToLoading() {
Assignment loading = new Assignment();
ArrayList<Assignment> courseAssignments = new ArrayList<>();
loading.setName(getString(R.string.loadingAssignments));
loading.setId(Long.MIN_VALUE);
courseAssignments.add(loading);
assignmentSpinner.setAdapter(new FileUploadAssignmentsAdapter(getActivity(), courseAssignments));
}
Aggregations