use of com.instructure.canvasapi2.models.Group 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;
}
}
use of com.instructure.canvasapi2.models.Group in project instructure-android by instructure.
the class GroupManager method getAllGroups.
public static void getAllGroups(StatusCallback<List<Group>> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO
} else {
final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withPerPageQueryParam(true).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.getFirstPageGroups(adapter, depaginatedCallback, params);
}
}
use of com.instructure.canvasapi2.models.Group in project instructure-android by instructure.
the class GroupManager method getDetailedGroup.
public static void getDetailedGroup(long groupId, StatusCallback<Group> callback, boolean forceNetwork) {
if (isTesting() || mTesting) {
// TODO
} else {
final RestParams params = new RestParams.Builder().withForceReadFromNetwork(forceNetwork).withShouldIgnoreToken(false).build();
final RestBuilder adapter = new RestBuilder(callback);
GroupAPI.getDetailedGroup(adapter, callback, params, groupId);
}
}
use of com.instructure.canvasapi2.models.Group in project instructure-android by instructure.
the class CourseModuleProgressionFragment method updateBottomNavBarButtons.
// the bottom navigation bar has prev and next arrows that sometimes show up and sometimes don't depending
// on where the user is (on the first module item there isn't a prev button). We also may need to update these
// dynamically when we use an async task to get the next group of module items
private void updateBottomNavBarButtons() {
// make them visible by default
prev.setVisibility(View.VISIBLE);
next.setVisibility(View.VISIBLE);
// don't want to see the previous button if we're on the first item
if (currentPos == 0) {
prev.setVisibility(View.INVISIBLE);
}
// don't show the next button if we're on the last item
if (currentPos + 1 >= NUM_ITEMS) {
next.setVisibility(View.INVISIBLE);
}
// get the fragment and update the title
Fragment fragment = adapter.getItem(currentPos);
ModuleItem.CompletionRequirement completionRequirement = getCurrentModuleItem(currentPos).getCompletionRequirement();
if (completionRequirement != null && ModuleItem.MUST_VIEW.equals(completionRequirement.getType())) {
// reload the module object to update the items. By viewing this item subsequent items may now be unlocked
adapter.notifyDataSetChanged();
addLockedIconIfNeeded(modules, items, groupPos, childPos);
}
ModuleItem moduleItem = getCurrentModuleItem(currentPos);
updateModuleMarkDoneView(moduleItem);
}
use of com.instructure.canvasapi2.models.Group in project instructure-android by instructure.
the class NotificationListFragment method applyTheme.
@Override
public void applyTheme() {
CanvasContext canvasContext = getCanvasContext();
if (canvasContext instanceof Course || canvasContext instanceof Group) {
PandaViewUtils.setupToolbarBackButton(mToolbar, this);
ViewStyler.themeToolbar(getActivity(), mToolbar, canvasContext);
} else {
Navigation navigation = getNavigation();
if (navigation != null)
navigation.attachNavigationDrawer(this, mToolbar);
// Styling done in attachNavigationDrawer
}
}
Aggregations