use of org.edx.mobile.model.course.CourseComponent in project edx-app-android by edx.
the class NewCourseOutlineFragment method isOnCourseOutline.
protected boolean isOnCourseOutline() {
if (courseComponentId == null)
return true;
final CourseComponent outlineComp = courseManager.getComponentByIdFromAppLevelCache(courseData.getCourse().getId(), courseComponentId);
final BlockPath outlinePath = outlineComp.getPath();
final int outlinePathSize = outlinePath.getPath().size();
return outlinePathSize <= 1;
}
use of org.edx.mobile.model.course.CourseComponent in project edx-app-android by edx.
the class NewCourseOutlineFragment method fetchCourseComponent.
private void fetchCourseComponent() {
final String courseId = courseData.getCourse().getId();
if (courseComponentId != null) {
final CourseComponent courseComponent = courseManager.getComponentByIdFromAppLevelCache(courseId, courseComponentId);
if (courseComponent != null) {
// Course data exist in app session cache
loadData(courseComponent);
return;
}
}
// Check if course data is available in app session cache
final CourseComponent courseComponent = courseManager.getCourseDataFromAppLevelCache(courseId);
if (courseComponent != null) {
// Course data exist in app session cache
loadData(courseComponent);
return;
}
// Check if course data is available in persistable cache
loadingIndicator.setVisibility(View.VISIBLE);
// Prepare the loader. Either re-connect with an existing one or start a new one.
getLoaderManager().initLoader(0, null, this);
}
use of org.edx.mobile.model.course.CourseComponent in project edx-app-android by edx.
the class NewCourseOutlineFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
// the activity stack to point to it.
case REQUEST_SHOW_COURSE_UNIT_DETAIL:
{
switch(resultCode) {
case Activity.RESULT_OK:
{
final CourseComponent outlineComp = courseManager.getComponentByIdFromAppLevelCache(courseData.getCourse().getId(), courseComponentId);
final String leafCompId = (String) data.getSerializableExtra(Router.EXTRA_COURSE_COMPONENT_ID);
final CourseComponent leafComp = courseManager.getComponentByIdFromAppLevelCache(courseData.getCourse().getId(), leafCompId);
final BlockPath outlinePath = outlineComp.getPath();
final BlockPath leafPath = leafComp.getPath();
final int outlinePathSize = outlinePath.getPath().size();
if (!outlineComp.equals(leafPath.get(outlinePathSize - 1))) {
getActivity().setResult(Activity.RESULT_OK, data);
getActivity().finish();
} else {
final int leafPathSize = leafPath.getPath().size();
if (outlinePathSize == leafPathSize - 2) {
updateRowSelection(leafCompId);
} else {
for (int i = outlinePathSize + 1; i < leafPathSize - 1; i += 2) {
final CourseComponent nextComp = leafPath.get(i);
environment.getRouter().showCourseContainerOutline(NewCourseOutlineFragment.this, REQUEST_SHOW_COURSE_UNIT_DETAIL, courseData, nextComp.getId(), leafCompId, isVideoMode);
}
}
}
}
}
break;
}
}
}
use of org.edx.mobile.model.course.CourseComponent in project edx-app-android by edx.
the class NewCourseOutlineFragment method validateCourseComponent.
/**
* Validates the course component that we should load on screen i.e. based on
* {@link #isOnCourseOutline} validates that the CourseComponent we are about to load on screen
* has the same ID as {@link #courseComponentId}.
*
* @param courseComponent The course component to validate.
* @return Validated course component having the same ID as {@link #courseComponentId}.
*/
@NonNull
private CourseComponent validateCourseComponent(@NonNull CourseComponent courseComponent) {
if (!isOnCourseOutline) {
final CourseComponent cached = courseManager.getComponentByIdFromAppLevelCache(courseData.getCourse().getId(), courseComponentId);
courseComponent = cached != null ? cached : courseComponent;
}
return courseComponent;
}
use of org.edx.mobile.model.course.CourseComponent in project edx-app-android by edx.
the class CourseBaseActivity method isOnCourseOutline.
protected boolean isOnCourseOutline() {
if (courseComponentId == null)
return true;
CourseComponent outlineComp = courseManager.getComponentById(courseData.getCourse().getId(), courseComponentId);
BlockPath outlinePath = outlineComp.getPath();
int outlinePathSize = outlinePath.getPath().size();
return outlinePathSize <= 1;
}
Aggregations