Search in sources :

Example 11 with CourseComponent

use of org.edx.mobile.model.course.CourseComponent in project edx-app-android by edx.

the class CourseOutlineAdapter method getRowViewForLeaf.

private void getRowViewForLeaf(ViewHolder viewHolder, final SectionRow row) {
    final CourseComponent unit = row.component;
    viewHolder.rowType.setVisibility(View.VISIBLE);
    viewHolder.rowSubtitleIcon.setVisibility(View.GONE);
    viewHolder.rowSubtitleDueDate.setVisibility(View.GONE);
    viewHolder.rowSubtitle.setVisibility(View.GONE);
    viewHolder.rowSubtitlePanel.setVisibility(View.GONE);
    viewHolder.bulkDownload.setVisibility(View.INVISIBLE);
    viewHolder.rowTitle.setText(unit.getDisplayName());
    if (row.component instanceof VideoBlockModel) {
        final VideoBlockModel videoBlockModel = (VideoBlockModel) row.component;
        final DownloadEntry videoData = videoBlockModel.getDownloadEntry(storage);
        if (null != videoData) {
            updateUIForVideo(viewHolder, videoData, videoBlockModel);
            return;
        }
    }
    if (config.isDiscussionsEnabled() && row.component instanceof DiscussionBlockModel) {
        viewHolder.rowType.setIcon(FontAwesomeIcons.fa_comments_o);
        checkAccessStatus(viewHolder, unit);
    } else if (!unit.isMultiDevice()) {
        // If we reach here & the type is VIDEO, it means the video is webOnly
        viewHolder.bulkDownload.setVisibility(View.INVISIBLE);
        viewHolder.rowType.setIcon(FontAwesomeIcons.fa_laptop);
        viewHolder.rowType.setIconColorResource(R.color.edx_brand_gray_accent);
    } else {
        viewHolder.bulkDownload.setVisibility(View.INVISIBLE);
        if (unit.getType() == BlockType.PROBLEM) {
            viewHolder.rowType.setIcon(FontAwesomeIcons.fa_list);
        } else {
            viewHolder.rowType.setIcon(FontAwesomeIcons.fa_file_o);
        }
        checkAccessStatus(viewHolder, unit);
    }
}
Also used : VideoBlockModel(org.edx.mobile.model.course.VideoBlockModel) DiscussionBlockModel(org.edx.mobile.model.course.DiscussionBlockModel) CourseComponent(org.edx.mobile.model.course.CourseComponent) HasDownloadEntry(org.edx.mobile.model.course.HasDownloadEntry) DownloadEntry(org.edx.mobile.model.db.DownloadEntry)

Example 12 with CourseComponent

use of org.edx.mobile.model.course.CourseComponent in project edx-app-android by edx.

the class CourseOutlineAdapter method setData.

/**
 * component can be null.
 *
 * @IComponent component should be ICourse
 */
public void setData(CourseComponent component) {
    if (component != null && !component.isContainer())
        // 
        return;
    this.rootComponent = component;
    mData.clear();
    if (rootComponent != null) {
        List<IBlock> children = rootComponent.getChildren();
        for (IBlock block : children) {
            CourseComponent comp = (CourseComponent) block;
            if (isVideoMode && comp.getVideos().size() == 0)
                continue;
            if (comp.isContainer()) {
                SectionRow header = new SectionRow(SectionRow.SECTION, comp);
                mData.add(header);
                for (IBlock childBlock : comp.getChildren()) {
                    CourseComponent child = (CourseComponent) childBlock;
                    if (isVideoMode && child.getVideos().size() == 0)
                        continue;
                    SectionRow row = new SectionRow(SectionRow.ITEM, false, child);
                    mData.add(row);
                }
            } else {
                SectionRow row = new SectionRow(SectionRow.ITEM, true, comp);
                mData.add(row);
            }
        }
    }
    notifyDataSetChanged();
}
Also used : IBlock(org.edx.mobile.model.course.IBlock) CourseComponent(org.edx.mobile.model.course.CourseComponent)

Example 13 with CourseComponent

use of org.edx.mobile.model.course.CourseComponent in project edx-app-android by edx.

the class CourseOutlineAdapter method getRowView.

public View getRowView(int position, View convertView) {
    final SectionRow row = this.getItem(position);
    final SectionRow nextRow = this.getItem(position + 1);
    final CourseComponent component = row.component;
    final ViewHolder viewHolder = (ViewHolder) convertView.getTag();
    if (nextRow == null) {
        viewHolder.halfSeparator.setVisibility(View.GONE);
        viewHolder.wholeSeparator.setVisibility(View.VISIBLE);
    } else {
        viewHolder.wholeSeparator.setVisibility(View.GONE);
        boolean isLastChildInBlock = !row.component.getParent().getId().equals(nextRow.component.getParent().getId());
        if (isLastChildInBlock) {
            viewHolder.halfSeparator.setVisibility(View.GONE);
        } else {
            viewHolder.halfSeparator.setVisibility(View.VISIBLE);
        }
    }
    viewHolder.rowType.setVisibility(View.GONE);
    viewHolder.rowSubtitleIcon.setVisibility(View.GONE);
    viewHolder.rowSubtitle.setVisibility(View.GONE);
    viewHolder.rowSubtitleDueDate.setVisibility(View.GONE);
    viewHolder.rowSubtitlePanel.setVisibility(View.GONE);
    viewHolder.numOfVideoAndDownloadArea.setVisibility(View.GONE);
    if (component.isContainer()) {
        getRowViewForContainer(viewHolder, row);
    } else {
        getRowViewForLeaf(viewHolder, row);
    }
    return convertView;
}
Also used : CourseComponent(org.edx.mobile.model.course.CourseComponent)

Example 14 with CourseComponent

use of org.edx.mobile.model.course.CourseComponent 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)

Example 15 with CourseComponent

use of org.edx.mobile.model.course.CourseComponent in project edx-app-android by edx.

the class NewCourseOutlineAdapter method setData.

/**
 * Set the data for adapter to populate the listview.
 *
 * @param component The CourseComponent to extract data from.
 */
public void setData(@Nullable CourseComponent component) {
    if (component != null && !component.isContainer())
        // 
        return;
    this.rootComponent = component;
    clearCourseOutlineData();
    if (rootComponent != null) {
        List<IBlock> children = rootComponent.getChildren();
        for (IBlock block : children) {
            CourseComponent comp = (CourseComponent) block;
            if (isVideoMode && comp.getVideos().size() == 0)
                continue;
            if (comp.isContainer()) {
                SectionRow header = new SectionRow(SectionRow.SECTION, comp);
                adapterData.add(header);
                for (IBlock childBlock : comp.getChildren()) {
                    CourseComponent child = (CourseComponent) childBlock;
                    if (isVideoMode && child.getVideos().size() == 0)
                        continue;
                    SectionRow row = new SectionRow(SectionRow.ITEM, false, child);
                    adapterData.add(row);
                }
            } else {
                SectionRow row = new SectionRow(SectionRow.ITEM, true, comp);
                adapterData.add(row);
            }
        }
        if (isVideoMode && rootComponent.getDownloadableVideosCount() == 0) {
            // Remove bulk video download row if the course has NO downloadable videos
            if (adapterData.size() > 0 && adapterData.get(0).type == SectionRow.BULK_DOWNLOAD) {
                adapterData.remove(0);
            }
        }
    }
    notifyDataSetChanged();
}
Also used : IBlock(org.edx.mobile.model.course.IBlock) CourseComponent(org.edx.mobile.model.course.CourseComponent)

Aggregations

CourseComponent (org.edx.mobile.model.course.CourseComponent)43 VideoBlockModel (org.edx.mobile.model.course.VideoBlockModel)10 ArrayList (java.util.ArrayList)9 EnrolledCoursesResponse (org.edx.mobile.model.api.EnrolledCoursesResponse)9 Bundle (android.os.Bundle)8 BlockPath (org.edx.mobile.model.course.BlockPath)8 CourseStructureV1Model (org.edx.mobile.model.course.CourseStructureV1Model)8 Test (org.junit.Test)7 View (android.view.View)6 IBlock (org.edx.mobile.model.course.IBlock)6 Intent (android.content.Intent)5 NonNull (android.support.annotation.NonNull)5 DiscussionBlockModel (org.edx.mobile.model.course.DiscussionBlockModel)5 HtmlBlockModel (org.edx.mobile.model.course.HtmlBlockModel)5 TextView (android.widget.TextView)4 IconImageView (com.joanzapata.iconify.widget.IconImageView)4 LinkedHashMap (java.util.LinkedHashMap)4 Fragment (android.support.v4.app.Fragment)3 HashMap (java.util.HashMap)3 CourseContentNotValidException (org.edx.mobile.exception.CourseContentNotValidException)3