Search in sources :

Example 1 with CourseUnitFragment

use of org.edx.mobile.view.CourseUnitFragment in project edx-app-android by edx.

the class CourseUnitPagerAdapter method getItem.

@Override
public Fragment getItem(int pos) {
    CourseComponent unit = getUnit(pos);
    CourseUnitFragment unitFragment;
    // FIXME - for the video, let's ignore studentViewMultiDevice for now
    if (isCourseUnitVideo(unit)) {
        unitFragment = CourseUnitVideoFragment.newInstance((VideoBlockModel) unit, (pos < unitList.size()), (pos > 0));
    } else if (unit instanceof VideoBlockModel && ((VideoBlockModel) unit).getData().encodedVideos.getYoutubeVideoInfo() != null) {
        unitFragment = CourseUnitOnlyOnYoutubeFragment.newInstance(unit);
    } else if (config.isDiscussionsEnabled() && unit instanceof DiscussionBlockModel) {
        unitFragment = CourseUnitDiscussionFragment.newInstance(unit, courseData);
    } else if (!unit.isMultiDevice()) {
        unitFragment = CourseUnitMobileNotSupportedFragment.newInstance(unit);
    } else if (unit.getType() != BlockType.VIDEO && unit.getType() != BlockType.HTML && unit.getType() != BlockType.OTHERS && unit.getType() != BlockType.DISCUSSION && unit.getType() != BlockType.PROBLEM) {
        unitFragment = CourseUnitEmptyFragment.newInstance(unit);
    } else if (unit instanceof HtmlBlockModel) {
        unitFragment = CourseUnitWebViewFragment.newInstance((HtmlBlockModel) unit);
    } else // fallback
    {
        unitFragment = CourseUnitMobileNotSupportedFragment.newInstance(unit);
    }
    unitFragment.setHasComponentCallback(callback);
    return unitFragment;
}
Also used : CourseUnitFragment(org.edx.mobile.view.CourseUnitFragment) HtmlBlockModel(org.edx.mobile.model.course.HtmlBlockModel) VideoBlockModel(org.edx.mobile.model.course.VideoBlockModel) DiscussionBlockModel(org.edx.mobile.model.course.DiscussionBlockModel) CourseComponent(org.edx.mobile.model.course.CourseComponent)

Aggregations

CourseComponent (org.edx.mobile.model.course.CourseComponent)1 DiscussionBlockModel (org.edx.mobile.model.course.DiscussionBlockModel)1 HtmlBlockModel (org.edx.mobile.model.course.HtmlBlockModel)1 VideoBlockModel (org.edx.mobile.model.course.VideoBlockModel)1 CourseUnitFragment (org.edx.mobile.view.CourseUnitFragment)1