Search in sources :

Example 21 with DownloadEntry

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;
}
Also used : DownloadEntry(org.edx.mobile.model.db.DownloadEntry)

Example 22 with DownloadEntry

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;
}
Also used : DownloadEntry(org.edx.mobile.model.db.DownloadEntry)

Example 23 with DownloadEntry

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);
    }
}
Also used : DownloadEntry(org.edx.mobile.model.db.DownloadEntry)

Example 24 with DownloadEntry

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);
    }
}
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 25 with DownloadEntry

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

Aggregations

DownloadEntry (org.edx.mobile.model.db.DownloadEntry)50 Test (org.junit.Test)36 VideoModel (org.edx.mobile.model.VideoModel)10 List (java.util.List)6 HasDownloadEntry (org.edx.mobile.model.course.HasDownloadEntry)4 CourseComponent (org.edx.mobile.model.course.CourseComponent)2 DiscussionBlockModel (org.edx.mobile.model.course.DiscussionBlockModel)2 VideoBlockModel (org.edx.mobile.model.course.VideoBlockModel)2 WatchedState (org.edx.mobile.model.db.DownloadEntry.WatchedState)2 BulkVideosDownloadCancelledEvent (org.edx.mobile.module.storage.BulkVideosDownloadCancelledEvent)2 MenuItem (android.view.MenuItem)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 BaseFragmentActivity (org.edx.mobile.base.BaseFragmentActivity)1 BaseVideosDownloadStateActivity (org.edx.mobile.base.BaseVideosDownloadStateActivity)1 BlockPath (org.edx.mobile.model.course.BlockPath)1 IBlock (org.edx.mobile.model.course.IBlock)1 VideoInfo (org.edx.mobile.model.course.VideoInfo)1 DownloadedState (org.edx.mobile.model.db.DownloadEntry.DownloadedState)1