Search in sources :

Example 1 with BlockPath

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

the class NewCourseOutlineFragment method isOnCourseOutline.

protected boolean isOnCourseOutline() {
    if (courseComponentId == null)
        return true;
    final CourseComponent outlineComp = courseManager.getComponentByIdFromAppLevelCache(courseData.getCourse().getId(), courseComponentId);
    final BlockPath outlinePath = outlineComp.getPath();
    final int outlinePathSize = outlinePath.getPath().size();
    return outlinePathSize <= 1;
}
Also used : BlockPath(org.edx.mobile.model.course.BlockPath) CourseComponent(org.edx.mobile.model.course.CourseComponent)

Example 2 with BlockPath

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

the class NewCourseOutlineFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch(requestCode) {
        // the activity stack to point to it.
        case REQUEST_SHOW_COURSE_UNIT_DETAIL:
            {
                switch(resultCode) {
                    case Activity.RESULT_OK:
                        {
                            final CourseComponent outlineComp = courseManager.getComponentByIdFromAppLevelCache(courseData.getCourse().getId(), courseComponentId);
                            final String leafCompId = (String) data.getSerializableExtra(Router.EXTRA_COURSE_COMPONENT_ID);
                            final CourseComponent leafComp = courseManager.getComponentByIdFromAppLevelCache(courseData.getCourse().getId(), leafCompId);
                            final BlockPath outlinePath = outlineComp.getPath();
                            final BlockPath leafPath = leafComp.getPath();
                            final int outlinePathSize = outlinePath.getPath().size();
                            if (!outlineComp.equals(leafPath.get(outlinePathSize - 1))) {
                                getActivity().setResult(Activity.RESULT_OK, data);
                                getActivity().finish();
                            } else {
                                final int leafPathSize = leafPath.getPath().size();
                                if (outlinePathSize == leafPathSize - 2) {
                                    updateRowSelection(leafCompId);
                                } else {
                                    for (int i = outlinePathSize + 1; i < leafPathSize - 1; i += 2) {
                                        final CourseComponent nextComp = leafPath.get(i);
                                        environment.getRouter().showCourseContainerOutline(NewCourseOutlineFragment.this, REQUEST_SHOW_COURSE_UNIT_DETAIL, courseData, nextComp.getId(), leafCompId, isVideoMode);
                                    }
                                }
                            }
                        }
                }
                break;
            }
    }
}
Also used : BlockPath(org.edx.mobile.model.course.BlockPath) CourseComponent(org.edx.mobile.model.course.CourseComponent)

Example 3 with BlockPath

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

the class CourseBaseActivity method isOnCourseOutline.

protected boolean isOnCourseOutline() {
    if (courseComponentId == null)
        return true;
    CourseComponent outlineComp = courseManager.getComponentById(courseData.getCourse().getId(), courseComponentId);
    BlockPath outlinePath = outlineComp.getPath();
    int outlinePathSize = outlinePath.getPath().size();
    return outlinePathSize <= 1;
}
Also used : BlockPath(org.edx.mobile.model.course.BlockPath) CourseComponent(org.edx.mobile.model.course.CourseComponent)

Example 4 with BlockPath

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

the class NewCourseOutlineAdapter method getRowViewForContainer.

private void getRowViewForContainer(ViewHolder holder, final SectionRow row) {
    final CourseComponent component = row.component;
    String courseId = component.getCourseId();
    BlockPath path = component.getPath();
    // FIXME - we should add a new column in database - pathinfo.
    // then do the string match to get the record
    String chapterId = path.get(1) == null ? "" : path.get(1).getDisplayName();
    String sequentialId = path.get(2) == null ? "" : path.get(2).getDisplayName();
    holder.rowTitle.setText(component.getDisplayName());
    holder.numOfVideoAndDownloadArea.setVisibility(View.VISIBLE);
    if (component.isGraded()) {
        holder.bulkDownload.setVisibility(View.INVISIBLE);
        holder.rowSubtitlePanel.setVisibility(View.VISIBLE);
        holder.rowSubtitleIcon.setVisibility(View.VISIBLE);
        holder.rowSubtitle.setVisibility(View.VISIBLE);
        holder.rowSubtitle.setText(component.getFormat());
        holder.rowSubtitle.setTypeface(holder.rowSubtitle.getTypeface(), Typeface.BOLD);
        holder.rowSubtitle.setTextColor(ContextCompat.getColor(context, R.color.edx_brand_gray_dark));
        if (!TextUtils.isEmpty(component.getDueDate())) {
            try {
                holder.rowSubtitleDueDate.setText(getFormattedDueDate(component.getDueDate()));
                holder.rowSubtitleDueDate.setVisibility(View.VISIBLE);
            } catch (IllegalArgumentException e) {
                logger.error(e);
            }
        }
    }
    final int totalDownloadableVideos = component.getDownloadableVideosCount();
    // support video download for video type excluding the ones only viewable on web
    if (totalDownloadableVideos == 0) {
        holder.numOfVideoAndDownloadArea.setVisibility(View.GONE);
    } else {
        holder.bulkDownload.setVisibility(View.VISIBLE);
        holder.noOfVideos.setVisibility(View.VISIBLE);
        holder.noOfVideos.setText("" + totalDownloadableVideos);
        Integer downloadedCount = dbStore.getDownloadedVideosCountForSection(courseId, chapterId, sequentialId, null);
        if (downloadedCount == totalDownloadableVideos) {
            holder.noOfVideos.setVisibility(View.VISIBLE);
            setRowStateOnDownload(holder, DownloadEntry.DownloadedState.DOWNLOADED, null);
        } else if (dbStore.getDownloadingVideosCountForSection(courseId, chapterId, sequentialId, null) + downloadedCount == totalDownloadableVideos) {
            holder.noOfVideos.setVisibility(View.GONE);
            setRowStateOnDownload(holder, DownloadEntry.DownloadedState.DOWNLOADING, new View.OnClickListener() {

                @Override
                public void onClick(View downloadView) {
                    downloadListener.viewDownloadsStatus();
                }
            });
        } else {
            holder.noOfVideos.setVisibility(View.VISIBLE);
            setRowStateOnDownload(holder, DownloadEntry.DownloadedState.ONLINE, new View.OnClickListener() {

                @Override
                public void onClick(View downloadView) {
                    final List<VideoBlockModel> downloadableVideos = (List<VideoBlockModel>) (List) component.getVideos(true);
                    for (VideoBlockModel videoBlockModel : downloadableVideos) {
                        /**
                         * Assign preferred downloadable url to {@link VideoBlockModel#downloadUrl},
                         * to use this url to download. After downloading only downloaded
                         * video path will be used for streaming.
                         */
                        videoBlockModel.setDownloadUrl(VideoUtil.getPreferredVideoUrlForDownloading(videoBlockModel.getData()));
                    }
                    downloadListener.download(downloadableVideos);
                }
            });
        }
    }
}
Also used : BlockPath(org.edx.mobile.model.course.BlockPath) List(java.util.List) ArrayList(java.util.ArrayList) VideoBlockModel(org.edx.mobile.model.course.VideoBlockModel) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) IconImageView(com.joanzapata.iconify.widget.IconImageView) CourseComponent(org.edx.mobile.model.course.CourseComponent)

Example 5 with BlockPath

use of org.edx.mobile.model.course.BlockPath 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 VideoData.
 *
 * @param vrm
 * @return
 */
public static VideoModel getModel(VideoData vrm, VideoBlockModel block) {
    DownloadEntry e = new DownloadEntry();
    // FIXME - current database schema is not suitable for arbitary level of course structure tree
    // solution - store the navigation path info in into one column field in the database,
    // rather than individual column fields.
    BlockPath path = block.getPath();
    e.chapter = path.get(1) == null ? "" : path.get(1).getDisplayName();
    e.section = path.get(2) == null ? "" : path.get(2).getDisplayName();
    IBlock root = block.getRoot();
    e.eid = root.getCourseId();
    e.duration = vrm.duration;
    final VideoInfo preferredVideoInfo = vrm.encodedVideos.getPreferredVideoInfo();
    e.size = preferredVideoInfo.fileSize;
    e.title = block.getDisplayName();
    e.url = preferredVideoInfo.url;
    e.url_high_quality = getVideoNetworkUrlOrNull(vrm.encodedVideos.mobileHigh);
    e.url_low_quality = getVideoNetworkUrlOrNull(vrm.encodedVideos.mobileLow);
    e.url_youtube = getVideoNetworkUrlOrNull(vrm.encodedVideos.youtube);
    e.videoId = block.getId();
    e.transcript = vrm.transcripts;
    e.lmsUrl = block.getBlockUrl();
    e.isVideoForWebOnly = vrm.onlyOnWeb;
    return e;
}
Also used : BlockPath(org.edx.mobile.model.course.BlockPath) IBlock(org.edx.mobile.model.course.IBlock) VideoInfo(org.edx.mobile.model.course.VideoInfo) DownloadEntry(org.edx.mobile.model.db.DownloadEntry)

Aggregations

BlockPath (org.edx.mobile.model.course.BlockPath)9 CourseComponent (org.edx.mobile.model.course.CourseComponent)8 ArrayList (java.util.ArrayList)3 IBlock (org.edx.mobile.model.course.IBlock)3 View (android.view.View)2 TextView (android.widget.TextView)2 IconImageView (com.joanzapata.iconify.widget.IconImageView)2 List (java.util.List)2 EnrolledCoursesResponse (org.edx.mobile.model.api.EnrolledCoursesResponse)2 CourseStructureV1Model (org.edx.mobile.model.course.CourseStructureV1Model)2 VideoBlockModel (org.edx.mobile.model.course.VideoBlockModel)2 Test (org.junit.Test)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Fragment (android.support.v4.app.Fragment)1 ImageView (android.widget.ImageView)1 Filter (org.edx.mobile.model.Filter)1 BlockType (org.edx.mobile.model.course.BlockType)1 HasDownloadEntry (org.edx.mobile.model.course.HasDownloadEntry)1 VideoInfo (org.edx.mobile.model.course.VideoInfo)1