use of com.bilibili.boxing.model.entity.impl.VideoMedia in project boxing by Bilibili.
the class PickerModuleTest method testSize.
@Test
public void testSize() {
VideoMedia videoMedia = new VideoMedia.Builder("233", "233").build();
videoMedia.setSize("-1");
String result = videoMedia.getSizeByUnit();
assertEquals(result, "0K");
videoMedia.setSize("0");
result = videoMedia.getSizeByUnit();
assertEquals(result, "0K");
videoMedia.setSize("200");
result = videoMedia.getSizeByUnit();
assertEquals(result, "0.2K");
videoMedia.setSize("1024");
result = videoMedia.getSizeByUnit();
assertEquals(result, "1.0K");
videoMedia.setSize("1048576");
result = videoMedia.getSizeByUnit();
assertEquals(result, "1.0M");
videoMedia.setSize("2048576");
result = videoMedia.getSizeByUnit();
assertEquals(result, "2.0M");
}
use of com.bilibili.boxing.model.entity.impl.VideoMedia in project boxing by Bilibili.
the class PickerPresenterTest method loadVideo.
@Test
public void loadVideo() {
Mockito.when(mPickerManager.getBoxingConfig()).thenReturn(new BoxingConfig(BoxingConfig.Mode.VIDEO));
mPresenter.loadMedias(1, "");
Mockito.verify(mPickerManager).loadMedia(any(ContentResolver.class), ArgumentCaptor.forClass(Integer.class).capture(), ArgumentCaptor.forClass(String.class).capture(), mLoadMediaCallback.capture());
List<VideoMedia> videoMedias = new ArrayList<>();
videoMedias.add(new VideoMedia.Builder("1", "test1").build());
videoMedias.add(new VideoMedia.Builder("2", "test2").build());
videoMedias.add(new VideoMedia.Builder("3", "test3").build());
mLoadMediaCallback.getValue().postMedia(videoMedias, 3);
ArgumentCaptor<List> showVideoCaptor = ArgumentCaptor.forClass(List.class);
Mockito.verify(mView).showMedia(showVideoCaptor.capture(), anyInt());
System.out.print("load video count:" + showVideoCaptor.getValue().size());
Assert.assertTrue(showVideoCaptor.getValue().size() == 3);
Assert.assertTrue(showVideoCaptor.getValue().get(0).equals(videoMedias.get(0)));
Assert.assertTrue(showVideoCaptor.getValue().get(1).equals(videoMedias.get(1)));
}
use of com.bilibili.boxing.model.entity.impl.VideoMedia in project boxing by Bilibili.
the class MediaItemLayoutTest method testMediaItemLayout.
@Test
public void testMediaItemLayout() {
MediaItemLayout layout = (MediaItemLayout) LayoutInflater.from(InstrumentationRegistry.getContext()).inflate(R.layout.layout_boxing_recycleview_item, null, false);
assertNotNull(layout);
BoxingManager.getInstance().setBoxingConfig(new BoxingConfig(BoxingConfig.Mode.VIDEO).withVideoDurationRes(R.drawable.ic_boxing_broken_image));
VideoMedia videoMedia = new VideoMedia.Builder("233", "233").build();
layout.setMedia(videoMedia);
View videoLayout = layout.findViewById(R.id.video_layout);
assertNotNull(videoLayout);
assertTrue(videoLayout.getVisibility() == View.VISIBLE);
layout.setChecked(true);
View fontLayout = layout.findViewById(R.id.media_font_layout);
assertNotNull(fontLayout);
assertTrue(fontLayout.getVisibility() == View.VISIBLE);
ImageView checkImg = (ImageView) layout.findViewById(R.id.media_item_check);
assertNotNull(checkImg);
assertTrue(checkImg.getVisibility() == View.VISIBLE);
layout.setChecked(false);
assertNotNull(fontLayout);
assertTrue(fontLayout.getVisibility() == View.GONE);
}
use of com.bilibili.boxing.model.entity.impl.VideoMedia in project boxing by Bilibili.
the class PickerModuleTest method testVideoMedia.
@Test
public void testVideoMedia() {
VideoMedia videoMedia = new VideoMedia.Builder("233", "233").build();
videoMedia.setDuration("asd");
String result1 = videoMedia.formatTimeWithMin(0);
assertEquals(result1, "00:00");
String result2 = videoMedia.formatTimeWithMin(1000);
assertEquals(result2, "00:01");
String result3 = videoMedia.formatTimeWithMin(1000 * 36);
assertEquals(result3, "00:36");
String result4 = videoMedia.formatTimeWithMin(1000 * 60 * 36 + 45 * 1000);
assertEquals(result4, "36:45");
String result5 = videoMedia.formatTimeWithMin(1000 * 60 * 36 + 45 * 1000 + 8500);
assertEquals(result5, "36:53");
String result6 = videoMedia.formatTimeWithMin((long) (1000 * 60 * 102 + 1000 * 60 * 7.2 + 45 * 1000 + 8500));
assertEquals(result6, "110:05");
String duration = videoMedia.getDuration();
assertEquals(duration, "0:00");
videoMedia.setDuration("2160000");
String duration1 = videoMedia.getDuration();
assertEquals(duration1, "36:00");
}
use of com.bilibili.boxing.model.entity.impl.VideoMedia in project boxing by Bilibili.
the class VideoTask method loadVideos.
private void loadVideos(ContentResolver cr, int page, @NonNull final IMediaTaskCallback<VideoMedia> callback) {
final List<VideoMedia> videoMedias = new ArrayList<>();
final Cursor cursor = cr.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, MEDIA_COL, null, null, MediaStore.Images.Media.DATE_MODIFIED + " desc" + " LIMIT " + page * IMediaTask.PAGE_LIMIT + " , " + IMediaTask.PAGE_LIMIT);
try {
int count = 0;
if (cursor != null && cursor.moveToFirst()) {
count = cursor.getCount();
do {
String data = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATA));
String id = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media._ID));
String title = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.TITLE));
String type = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.MIME_TYPE));
String size = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.SIZE));
String date = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATE_TAKEN));
String duration = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DURATION));
VideoMedia video = new VideoMedia.Builder(id, data).setTitle(title).setDuration(duration).setSize(size).setDataTaken(date).setMimeType(type).build();
videoMedias.add(video);
} while (!cursor.isLast() && cursor.moveToNext());
postMedias(callback, videoMedias, count);
} else {
postMedias(callback, videoMedias, 0);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
}
Aggregations