Search in sources :

Example 1 with BoxingCropOption

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);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) BoxingCropOption(com.bilibili.boxing.model.config.BoxingCropOption) BoxingActivity(com.bilibili.boxing_impl.ui.BoxingActivity) Intent(android.content.Intent) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia) Test(org.junit.Test)

Example 2 with BoxingCropOption

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);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) BoxingCropOption(com.bilibili.boxing.model.config.BoxingCropOption) BoxingActivity(com.bilibili.boxing_impl.ui.BoxingActivity) Intent(android.content.Intent) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia) Test(org.junit.Test)

Example 3 with BoxingCropOption

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);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) BoxingCropOption(com.bilibili.boxing.model.config.BoxingCropOption) BoxingActivity(com.bilibili.boxing_impl.ui.BoxingActivity) Intent(android.content.Intent) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia) Uri(android.net.Uri) Test(org.junit.Test)

Example 4 with BoxingCropOption

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;
    }
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) BoxingCropOption(com.bilibili.boxing.model.config.BoxingCropOption) BoxingActivity(com.bilibili.boxing_impl.ui.BoxingActivity) AbsBoxingActivity(com.bilibili.boxing.AbsBoxingActivity) BoxingBottomSheetActivity(com.bilibili.boxing_impl.ui.BoxingBottomSheetActivity) Uri(android.net.Uri)

Example 5 with BoxingCropOption

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);
}
Also used : BoxingCropOption(com.bilibili.boxing.model.config.BoxingCropOption)

Aggregations

BoxingCropOption (com.bilibili.boxing.model.config.BoxingCropOption)8 BoxingConfig (com.bilibili.boxing.model.config.BoxingConfig)7 BoxingActivity (com.bilibili.boxing_impl.ui.BoxingActivity)6 Intent (android.content.Intent)5 BaseMedia (com.bilibili.boxing.model.entity.BaseMedia)5 Test (org.junit.Test)5 Uri (android.net.Uri)4 ImageMedia (com.bilibili.boxing.model.entity.impl.ImageMedia)2 ArrayList (java.util.ArrayList)2 AbsBoxingActivity (com.bilibili.boxing.AbsBoxingActivity)1 BoxingBottomSheetActivity (com.bilibili.boxing_impl.ui.BoxingBottomSheetActivity)1