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