Search in sources :

Example 6 with SectionEntry

use of org.edx.mobile.model.api.SectionEntry in project edx-app-android by edx.

the class CourseAPI method getVideoById.

@Nullable
public VideoResponseModel getVideoById(@NonNull final String courseId, @NonNull final String videoId) throws Exception {
    CourseComponent course = this.getCourseStructureFromCache(courseId);
    if (course == null) {
        return getVideoById(course, videoId);
    }
    Map<String, SectionEntry> map = getCourseHierarchy(courseId);
    // iterate chapters
    for (Map.Entry<String, SectionEntry> chapterentry : map.entrySet()) {
        // iterate lectures
        for (Map.Entry<String, ArrayList<VideoResponseModel>> entry : chapterentry.getValue().sections.entrySet()) {
            // iterate videos
            for (VideoResponseModel v : entry.getValue()) {
                // identify the video
                if (videoId.equals(v.getSummary().getId())) {
                    return v;
                }
            }
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) VideoResponseModel(org.edx.mobile.model.api.VideoResponseModel) SectionEntry(org.edx.mobile.model.api.SectionEntry) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CourseComponent(org.edx.mobile.model.course.CourseComponent) Nullable(android.support.annotation.Nullable)

Aggregations

SectionEntry (org.edx.mobile.model.api.SectionEntry)6 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 VideoResponseModel (org.edx.mobile.model.api.VideoResponseModel)3 CourseComponent (org.edx.mobile.model.course.CourseComponent)3 NonNull (android.support.annotation.NonNull)2 HashMap (java.util.HashMap)2 EnrolledCoursesResponse (org.edx.mobile.model.api.EnrolledCoursesResponse)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 Nullable (android.support.annotation.Nullable)1 Map (java.util.Map)1 SyncLastAccessedSubsectionResponse (org.edx.mobile.model.api.SyncLastAccessedSubsectionResponse)1 IBlock (org.edx.mobile.model.course.IBlock)1