use of com.bilibili.boxing.model.entity.BaseMedia 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.BaseMedia in project boxing by Bilibili.
the class PickerActivityTest method testCreateSingleImageIntent.
@Test
public void testCreateSingleImageIntent() {
Intent intent = Boxing.of(new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG).needCamera(R.drawable.ic_boxing_broken_image)).withIntent(mContext, BoxingActivity.class).getIntent();
assertNotNull(intent);
BoxingConfig config = BoxingManager.getInstance().getBoxingConfig();
assertNotNull(config);
assertEquals(config.getMode(), BoxingConfig.Mode.SINGLE_IMG);
assertEquals(config.isNeedCamera(), true);
BoxingCropOption cropOptions = config.getCropOption();
assertEquals(cropOptions, null);
ArrayList<BaseMedia> list = intent.getParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA);
assertEquals(list, null);
}
use of com.bilibili.boxing.model.entity.BaseMedia in project boxing by Bilibili.
the class PickerActivityTest method testCreateVideoIntent.
@Test
public void testCreateVideoIntent() {
Intent intent = Boxing.of(new BoxingConfig(BoxingConfig.Mode.VIDEO)).withIntent(mContext, BoxingActivity.class).getIntent();
assertNotNull(intent);
BoxingConfig config = BoxingManager.getInstance().getBoxingConfig();
assertNotNull(config);
assertEquals(config.getMode(), BoxingConfig.Mode.VIDEO);
assertEquals(config.isNeedCamera(), false);
BoxingCropOption cropOptions = config.getCropOption();
assertEquals(cropOptions, null);
ArrayList<BaseMedia> list = intent.getParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA);
assertEquals(null, list);
}
use of com.bilibili.boxing.model.entity.BaseMedia in project boxing by Bilibili.
the class PickerActivityTest method testCreateSingleImageWithCropIntent.
@Test
public void testCreateSingleImageWithCropIntent() {
Uri destUri = new Uri.Builder().scheme("file").appendPath("test").appendPath(String.format(Locale.US, "%s.jpg", System.currentTimeMillis())).build();
Intent intent = Boxing.of(new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG).withCropOption(new BoxingCropOption(destUri))).withIntent(mContext, BoxingActivity.class).getIntent();
assertNotNull(intent);
BoxingConfig config = BoxingManager.getInstance().getBoxingConfig();
assertNotNull(config);
assertEquals(config.getMode(), BoxingConfig.Mode.SINGLE_IMG);
assertEquals(config.isNeedCamera(), false);
BoxingCropOption cropOptions = config.getCropOption();
assertNotNull(cropOptions);
ArrayList<BaseMedia> list = intent.getParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA);
assertEquals(list, null);
}
use of com.bilibili.boxing.model.entity.BaseMedia 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