Search in sources :

Example 11 with BaseMedia

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);
}
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)

Example 12 with BaseMedia

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));
    }
}
Also used : BoxingBottomSheetFragment(com.bilibili.boxing_impl.ui.BoxingBottomSheetFragment) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) Boxing(com.bilibili.boxing.Boxing) BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) Intent(android.content.Intent) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia) PickerPresenter(com.bilibili.boxing.presenter.PickerPresenter)

Example 13 with BaseMedia

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);
}
Also used : ImageMedia(com.bilibili.boxing.model.entity.impl.ImageMedia) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia) Test(org.junit.Test)

Aggregations

BaseMedia (com.bilibili.boxing.model.entity.BaseMedia)13 Intent (android.content.Intent)8 ImageMedia (com.bilibili.boxing.model.entity.impl.ImageMedia)7 Test (org.junit.Test)7 BoxingConfig (com.bilibili.boxing.model.config.BoxingConfig)6 BoxingCropOption (com.bilibili.boxing.model.config.BoxingCropOption)5 BoxingActivity (com.bilibili.boxing_impl.ui.BoxingActivity)5 ArrayList (java.util.ArrayList)4 Uri (android.net.Uri)3 BottomSheetBehavior (android.support.design.widget.BottomSheetBehavior)1 Boxing (com.bilibili.boxing.Boxing)1 PickerPresenter (com.bilibili.boxing.presenter.PickerPresenter)1 BoxingBottomSheetFragment (com.bilibili.boxing_impl.ui.BoxingBottomSheetFragment)1 HashMap (java.util.HashMap)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 PrepareOnlyThisForTest (org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)1