use of com.bilibili.boxing.model.entity.BaseMedia in project boxing by Bilibili.
the class PickerActivityTest method testCreateCustomIntent.
@Test
public void testCreateCustomIntent() {
BoxingConfig pickerConfig = new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).needCamera(R.drawable.ic_boxing_broken_image);
Uri destUri = new Uri.Builder().scheme("file").appendPath("test").appendPath(String.format(Locale.US, "%s.jpg", System.currentTimeMillis())).build();
BoxingCropOption cropOptions = new BoxingCropOption(destUri);
ArrayList<ImageMedia> medias = new ArrayList<>();
medias.add(new ImageMedia("test", "test"));
medias.add(new ImageMedia("test1", "test1"));
pickerConfig.withCropOption(cropOptions);
Intent intent = Boxing.of(pickerConfig).withIntent(mContext, BoxingActivity.class, medias).getIntent();
assertNotNull(intent);
BoxingConfig config = BoxingManager.getInstance().getBoxingConfig();
assertNotNull(config);
assertEquals(config.getMode(), BoxingConfig.Mode.MULTI_IMG);
assertEquals(config.isNeedCamera(), true);
assertEquals(config.isNeedGif(), false);
BoxingCropOption cropOptionsResult = pickerConfig.getCropOption();
assertEquals(cropOptions, cropOptionsResult);
ArrayList<BaseMedia> list = intent.getParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA);
assertEquals(list, medias);
}
use of com.bilibili.boxing.model.entity.BaseMedia in project boxing by Bilibili.
the class SecondActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
createToolbar();
findViewById(R.id.inside_bs_btn).setOnClickListener(this);
mResultImg = (ImageView) findViewById(R.id.media_result);
mResultImg.setOnClickListener(this);
mInsideBottomSheet = (FrameLayout) findViewById(R.id.content_layout);
BoxingBottomSheetFragment fragment = (BoxingBottomSheetFragment) getSupportFragmentManager().findFragmentByTag(BoxingBottomSheetFragment.TAG);
if (fragment == null) {
fragment = BoxingBottomSheetFragment.newInstance();
getSupportFragmentManager().beginTransaction().add(R.id.content_layout, fragment, BoxingBottomSheetFragment.TAG).commit();
BoxingConfig singleImgConfig = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG).withMediaPlaceHolderRes(R.drawable.ic_boxing_default_image).withAlbumPlaceHolderRes(R.drawable.ic_boxing_default_image);
Boxing.of(singleImgConfig).setupFragment(fragment, new Boxing.OnBoxingFinishListener() {
@Override
public void onBoxingFinish(Intent intent, List<BaseMedia> medias) {
BottomSheetBehavior behavior = BottomSheetBehavior.from(mInsideBottomSheet);
behavior.setState(BottomSheetBehavior.STATE_HIDDEN);
if (medias != null && medias.size() > 0) {
BaseMedia media = mMedia = medias.get(0);
String path = media.getPath();
BoxingMediaLoader.getInstance().displayRaw(mResultImg, path, 1080, 720, null);
}
}
});
} else {
fragment.setPresenter(new PickerPresenter(fragment));
}
}
use of com.bilibili.boxing.model.entity.BaseMedia 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