use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class CourseAPI method getNextPageFavoriteCourses.
public static void getNextPageFavoriteCourses(boolean forceNetwork, String nextUrl, RestBuilder adapter, StatusCallback<List<Course>> callback) {
RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
callback.addCall(adapter.build(CoursesInterface.class, params).next(nextUrl)).enqueue(callback);
}
use of com.instructure.canvasapi2.models.Course 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.Course in project instructure-android by instructure.
the class CanvasContextSpinnerAdapter method newAdapterInstance.
public static CanvasContextSpinnerAdapter newAdapterInstance(Context context, List<Course> courses, List<Group> groups) {
ArrayList<CanvasContext> canvasContexts = new ArrayList<>();
if (!courses.isEmpty()) {
Course courseSeparator = new Course();
courseSeparator.setName(context.getString(R.string.courses));
courseSeparator.setId(COURSE_SEPARATOR);
canvasContexts.add(courseSeparator);
canvasContexts.addAll(courses);
}
if (!groups.isEmpty()) {
Course groupSeparator = new Course();
groupSeparator.setName(context.getString(R.string.groups));
groupSeparator.setId(GROUP_SEPARATOR);
canvasContexts.add(groupSeparator);
canvasContexts.addAll(groups);
}
return new CanvasContextSpinnerAdapter(context, canvasContexts);
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class FileUploadCoursesAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final CourseViewHolder viewHolder;
if (convertView == null) {
Logger.d("creating view holder, getView");
convertView = mInflater.inflate(R.layout.canvas_context_spinner_adapter_item, null);
viewHolder = new CourseViewHolder();
viewHolder.title = (TextView) convertView.findViewById(R.id.title);
viewHolder.indicator = (ImageView) convertView.findViewById(R.id.icon);
convertView.setTag(viewHolder);
} else {
viewHolder = (CourseViewHolder) convertView.getTag();
}
Course item = mCourses.get(position);
if (item != null) {
viewHolder.title.setText(item.getName());
viewHolder.indicator.setVisibility(View.VISIBLE);
viewHolder.indicator.setBackground(BaseBinder.createIndicatorBackground(ColorKeeper.getOrGenerateColor(item)));
} else {
viewHolder.indicator.setVisibility(View.GONE);
viewHolder.title.setText("");
}
return convertView;
}
use of com.instructure.canvasapi2.models.Course in project instructure-android by instructure.
the class ModuleListRecyclerAdapter method isSequentiallyEnabled.
// endregion
// region Module binder Helpers
private boolean isSequentiallyEnabled(ModuleObject moduleObject, ModuleItem moduleItem) {
// 0 based) or the previous item is unlocked
if (mCanvasContext instanceof Course && (((Course) mCanvasContext).isTeacher() || ((Course) mCanvasContext).isTA())) {
return true;
}
if (moduleObject.isSequential_progress() && (moduleObject.getState() != null && (moduleObject.getState().equals(ModuleObject.STATE.unlocked.toString()) || moduleObject.getState().equals(ModuleObject.STATE.started.toString())))) {
// group is sequential, need to figure out which ones to grey out
int indexOfCurrentModuleItem = storedIndexOfItem(moduleObject, moduleItem);
if (indexOfCurrentModuleItem != -1) {
// getItem performs invalid index checks
ModuleItem previousModuleItem = getItem(moduleObject, indexOfCurrentModuleItem - 1);
ModuleItem nextModuleItem = getItem(moduleObject, indexOfCurrentModuleItem + 1);
if (isComplete(moduleItem)) {
return true;
} else if (previousModuleItem == null) {
// Its the first one in the sequence
return true;
} else if (!isComplete(previousModuleItem)) {
// previous item is not complete
return false;
} else if (isComplete(previousModuleItem) && !isComplete(moduleItem)) {
// previous complete, so show current as next in sequence
return true;
} else {
return false;
}
}
}
return true;
}
Aggregations