use of com.bilibili.boxing.model.entity.impl.ImageMedia in project boxing by Bilibili.
the class ImageTask method addItem.
private void addItem(final int allCount, final List<ImageMedia> result, Cursor cursor, @NonNull final IMediaTaskCallback<ImageMedia> callback) {
if (cursor != null && cursor.moveToFirst()) {
do {
String picPath = cursor.getString(cursor.getColumnIndex(Images.Media.DATA));
if (callback.needFilter(picPath)) {
BoxingLog.d("path:" + picPath + " has been filter");
} else {
String id = cursor.getString(cursor.getColumnIndex(Images.Media._ID));
String size = cursor.getString(cursor.getColumnIndex(Images.Media.SIZE));
String mimeType = cursor.getString(cursor.getColumnIndex(Images.Media.MIME_TYPE));
int width = 0;
int height = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
width = cursor.getInt(cursor.getColumnIndex(Images.Media.WIDTH));
height = cursor.getInt(cursor.getColumnIndex(Images.Media.HEIGHT));
}
ImageMedia imageItem = new ImageMedia.Builder(id, picPath).setThumbnailPath(mThumbnailMap.get(id)).setSize(size).setMimeType(mimeType).setHeight(height).setWidth(width).build();
if (!result.contains(imageItem)) {
result.add(imageItem);
}
}
} while (!cursor.isLast() && cursor.moveToNext());
postMedias(result, allCount, callback);
} else {
postMedias(result, 0, callback);
}
clear();
}
use of com.bilibili.boxing.model.entity.impl.ImageMedia in project boxing by Bilibili.
the class PickerPresenterTest method checkSelectedMedia.
@Test
public void checkSelectedMedia() {
List<BaseMedia> allMedias = new ArrayList<>();
allMedias.add(new ImageMedia.Builder("1", "test1").setSelected(true).build());
allMedias.add(new ImageMedia.Builder("2", "test2").setSelected(false).build());
allMedias.add(new ImageMedia.Builder("3", "test3").build());
List<BaseMedia> selectedMedias = new ArrayList<>();
selectedMedias.add(new ImageMedia.Builder("2", "test2").setSelected(true).build());
mPresenter.checkSelectedMedia(allMedias, selectedMedias);
ImageMedia imageMedia0 = (ImageMedia) allMedias.get(0);
ImageMedia imageMedia1 = (ImageMedia) allMedias.get(1);
ImageMedia imageMedia2 = (ImageMedia) allMedias.get(2);
Assert.assertTrue(!imageMedia0.isSelected());
Assert.assertTrue(imageMedia1.isSelected());
Assert.assertTrue(!imageMedia2.isSelected());
mPresenter.checkSelectedMedia(null, null);
}
use of com.bilibili.boxing.model.entity.impl.ImageMedia in project boxing by Bilibili.
the class PickerPresenterTest method loadImages.
@Test
public void loadImages() {
Mockito.when(mPickerManager.getBoxingConfig()).thenReturn(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG));
mPresenter.loadMedias(0, "");
Mockito.verify(mPickerManager).loadMedia(any(ContentResolver.class), ArgumentCaptor.forClass(Integer.class).capture(), ArgumentCaptor.forClass(String.class).capture(), mLoadMediaCallback.capture());
List<ImageMedia> imageMedias = new ArrayList<>();
imageMedias.add(new ImageMedia.Builder("1", "test1").build());
imageMedias.add(new ImageMedia.Builder("2", "test2").build());
imageMedias.add(new ImageMedia.Builder("3", "test3").build());
imageMedias.add(new ImageMedia.Builder("4", "test4").build());
mLoadMediaCallback.getValue().postMedia(imageMedias, 4);
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() == 4);
Assert.assertTrue(showVideoCaptor.getValue().get(0).equals(imageMedias.get(0)));
Assert.assertTrue(showVideoCaptor.getValue().get(1).equals(imageMedias.get(1)));
}
use of com.bilibili.boxing.model.entity.impl.ImageMedia in project boxing by Bilibili.
the class PickerUtilTest method testCompressTask.
@Test
public void testCompressTask() {
ImageCompressor illegalCompressor = new ImageCompressor(new File("///"));
ImageMedia media = new ImageMedia("123", "44");
ImageCompressor compressor = new ImageCompressor(new File("src/main/res/"));
ImageMedia media1 = new ImageMedia("1223", "../boxing-impl/src/main/res/drawable-hdpi/ic_camera.png");
media1.setSize("233");
boolean result1 = CompressTask.compress(null, null, 0);
assertTrue(!result1);
result1 = CompressTask.compress(null, media, 0);
assertTrue(!result1);
result1 = CompressTask.compress(illegalCompressor, media, 0);
assertTrue(!result1);
result1 = CompressTask.compress(illegalCompressor, media, 1000);
assertTrue(!result1);
result1 = CompressTask.compress(compressor, media1, 1000);
assertTrue(result1);
}
use of com.bilibili.boxing.model.entity.impl.ImageMedia in project boxing by Bilibili.
the class PickerModuleTest method testBaseMedia.
@Test
public void testBaseMedia() {
BaseMedia media = new ImageMedia("233", "988");
assertTrue(media.getId().equals("233"));
assertTrue(media.getPath().equals("988"));
media.setSize("99");
assertTrue(media.getSize() == 99);
media.setSize("&&");
assertTrue(media.getSize() == 0);
media.setSize("-1");
assertTrue(media.getSize() == 0);
}
Aggregations