use of org.edx.mobile.model.api.VideoResponseModel 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;
}
Aggregations