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;
}
Aggregations