Search in sources :

Example 16 with Group

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;
    }
}
Also used : Group(com.instructure.canvasapi2.models.Group) RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) ArrayList(java.util.ArrayList) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) ArrayList(java.util.ArrayList) List(java.util.List) NonNull(android.support.annotation.NonNull)

Example 17 with Group

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);
    }
}
Also used : Group(com.instructure.canvasapi2.models.Group) RestParams(com.instructure.canvasapi2.builders.RestParams) NonNull(android.support.annotation.NonNull) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) ArrayList(java.util.ArrayList) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Example 18 with Group

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);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 19 with Group

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);
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) Fragment(android.support.v4.app.Fragment)

Example 20 with Group

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
    }
}
Also used : ViewGroup(android.view.ViewGroup) Group(com.instructure.canvasapi2.models.Group) Navigation(com.instructure.interactions.Navigation) CanvasContext(com.instructure.canvasapi2.models.CanvasContext) Course(com.instructure.canvasapi2.models.Course)

Aggregations

Group (com.instructure.canvasapi2.models.Group)17 ArrayList (java.util.ArrayList)12 List (java.util.List)9 Test (org.junit.Test)9 NonNull (android.support.annotation.NonNull)8 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)8 RestParams (com.instructure.canvasapi2.builders.RestParams)8 Course (com.instructure.canvasapi2.models.Course)7 CanvasContext (com.instructure.canvasapi2.models.CanvasContext)6 StatusCallback (com.instructure.canvasapi2.StatusCallback)5 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)5 Bundle (android.os.Bundle)3 View (android.view.View)3 ModuleItem (com.instructure.canvasapi2.models.ModuleItem)3 ApiType (com.instructure.canvasapi2.utils.ApiType)3 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)3 Response (retrofit2.Response)3 RecyclerView (android.support.v7.widget.RecyclerView)2 ViewGroup (android.view.ViewGroup)2 AdapterView (android.widget.AdapterView)2