Search in sources :

Example 6 with BoxingConfig

use of com.bilibili.boxing.model.config.BoxingConfig 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 7 with BoxingConfig

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

the class PickerActivityTest method setup.

@Before
public void setup() {
    BoxingManager.getInstance().setBoxingConfig(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG));
    mContext = InstrumentationRegistry.getContext();
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) Before(org.junit.Before)

Example 8 with BoxingConfig

use of com.bilibili.boxing.model.config.BoxingConfig 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 9 with BoxingConfig

use of com.bilibili.boxing.model.config.BoxingConfig 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 10 with BoxingConfig

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

the class MediaItemLayoutTest method testMediaItemLayout.

@Test
public void testMediaItemLayout() {
    MediaItemLayout layout = (MediaItemLayout) LayoutInflater.from(InstrumentationRegistry.getContext()).inflate(R.layout.layout_boxing_recycleview_item, null, false);
    assertNotNull(layout);
    BoxingManager.getInstance().setBoxingConfig(new BoxingConfig(BoxingConfig.Mode.VIDEO).withVideoDurationRes(R.drawable.ic_boxing_broken_image));
    VideoMedia videoMedia = new VideoMedia.Builder("233", "233").build();
    layout.setMedia(videoMedia);
    View videoLayout = layout.findViewById(R.id.video_layout);
    assertNotNull(videoLayout);
    assertTrue(videoLayout.getVisibility() == View.VISIBLE);
    layout.setChecked(true);
    View fontLayout = layout.findViewById(R.id.media_font_layout);
    assertNotNull(fontLayout);
    assertTrue(fontLayout.getVisibility() == View.VISIBLE);
    ImageView checkImg = (ImageView) layout.findViewById(R.id.media_item_check);
    assertNotNull(checkImg);
    assertTrue(checkImg.getVisibility() == View.VISIBLE);
    layout.setChecked(false);
    assertNotNull(fontLayout);
    assertTrue(fontLayout.getVisibility() == View.GONE);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) VideoMedia(com.bilibili.boxing.model.entity.impl.VideoMedia) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) Test(org.junit.Test)

Aggregations

BoxingConfig (com.bilibili.boxing.model.config.BoxingConfig)25 Test (org.junit.Test)14 Intent (android.content.Intent)7 BoxingCropOption (com.bilibili.boxing.model.config.BoxingCropOption)7 BaseMedia (com.bilibili.boxing.model.entity.BaseMedia)6 BoxingActivity (com.bilibili.boxing_impl.ui.BoxingActivity)6 Uri (android.net.Uri)4 PickerPresenter (com.bilibili.boxing.presenter.PickerPresenter)4 ArrayList (java.util.ArrayList)4 ContentResolver (android.content.ContentResolver)3 ImageMedia (com.bilibili.boxing.model.entity.impl.ImageMedia)3 MockContentResolver (android.test.mock.MockContentResolver)2 ImageView (android.widget.ImageView)2 VideoMedia (com.bilibili.boxing.model.entity.impl.VideoMedia)2 List (java.util.List)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 PrepareOnlyThisForTest (org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)2 BottomSheetBehavior (android.support.design.widget.BottomSheetBehavior)1 FragmentManager (android.support.v4.app.FragmentManager)1 View (android.view.View)1