use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class FileFolderManager method deleteFolder.
public static void deleteFolder(long folderId, final StatusCallback<FileFolder> callback) {
if (isTesting() || mTesting) {
// TODO
} else {
final RestBuilder adapter = new RestBuilder(callback);
final RestParams params = new RestParams.Builder().build();
FileFolderAPI.deleteFolder(folderId, adapter, callback, params);
}
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class GroupCategoriesManager method getAllGroupsForCategory.
public static void getAllGroupsForCategory(long categoryId, StatusCallback<List<Group>> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO
} else {
final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
final RestBuilder adapter = new RestBuilder(callback);
StatusCallback<List<Group>> depaginatedCallback = new ExhaustiveListCallback<Group>(callback) {
@Override
public void getNextPage(@NonNull StatusCallback<List<Group>> callback, @NonNull String nextUrl, boolean isCached) {
GroupCategoriesAPI.getNextPageGroups(nextUrl, adapter, callback, params);
}
};
adapter.setStatusCallback(depaginatedCallback);
GroupCategoriesAPI.getFirstPageGroupsInCategory(categoryId, adapter, depaginatedCallback, params);
}
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class GroupManager method getFavoriteGroups.
public static void getFavoriteGroups(StatusCallback<List<Group>> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO
} else {
final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).withShouldIgnoreToken(false).build();
final RestBuilder adapter = new RestBuilder(callback);
StatusCallback<List<Group>> depaginatedCallback = new ExhaustiveListCallback<Group>(callback) {
@Override
public void getNextPage(@NonNull StatusCallback<List<Group>> callback, @NonNull String nextUrl, boolean isCached) {
GroupAPI.getNextPageGroups(nextUrl, adapter, callback, params);
}
};
adapter.setStatusCallback(depaginatedCallback);
GroupAPI.getFavoriteGroups(adapter, depaginatedCallback, params);
}
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class GroupManager method getFavoriteGroupsSynchronous.
@NonNull
public static List<Group> getFavoriteGroupsSynchronous(final boolean forceNetwork) throws IOException {
if (isTesting() || mTesting) {
// TODO
return new ArrayList<>();
} else {
final RestBuilder adapter = new RestBuilder();
RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
Response<List<Group>> response = GroupAPI.getFavoriteGroupsSynchronously(adapter, params);
if (response != null && response.isSuccessful() && response.body() != null)
return response.body();
else
return new ArrayList<>();
}
}
use of com.instructure.canvasapi2.builders.RestBuilder in project instructure-android by instructure.
the class GroupManager method getGroupsSynchronous.
/**
* So we are only going to fetch the first 200 groups. If you are reading this and are an instructor with more than 200 groups... sorry.
* @param forceNetwork
* @return
* @throws IOException
*/
@NonNull
public static List<Group> getGroupsSynchronous(final boolean forceNetwork) throws IOException {
if (isTesting() || mTesting) {
return new ArrayList<>();
} else {
final RestBuilder adapter = new RestBuilder();
RestParams params = new RestParams.Builder().withPerPageQueryParam(true).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
ArrayList<Group> items = new ArrayList<>();
Response<List<Group>> response = GroupAPI.getGroupsSynchronously(adapter, params);
if (response != null && response.isSuccessful() && response.body() != null)
items.addAll(response.body());
String nextUrl = nextUrl(response);
if (nextUrl != null) {
Response<List<Group>> nextResponse = GroupAPI.getNextPageGroupsSynchronously(nextUrl, adapter, params);
if (nextResponse != null && nextResponse.isSuccessful() && nextResponse.body() != null)
items.addAll(nextResponse.body());
}
return items;
}
}
Aggregations