use of org.edx.mobile.model.course.VideoBlockModel in project edx-app-android by edx.
the class CourseUnitOnlyOnYoutubeFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_course_unit_only_on_youtube, container, false);
((TextView) v.findViewById(R.id.only_youtube_available_message)).setText(R.string.assessment_only_on_youtube);
v.findViewById(R.id.view_on_youtube_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(((VideoBlockModel) unit).getData().encodedVideos.youtube.url));
startActivity(i);
}
});
return v;
}
use of org.edx.mobile.model.course.VideoBlockModel in project edx-app-android by edx.
the class ApiTests method verifyModelParsing.
/**
* Verifies the parsing of course structure json to {@link CourseComponent} model class.
*
* @param component Parsed {@link CourseComponent} model.
*/
private void verifyModelParsing(CourseComponent component) throws IOException, JSONException {
JSONObject jsonObj;
jsonObj = new JSONObject(MockDataUtil.getMockResponse("get_course_structure"));
jsonObj = jsonObj.getJSONObject("blocks");
jsonObj = jsonObj.getJSONObject(component.getId());
assertNotNull(jsonObj);
// Not using the getDisplayName function below, because it returns a placeholder text
// when the display_name field's value is empty.
assertEquals(jsonObj.getString("display_name"), component.getInternalName());
assertEquals(jsonObj.getBoolean("graded"), component.isGraded());
assertEquals(jsonObj.getString("student_view_url"), component.getBlockUrl());
assertEquals(jsonObj.getBoolean("student_view_multi_device"), component.isMultiDevice());
assertEquals(jsonObj.getString("lms_web_url"), component.getWebUrl());
// Type specific validations
Gson gson = new Gson();
switch(component.getType()) {
case VIDEO:
{
JSONObject dataObj = jsonObj.getJSONObject("student_view_data");
// Our current parser checks the existence of these fields to determine the type to convert into
assertTrue(dataObj.has("encoded_videos") || dataObj.has("transcripts"));
String dataRawJson = dataObj.toString();
assertTrue(component instanceof VideoBlockModel);
VideoBlockModel model = (VideoBlockModel) component;
VideoData expected = gson.fromJson(dataRawJson, VideoData.class);
assertEquals(expected, model.getData());
break;
}
case DISCUSSION:
{
JSONObject dataObj = jsonObj.getJSONObject("student_view_data");
// Our current parser checks the existence of these fields to determine the type to convert into
assertTrue(dataObj.has("topic_id"));
String dataRawJson = dataObj.toString();
assertTrue(component instanceof DiscussionBlockModel);
DiscussionBlockModel model = (DiscussionBlockModel) component;
DiscussionData expected = gson.fromJson(dataRawJson, DiscussionData.class);
assertEquals(expected, model.getData());
break;
}
}
}
use of org.edx.mobile.model.course.VideoBlockModel in project edx-app-android by edx.
the class CourseComponentTest method setUp.
@Before
public void setUp() throws Exception {
BlockModel bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.COURSE;
bm.id = UUID.randomUUID().toString();
course = new CourseComponent(bm, null);
course.setCourseId(UUID.randomUUID().toString());
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.CHAPTER;
bm.id = UUID.randomUUID().toString();
chapter1 = new CourseComponent(bm, course);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.SECTION;
bm.id = UUID.randomUUID().toString();
sequential1 = new CourseComponent(bm, chapter1);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.VERTICAL;
bm.id = UUID.randomUUID().toString();
vertical1 = new CourseComponent(bm, sequential1);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.VIDEO;
bm.id = UUID.randomUUID().toString();
unit1 = new VideoBlockModel(bm, vertical1);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.HTML;
bm.id = UUID.randomUUID().toString();
unit2 = new CourseComponent(bm, vertical1);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.CHAPTER;
bm.id = UUID.randomUUID().toString();
chapter2 = new CourseComponent(bm, course);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.SECTION;
bm.id = UUID.randomUUID().toString();
sequential2 = new CourseComponent(bm, chapter2);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.VERTICAL;
bm.id = UUID.randomUUID().toString();
vertical2 = new CourseComponent(bm, sequential2);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.VIDEO;
bm.id = UUID.randomUUID().toString();
unit3 = new VideoBlockModel(bm, vertical2);
bm = Mockito.mock(BlockModel.class);
bm.type = BlockType.HTML;
bm.id = UUID.randomUUID().toString();
unit4 = new CourseComponent(bm, vertical2);
}
use of org.edx.mobile.model.course.VideoBlockModel 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.course.VideoBlockModel in project edx-app-android by edx.
the class CourseUnitPagerAdapter method getItem.
@Override
public Fragment getItem(int pos) {
CourseComponent unit = getUnit(pos);
CourseUnitFragment unitFragment;
// FIXME - for the video, let's ignore studentViewMultiDevice for now
if (isCourseUnitVideo(unit)) {
unitFragment = CourseUnitVideoFragment.newInstance((VideoBlockModel) unit, (pos < unitList.size()), (pos > 0));
} else if (unit instanceof VideoBlockModel && ((VideoBlockModel) unit).getData().encodedVideos.getYoutubeVideoInfo() != null) {
unitFragment = CourseUnitOnlyOnYoutubeFragment.newInstance(unit);
} else if (config.isDiscussionsEnabled() && unit instanceof DiscussionBlockModel) {
unitFragment = CourseUnitDiscussionFragment.newInstance(unit, courseData);
} else if (!unit.isMultiDevice()) {
unitFragment = CourseUnitMobileNotSupportedFragment.newInstance(unit);
} else if (unit.getType() != BlockType.VIDEO && unit.getType() != BlockType.HTML && unit.getType() != BlockType.OTHERS && unit.getType() != BlockType.DISCUSSION && unit.getType() != BlockType.PROBLEM) {
unitFragment = CourseUnitEmptyFragment.newInstance(unit);
} else if (unit instanceof HtmlBlockModel) {
unitFragment = CourseUnitWebViewFragment.newInstance((HtmlBlockModel) unit);
} else // fallback
{
unitFragment = CourseUnitMobileNotSupportedFragment.newInstance(unit);
}
unitFragment.setHasComponentCallback(callback);
return unitFragment;
}
Aggregations