Search in sources :

Example 1 with AssignmentDueDate

use of com.instructure.canvasapi.model.AssignmentDueDate in project instructure-android by instructure.

the class AssignmentUnitTest method testAssignmentDueDate.

@Test
public void testAssignmentDueDate() {
    Gson gson = CanvasRestAdapter.getGSONParser();
    Assignment assignment = gson.fromJson(assignmentDueDates, Assignment.class);
    List<AssignmentDueDate> allDates = assignment.getDueDates();
    assertEquals(allDates.size(), 2);
    for (AssignmentDueDate dueDate : allDates) {
        assertNotNull(dueDate.getDueDate());
    }
}
Also used : Assignment(com.instructure.canvasapi.model.Assignment) AssignmentDueDate(com.instructure.canvasapi.model.AssignmentDueDate) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 2 with AssignmentDueDate

use of com.instructure.canvasapi.model.AssignmentDueDate in project instructure-android by instructure.

the class AssignmentBinder method getDueDateString.

public static String getDueDateString(Context context, Assignment assignment) {
    String dateString = "";
    int index = 0;
    if (assignment.getDueDates() != null) {
        for (AssignmentDueDate dueDate : assignment.getDueDates()) {
            if (dueDate.getDueDate() != null) {
                if (index == 0) {
                    dateString += " " + DateHelpers.createPrefixedDateTimeString(context, context.getResources().getString(R.string.due), dueDate.getDueDate());
                } else {
                    dateString += ", " + DateHelpers.getDateTimeString(context, dueDate.getDueDate());
                }
            }
            index++;
        }
    } else if (assignment.getDueDates() == null && assignment.getDueDate() != null) {
        dateString = DateHelpers.createPrefixedDateTimeString(context, context.getResources().getString(R.string.due), assignment.getDueDate());
    }
    if (dateString == "") {
        dateString = context.getResources().getString(R.string.noDueDate);
    }
    return dateString;
}
Also used : AssignmentDueDate(com.instructure.canvasapi.model.AssignmentDueDate)

Aggregations

AssignmentDueDate (com.instructure.canvasapi.model.AssignmentDueDate)2 Gson (com.google.gson.Gson)1 Assignment (com.instructure.canvasapi.model.Assignment)1 Test (org.junit.Test)1