use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class DatabaseModelFactory method getModel.
/**
* Returns an object of IVideoModel which has all the fields copied from given VideoResponseModel.
*
* @param vrm
* @return
*/
public static VideoModel getModel(VideoResponseModel vrm) {
DownloadEntry e = new DownloadEntry();
e.chapter = vrm.getChapterName();
e.section = vrm.getSequentialName();
e.eid = vrm.getCourseId();
e.duration = vrm.getSummary().getDuration();
e.size = vrm.getSummary().getSize();
e.title = vrm.getSummary().getDisplayName();
e.url = vrm.getSummary().getVideoUrl();
e.url_high_quality = vrm.getSummary().getHighEncoding();
e.url_low_quality = vrm.getSummary().getLowEncoding();
e.url_youtube = vrm.getSummary().getYoutubeLink();
e.videoId = vrm.getSummary().getId();
e.transcript = vrm.getSummary().getTranscripts();
e.lmsUrl = vrm.getUnitUrl();
e.isVideoForWebOnly = vrm.getSummary().isOnlyOnWeb();
return e;
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class Storage method reloadDownloadEntry.
@Override
public DownloadEntry reloadDownloadEntry(DownloadEntry video) {
try {
DownloadEntry de = (DownloadEntry) db.getVideoEntryByVideoId(video.videoId, null);
if (de != null) {
video.lastPlayedOffset = de.lastPlayedOffset;
video.watched = de.watched;
video.downloaded = de.downloaded;
}
return video;
} catch (Exception ex) {
logger.error(ex);
}
return null;
}
use of org.edx.mobile.model.db.DownloadEntry in project edx-app-android by edx.
the class Storage method markVideoPlaying.
@Override
public void markVideoPlaying(DownloadEntry videoModel, final DataCallback<Integer> watchedStateCallback) {
try {
final DownloadEntry v = videoModel;
if (v != null) {
if (v.watched == DownloadEntry.WatchedState.UNWATCHED) {
videoModel.watched = DownloadEntry.WatchedState.PARTIALLY_WATCHED;
// video entry might not exist in the database, add it
db.addVideoData(videoModel, new DataCallback<Long>() {
@Override
public void onResult(Long result) {
try {
// mark this as partially watches, as playing has started
db.updateVideoWatchedState(v.getVideoId(), DownloadEntry.WatchedState.PARTIALLY_WATCHED, watchedStateCallback);
} catch (Exception ex) {
logger.error(ex);
}
}
@Override
public void onFail(Exception ex) {
logger.error(ex);
}
});
}
}
} catch (Exception ex) {
logger.error(ex);
}
}
use of org.edx.mobile.model.db.DownloadEntry 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.db.DownloadEntry in project edx-app-android by edx.
the class NewCourseOutlineAdapter 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);
}
}
Aggregations