Search in sources :

Example 1 with BaseMedia

use of com.bilibili.boxing.model.entity.BaseMedia in project boxing by Bilibili.

the class PickerPresenterTest method checkSelectedMedia.

@Test
public void checkSelectedMedia() {
    List<BaseMedia> allMedias = new ArrayList<>();
    allMedias.add(new ImageMedia.Builder("1", "test1").setSelected(true).build());
    allMedias.add(new ImageMedia.Builder("2", "test2").setSelected(false).build());
    allMedias.add(new ImageMedia.Builder("3", "test3").build());
    List<BaseMedia> selectedMedias = new ArrayList<>();
    selectedMedias.add(new ImageMedia.Builder("2", "test2").setSelected(true).build());
    mPresenter.checkSelectedMedia(allMedias, selectedMedias);
    ImageMedia imageMedia0 = (ImageMedia) allMedias.get(0);
    ImageMedia imageMedia1 = (ImageMedia) allMedias.get(1);
    ImageMedia imageMedia2 = (ImageMedia) allMedias.get(2);
    Assert.assertTrue(!imageMedia0.isSelected());
    Assert.assertTrue(imageMedia1.isSelected());
    Assert.assertTrue(!imageMedia2.isSelected());
    mPresenter.checkSelectedMedia(null, null);
}
Also used : ImageMedia(com.bilibili.boxing.model.entity.impl.ImageMedia) ArrayList(java.util.ArrayList) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Example 2 with BaseMedia

use of com.bilibili.boxing.model.entity.BaseMedia 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 3 with BaseMedia

use of com.bilibili.boxing.model.entity.BaseMedia 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 4 with BaseMedia

use of com.bilibili.boxing.model.entity.BaseMedia 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 5 with BaseMedia

use of com.bilibili.boxing.model.entity.BaseMedia in project boxing by Bilibili.

the class BoxingMediaAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof CameraViewHolder) {
        CameraViewHolder viewHolder = (CameraViewHolder) holder;
        viewHolder.mCameraLayout.setOnClickListener(mOnCameraClickListener);
        viewHolder.mCameraImg.setImageResource(BoxingResHelper.getCameraRes());
    } else {
        int pos = position - mOffset;
        final BaseMedia media = mMedias.get(pos);
        final ImageViewHolder vh = (ImageViewHolder) holder;
        vh.mItemLayout.setImageRes(mDefaultRes);
        vh.mItemLayout.setTag(media);
        vh.mItemLayout.setOnClickListener(mOnMediaClickListener);
        vh.mItemLayout.setTag(R.id.media_item_check, pos);
        vh.mItemLayout.setMedia(media);
        vh.mItemChecked.setVisibility(mMultiImageMode ? View.VISIBLE : View.GONE);
        if (mMultiImageMode && media instanceof ImageMedia) {
            vh.mItemLayout.setChecked(((ImageMedia) media).isSelected());
            vh.mItemChecked.setTag(R.id.media_layout, vh.mItemLayout);
            vh.mItemChecked.setTag(media);
            vh.mItemChecked.setOnClickListener(mOnCheckListener);
        }
    }
}
Also used : ImageMedia(com.bilibili.boxing.model.entity.impl.ImageMedia) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia)

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