Search in sources :

Example 26 with DiscussionTopicHeader

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

the class DiscussionListRecyclerAdapterTest method testAreContentsTheSame_DifferentTitle.

@Test
public void testAreContentsTheSame_DifferentTitle() {
    DiscussionTopicHeader discussionTopicHeader1 = new DiscussionTopicHeader();
    discussionTopicHeader1.setTitle("discussion1");
    DiscussionTopicHeader discussionTopicHeader2 = new DiscussionTopicHeader();
    discussionTopicHeader2.setTitle("discussion2");
    assertFalse(mAdapter.createItemCallback().areContentsTheSame(discussionTopicHeader1, discussionTopicHeader2));
}
Also used : DiscussionTopicHeader(com.instructure.canvasapi2.models.DiscussionTopicHeader) Test(org.junit.Test)

Example 27 with DiscussionTopicHeader

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

the class DiscussionManager method getFilteredDiscussionTopic.

public static void getFilteredDiscussionTopic(final boolean forceNetwork, @NonNull CanvasContext canvasContext, @NonNull String searchTerm, StatusCallback<List<DiscussionTopicHeader>> callback) {
    if (isTesting() || mTesting) {
    // TODO:
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).build();
        DiscussionAPI.getFilteredDiscussionTopic(canvasContext, searchTerm, callback, adapter, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 28 with DiscussionTopicHeader

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

the class DiscussionManager method getAllPinnedDiscussions.

public static void getAllPinnedDiscussions(@NonNull CanvasContext canvasContext, final boolean forceNetwork, StatusCallback<List<DiscussionTopicHeader>> callback) {
    if (isTesting() || mTesting) {
    // TODO:
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(false).build();
        StatusCallback<List<DiscussionTopicHeader>> depaginatedCallback = new ExhaustiveListCallback<DiscussionTopicHeader>(callback) {

            @Override
            public void getNextPage(@NotNull StatusCallback<List<DiscussionTopicHeader>> callback, @NotNull String nextUrl, boolean isCached) {
                DiscussionAPI.getNextPage(nextUrl, adapter, callback, params);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        DiscussionAPI.getFirstPagePinnedDiscussions(canvasContext, adapter, depaginatedCallback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) DiscussionTopicHeader(com.instructure.canvasapi2.models.DiscussionTopicHeader) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback) NotNull(org.jetbrains.annotations.NotNull)

Example 29 with DiscussionTopicHeader

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

the class DiscussionManager method unpinDiscussionTopicHeader.

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

Example 30 with DiscussionTopicHeader

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

the class DiscussionManager method pinDiscussionTopicHeader.

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

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