Search in sources :

Example 6 with BoxingCropOption

use of com.bilibili.boxing.model.config.BoxingCropOption in project boxing by Bilibili.

the class PickerActivityTest method testCreateMultiImageIntent.

@Test
public void testCreateMultiImageIntent() {
    Intent intent = Boxing.of(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).needGif()).withIntent(mContext, BoxingActivity.class).getIntent();
    assertNotNull(intent);
    BoxingConfig config = BoxingManager.getInstance().getBoxingConfig();
    assertNotNull(config);
    assertEquals(config.getMode(), BoxingConfig.Mode.MULTI_IMG);
    assertEquals(config.isNeedCamera(), false);
    BoxingCropOption cropOptions = config.getCropOption();
    assertNull(cropOptions);
    ArrayList<BaseMedia> list = intent.getParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA);
    assertEquals(list, null);
    Intent intent1 = Boxing.of(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).needGif()).withIntent(mContext, BoxingActivity.class, new ArrayList<ImageMedia>()).getIntent();
    assertNotNull(intent1);
    ArrayList<BaseMedia> list1 = intent.getParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA);
    assertEquals(list1, null);
    ArrayList<ImageMedia> medias = new ArrayList<>();
    medias.add(new ImageMedia("test", "test"));
    Intent intent2 = Boxing.of(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).needGif()).withIntent(mContext, BoxingActivity.class, medias).getIntent();
    assertNotNull(intent2);
    ArrayList<BaseMedia> list2 = intent2.getParcelableArrayListExtra(Boxing.EXTRA_SELECTED_MEDIA);
    assertEquals(list2, medias);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) BoxingCropOption(com.bilibili.boxing.model.config.BoxingCropOption) ImageMedia(com.bilibili.boxing.model.entity.impl.ImageMedia) BoxingActivity(com.bilibili.boxing_impl.ui.BoxingActivity) ArrayList(java.util.ArrayList) Intent(android.content.Intent) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia) Test(org.junit.Test)

Example 7 with BoxingCropOption

use of com.bilibili.boxing.model.config.BoxingCropOption in project boxing by Bilibili.

the class PickerActivityTest method testCreateCustomIntent.

@Test
public void testCreateCustomIntent() {
    BoxingConfig pickerConfig = new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).needCamera();
    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);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) BoxingCropOption(com.bilibili.boxing.model.config.BoxingCropOption) ImageMedia(com.bilibili.boxing.model.entity.impl.ImageMedia) ArrayList(java.util.ArrayList) 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)

Aggregations

BoxingCropOption (com.bilibili.boxing.model.config.BoxingCropOption)7 BoxingConfig (com.bilibili.boxing.model.config.BoxingConfig)6 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)3 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