Search in sources :

Example 91 with Course

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);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 92 with Course

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) {
        }
    });
}
Also used : AdapterView(android.widget.AdapterView) Course(com.instructure.canvasapi2.models.Course) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) CheckedTextView(android.widget.CheckedTextView) FileUploadCoursesAdapter(com.instructure.candroid.adapter.FileUploadCoursesAdapter)

Example 93 with Course

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);
}
Also used : ArrayList(java.util.ArrayList) CanvasContext(com.instructure.canvasapi2.models.CanvasContext) Course(com.instructure.canvasapi2.models.Course)

Example 94 with Course

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;
}
Also used : Course(com.instructure.canvasapi2.models.Course)

Example 95 with Course

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;
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) Course(com.instructure.canvasapi2.models.Course)

Aggregations

Course (com.instructure.canvasapi2.models.Course)106 Test (org.junit.Test)70 ArrayList (java.util.ArrayList)39 Enrollment (com.instructure.canvasapi2.models.Enrollment)29 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)17 RestParams (com.instructure.canvasapi2.builders.RestParams)17 View (android.view.View)13 Bundle (android.os.Bundle)10 TextView (android.widget.TextView)10 NonNull (android.support.annotation.NonNull)8 AdapterView (android.widget.AdapterView)8 ModuleItem (com.instructure.canvasapi2.models.ModuleItem)8 ParentFragment (com.instructure.candroid.fragment.ParentFragment)7 CanvasContext (com.instructure.canvasapi2.models.CanvasContext)7 ImageView (android.widget.ImageView)6 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)6 List (java.util.List)6 BindView (butterknife.BindView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 StatusCallback (com.instructure.canvasapi2.StatusCallback)4