use of com.bilibili.boxing.model.config.BoxingCropOption 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.config.BoxingCropOption 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.config.BoxingCropOption 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.config.BoxingCropOption in project boxing by Bilibili.
the class FirstActivity method onClick.
@Override
public void onClick(View v) {
int id = v.getId();
switch(id) {
case R.id.single_image_btn:
BoxingConfig singleImgConfig = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG).withMediaPlaceHolderRes(R.drawable.ic_boxing_default_image);
Boxing.of(singleImgConfig).withIntent(this, BoxingActivity.class).start(this, COMPRESS_REQUEST_CODE);
break;
case R.id.single_image_btn_crop_btn:
String cachePath = BoxingFileHelper.getCacheDir(this);
if (TextUtils.isEmpty(cachePath)) {
Toast.makeText(getApplicationContext(), R.string.boxing_storage_deny, Toast.LENGTH_SHORT).show();
return;
}
Uri destUri = new Uri.Builder().scheme("file").appendPath(cachePath).appendPath(String.format(Locale.US, "%s.png", System.currentTimeMillis())).build();
BoxingConfig singleCropImgConfig = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG).withCropOption(new BoxingCropOption(destUri)).withMediaPlaceHolderRes(R.drawable.ic_boxing_default_image);
Boxing.of(singleCropImgConfig).withIntent(this, BoxingActivity.class).start(this, REQUEST_CODE);
break;
case R.id.multi_image_btn:
BoxingConfig config = new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).needCamera(R.drawable.ic_boxing_camera_white).needGif();
Boxing.of(config).withIntent(this, BoxingActivity.class).start(this, REQUEST_CODE);
break;
case R.id.video_btn:
BoxingConfig videoConfig = new BoxingConfig(BoxingConfig.Mode.VIDEO).withVideoDurationRes(R.drawable.ic_boxing_play);
Boxing.of(videoConfig).withIntent(this, BoxingActivity.class).start(this, REQUEST_CODE);
break;
case R.id.outside_bs_btn:
BoxingConfig bsConfig = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG);
Boxing.of(bsConfig).withIntent(this, BoxingBottomSheetActivity.class).start(this, REQUEST_CODE);
break;
default:
break;
}
}
use of com.bilibili.boxing.model.config.BoxingCropOption in project boxing by Bilibili.
the class AbsBoxingViewFragment method startCrop.
/**
* to start the crop behavior, call it when {@link #hasCropBehavior()} return true.
*
* @param media the media to be cropped.
* @param requestCode The integer request code originally supplied to
* startActivityForResult(), allowing you to identify who this
* result came from.
*/
@Override
public final void startCrop(@NonNull BaseMedia media, int requestCode) {
BoxingCropOption cropConfig = BoxingManager.getInstance().getBoxingConfig().getCropOption();
BoxingCrop.getInstance().onStartCrop(getActivity(), this, cropConfig, media.getPath(), requestCode);
}
Aggregations