Search in sources :

Example 51 with Assignment

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());
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) ParentFragment(com.instructure.candroid.fragment.ParentFragment) Bundle(android.os.Bundle) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 52 with Assignment

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

Example 53 with Assignment

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;
    }
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Drawable(android.graphics.drawable.Drawable) View(android.view.View) Date(java.util.Date)

Example 54 with Assignment

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) {
        }
    });
}
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 55 with Assignment

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));
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) ArrayList(java.util.ArrayList) FileUploadAssignmentsAdapter(com.instructure.candroid.adapter.FileUploadAssignmentsAdapter)

Aggregations

Assignment (com.instructure.canvasapi2.models.Assignment)62 Test (org.junit.Test)46 Submission (com.instructure.canvasapi2.models.Submission)25 Date (java.util.Date)18 ArrayList (java.util.ArrayList)15 View (android.view.View)10 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)10 Course (com.instructure.canvasapi2.models.Course)9 RestParams (com.instructure.canvasapi2.builders.RestParams)7 Bundle (android.os.Bundle)6 ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)6 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)6 Navigation (com.instructure.interactions.Navigation)5 DrawableRes (android.support.annotation.DrawableRes)4 AdapterView (android.widget.AdapterView)4 TextView (android.widget.TextView)4 Request (okhttp3.Request)4 Response (okhttp3.Response)4 Paint (android.graphics.Paint)3 Drawable (android.graphics.drawable.Drawable)3