Search in sources :

Example 6 with ModuleObject

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

the class ModuleListRecyclerAdapter method isSequentiallyEnabled.

// endregion
// region Module binder Helpers
private boolean isSequentiallyEnabled(ModuleObject moduleObject, ModuleItem moduleItem) {
    // 0 based) or the previous item is unlocked
    if (mCanvasContext instanceof Course && (((Course) mCanvasContext).isTeacher() || ((Course) mCanvasContext).isTA())) {
        return true;
    }
    if (moduleObject.isSequential_progress() && (moduleObject.getState() != null && (moduleObject.getState().equals(ModuleObject.STATE.unlocked.toString()) || moduleObject.getState().equals(ModuleObject.STATE.started.toString())))) {
        // group is sequential, need to figure out which ones to grey out
        int indexOfCurrentModuleItem = storedIndexOfItem(moduleObject, moduleItem);
        if (indexOfCurrentModuleItem != -1) {
            // getItem performs invalid index checks
            ModuleItem previousModuleItem = getItem(moduleObject, indexOfCurrentModuleItem - 1);
            ModuleItem nextModuleItem = getItem(moduleObject, indexOfCurrentModuleItem + 1);
            if (isComplete(moduleItem)) {
                return true;
            } else if (previousModuleItem == null) {
                // Its the first one in the sequence
                return true;
            } else if (!isComplete(previousModuleItem)) {
                // previous item is not complete
                return false;
            } else if (isComplete(previousModuleItem) && !isComplete(moduleItem)) {
                // previous complete, so show current as next in sequence
                return true;
            } else {
                return false;
            }
        }
    }
    return true;
}
Also used : ModuleItem(com.instructure.canvasapi2.models.ModuleItem) Course(com.instructure.canvasapi2.models.Course)

Aggregations

ModuleItem (com.instructure.canvasapi2.models.ModuleItem)4 ModuleObject (com.instructure.canvasapi2.models.ModuleObject)3 Bundle (android.os.Bundle)2 View (android.view.View)2 Course (com.instructure.canvasapi2.models.Course)2 ArrayList (java.util.ArrayList)2 Drawable (android.graphics.drawable.Drawable)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 CardView (android.support.v7.widget.CardView)1 ModuleListRecyclerAdapter (com.instructure.candroid.adapter.ModuleListRecyclerAdapter)1 ParentFragment (com.instructure.candroid.fragment.ParentFragment)1 ModuleAdapterToFragmentCallback (com.instructure.candroid.interfaces.ModuleAdapterToFragmentCallback)1 ModuleProgressionUtility (com.instructure.candroid.util.ModuleProgressionUtility)1 AssignmentSet (com.instructure.canvasapi2.models.AssignmentSet)1 ModuleContentDetails (com.instructure.canvasapi2.models.ModuleContentDetails)1 ApiType (com.instructure.canvasapi2.utils.ApiType)1 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)1 PageView (com.instructure.canvasapi2.utils.pageview.PageView)1 Navigation (com.instructure.interactions.Navigation)1