use of com.bilibili.boxing.model.entity.impl.ImageMedia in project boxing by Bilibili.
the class PickerModuleTest method testImageMedia.
@Test
public void testImageMedia() {
ImageMedia imageMedia = new ImageMedia.Builder("233", "233").build();
imageMedia.setPath("/");
imageMedia.getThumbnailPath();
String compressPath = imageMedia.getThumbnailPath();
assertEquals(compressPath, "/");
imageMedia.setCompressPath("111");
String compressPath1 = imageMedia.getThumbnailPath();
assertEquals(compressPath1, "/");
imageMedia = new ImageMedia.Builder("233", "233").setThumbnailPath("999").build();
String compressPath3 = imageMedia.getThumbnailPath();
assertEquals(compressPath3, "233");
assertEquals(imageMedia.getMimeType(), "image/jpeg");
imageMedia.setImageType(ImageMedia.IMAGE_TYPE.GIF);
assertEquals(imageMedia.getMimeType(), "image/gif");
}
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/boxing-impl/src/main/res/drawable-hdpi/ic_boxing_broken_image.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 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 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 BoxingMediaAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof CameraViewHolder) {
CameraViewHolder viewHolder = (CameraViewHolder) holder;
viewHolder.mCameraLayout.setOnClickListener(mOnCameraClickListener);
viewHolder.mCameraImg.setImageResource(BoxingResHelper.getCameraRes());
} else {
int pos = position - mOffset;
final BaseMedia media = mMedias.get(pos);
final ImageViewHolder vh = (ImageViewHolder) holder;
vh.mItemLayout.setImageRes(mDefaultRes);
vh.mItemLayout.setTag(media);
vh.mItemLayout.setOnClickListener(mOnMediaClickListener);
vh.mItemLayout.setTag(R.id.media_item_check, pos);
vh.mItemLayout.setMedia(media);
vh.mItemChecked.setVisibility(mMultiImageMode ? View.VISIBLE : View.GONE);
if (mMultiImageMode && media instanceof ImageMedia) {
vh.mItemLayout.setChecked(((ImageMedia) media).isSelected());
vh.mItemChecked.setTag(R.id.media_layout, vh.mItemLayout);
vh.mItemChecked.setTag(media);
vh.mItemChecked.setOnClickListener(mOnCheckListener);
}
}
}
Aggregations