Search in sources :

Example 6 with Recipient

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

the class RecipientManager method searchAllRecipientsNoSyntheticContexts.

/**
 * Synthetic contexts == sections and groups, so this will return only actual users, not groups or sections
 *
 * @param forceNetwork
 * @param searchQuery
 * @param context
 * @param callback
 */
public static void searchAllRecipientsNoSyntheticContexts(final boolean forceNetwork, String searchQuery, String context, StatusCallback<List<Recipient>> callback) {
    if (isTesting() || mTesting) {
    // TODO...
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        StatusCallback<List<Recipient>> depaginatedCallback = new ExhaustiveListCallback<Recipient>(callback) {

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Recipient>> callback, @NonNull String nextUrl, boolean isCached) {
                RecipientAPI.getNextPageRecipients(forceNetwork, nextUrl, adapter, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        RecipientAPI.getFirstPageRecipientsNoSyntheticContexts(forceNetwork, searchQuery, context, adapter, depaginatedCallback);
    }
}
Also used : NonNull(android.support.annotation.NonNull) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) Recipient(com.instructure.canvasapi2.models.Recipient) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Example 7 with Recipient

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

the class RecipientManager method searchRecipients.

public static void searchRecipients(String searchQuery, String context, StatusCallback<List<Recipient>> callback) {
    if (isTesting() || mTesting) {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
        RecipientManager_Test.getFirstPageRecipients(searchQuery, context, callback, adapter, params);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
        RecipientAPI.getRecipients(searchQuery, context, callback, adapter, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 8 with Recipient

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

the class RecipientAPI method getFirstPageRecipients.

public static void getFirstPageRecipients(boolean forceNetwork, String searchQuery, String context, @NonNull RestBuilder adapter, @NonNull StatusCallback<List<Recipient>> callback) {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
    callback.addCall(adapter.build(RecipientInterface.class, params).getFirstPageRecipientList(searchQuery, context)).enqueue(callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 9 with Recipient

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

the class RecipientAPI method getNextPageRecipients.

public static void getNextPageRecipients(boolean forceNetwork, String nextUrl, @NonNull RestBuilder adapter, @NonNull StatusCallback<List<Recipient>> callback) {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
    adapter.build(RecipientInterface.class, params).getNextPageRecipientList(nextUrl).enqueue(callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 10 with Recipient

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

the class RecipientAPI method getFirstPageRecipientsNoSyntheticContexts.

// Synthetic contexts == groups and sections, so this search will return only users
public static void getFirstPageRecipientsNoSyntheticContexts(boolean forceNetwork, String searchQuery, String context, @NonNull RestBuilder adapter, @NonNull StatusCallback<List<Recipient>> callback) {
    RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withForceReadFromNetwork(forceNetwork).build();
    callback.addCall(adapter.build(RecipientInterface.class, params).getFirstPageRecipientListNoSyntheticContexts(searchQuery, context)).enqueue(callback);
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Aggregations

Recipient (com.instructure.canvasapi2.models.Recipient)14 Test (org.junit.Test)9 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)7 RestParams (com.instructure.canvasapi2.builders.RestParams)4 NonNull (android.support.annotation.NonNull)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 RecipientEntry (com.android.ex.chips.RecipientEntry)2 StatusCallback (com.instructure.canvasapi2.StatusCallback)2 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)2 Context (android.content.Context)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 Rfc822Tokenizer (android.text.util.Rfc822Tokenizer)1 CanvasContext (com.instructure.canvasapi2.models.CanvasContext)1 Enrollment (com.instructure.canvasapi2.models.Enrollment)1 User (com.instructure.canvasapi2.models.User)1 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)1 RecipientAdapter (com.instructure.teacher.adapters.RecipientAdapter)1