Search in sources :

Example 21 with DiscussionTopicHeader

use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.

the class DiscussionManager method updateDiscussionTopic.

public static void updateDiscussionTopic(CanvasContext canvasContext, long topicId, @NonNull String title, @NonNull String message, boolean threaded, boolean isPublished, StatusCallback<DiscussionTopicHeader> callback) {
    if (isTesting() || mTesting) {
    // TODO:
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).build();
        DiscussionAPI.updateDiscussionTopic(adapter, canvasContext, topicId, title, message, threaded, isPublished, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 22 with DiscussionTopicHeader

use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.

the class DiscussionManager method getDetailedDiscussionAirwolf.

public static void getDetailedDiscussionAirwolf(String airwolfDomain, String parentId, String studentId, String courseId, String discussionTopicId, StatusCallback<DiscussionTopicHeader> callback) {
    if (isTesting() || mTesting) {
    // TODO:
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(false).withDomain(airwolfDomain).withAPIVersion("").build();
        DiscussionAPI.getDetailedDiscussionAirwolf(adapter, parentId, studentId, courseId, discussionTopicId, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 23 with DiscussionTopicHeader

use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.

the class DiscussionManager method getDetailedDiscussion.

public static void getDetailedDiscussion(CanvasContext canvasContext, long topicId, StatusCallback<DiscussionTopicHeader> callback) {
    if (isTesting() || mTesting) {
    // TODO:
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        DiscussionAPI.getDetailedDiscussion(adapter, canvasContext, topicId, callback, new RestParams.Builder().build());
    }
}
Also used : RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 24 with DiscussionTopicHeader

use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.

the class DiscussionListRecyclerAdapterTest method testCompare_oneNullDateLastReply.

@Test
public void testCompare_oneNullDateLastReply() {
    DiscussionTopicHeader d1 = new DiscussionTopicHeader();
    d1.setTitle("discussion1");
    DateTime dateTime2 = new DateTime("2014-12-29");
    Date date = new Date(dateTime2.getMilliseconds(TimeZone.getDefault()));
    d1.setLastReplyAt(APIHelper.dateToString(date));
    DiscussionTopicHeader d2 = new DiscussionTopicHeader();
    d2.setTitle("discussion2");
    assertEquals(-1, mAdapter.createItemCallback().compare("", d1, d2));
    assertEquals(1, mAdapter.createItemCallback().compare("", d2, d1));
    assertEquals(0, mAdapter.createItemCallback().compare("", d1, d1));
}
Also used : DiscussionTopicHeader(com.instructure.canvasapi2.models.DiscussionTopicHeader) DateTime(hirondelle.date4j.DateTime) Date(java.util.Date) Test(org.junit.Test)

Example 25 with DiscussionTopicHeader

use of com.instructure.canvasapi2.models.DiscussionTopicHeader in project instructure-android by instructure.

the class DiscussionListRecyclerAdapterTest method testCompare_bothHaveDates.

@Test
public void testCompare_bothHaveDates() {
    DiscussionTopicHeader d1 = new DiscussionTopicHeader();
    d1.setTitle("discussion1");
    DateTime dateTime1 = new DateTime("2014-12-27");
    Date date1 = new Date(dateTime1.getMilliseconds(TimeZone.getDefault()));
    d1.setLastReplyAt(APIHelper.dateToString(date1));
    DiscussionTopicHeader d2 = new DiscussionTopicHeader();
    DateTime dateTime2 = new DateTime("2014-12-29");
    Date date2 = new Date(dateTime2.getMilliseconds(TimeZone.getDefault()));
    d2.setLastReplyAt(APIHelper.dateToString(date2));
    d2.setTitle("discussion2");
    // callback sorts most recent date first
    assertEquals(1, mAdapter.createItemCallback().compare("", d1, d2));
    assertEquals(-1, mAdapter.createItemCallback().compare("", d2, d1));
    assertEquals(0, mAdapter.createItemCallback().compare("", d1, d1));
}
Also used : DiscussionTopicHeader(com.instructure.canvasapi2.models.DiscussionTopicHeader) DateTime(hirondelle.date4j.DateTime) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DiscussionTopicHeader (com.instructure.canvasapi2.models.DiscussionTopicHeader)24 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)20 RestParams (com.instructure.canvasapi2.builders.RestParams)19 Test (org.junit.Test)17 List (java.util.List)6 StatusCallback (com.instructure.canvasapi2.StatusCallback)4 DiscussionEntry (com.instructure.canvasapi2.models.DiscussionEntry)4 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)4 ArrayList (java.util.ArrayList)4 NotNull (org.jetbrains.annotations.NotNull)4 DateTime (hirondelle.date4j.DateTime)3 Date (java.util.Date)3 Assignment (com.instructure.canvasapi2.models.Assignment)2 Course (com.instructure.canvasapi2.models.Course)2 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)2 Response (okhttp3.Response)2 ViewGroup (android.view.ViewGroup)1 AccountNotification (com.instructure.canvasapi2.models.AccountNotification)1 Group (com.instructure.canvasapi2.models.Group)1 ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)1