Search in sources :

Example 6 with BaseMedia

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

the class AbsBoxingViewFragment method onCropActivityResult.

/**
 * successfully get result from crop in {@link #onActivityResult(int, int, Intent)}
 */
public void onCropActivityResult(int requestCode, int resultCode, @NonNull Intent data) {
    Uri output = BoxingCrop.getInstance().onCropFinish(resultCode, data);
    if (output != null) {
        List<BaseMedia> medias = new ArrayList<>(1);
        ImageMedia media = new ImageMedia(String.valueOf(System.currentTimeMillis()), output.getPath());
        medias.add(media);
        onFinish(medias);
    }
}
Also used : ImageMedia(com.bilibili.boxing.model.entity.impl.ImageMedia) ArrayList(java.util.ArrayList) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia) Uri(android.net.Uri)

Example 7 with BaseMedia

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

the class AbsBoxingViewFragment method onFinish.

/**
 * called the job is done.Click the ok button, take a photo from camera, crop a photo.
 * most of the time, you do not have to override.
 *
 * @param medias the list of selection
 */
@Override
public void onFinish(@NonNull List<BaseMedia> medias) {
    Intent intent = new Intent();
    intent.putParcelableArrayListExtra(Boxing.EXTRA_RESULT, (ArrayList<BaseMedia>) medias);
    if (mOnFinishListener != null) {
        mOnFinishListener.onBoxingFinish(intent, medias);
    }
}
Also used : Intent(android.content.Intent) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia)

Example 8 with BaseMedia

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

the class PickerPresenter method checkSelectedMedia.

@Override
public void checkSelectedMedia(List<BaseMedia> allMedias, List<BaseMedia> selectedMedias) {
    if (allMedias == null || allMedias.size() == 0) {
        return;
    }
    Map<String, ImageMedia> map = new HashMap<>(allMedias.size());
    for (BaseMedia allMedia : allMedias) {
        if (!(allMedia instanceof ImageMedia)) {
            return;
        }
        ImageMedia media = (ImageMedia) allMedia;
        media.setSelected(false);
        map.put(media.getPath(), media);
    }
    if (selectedMedias == null || selectedMedias.size() < 0) {
        return;
    }
    for (BaseMedia media : selectedMedias) {
        if (map.containsKey(media.getPath())) {
            map.get(media.getPath()).setSelected(true);
        }
    }
}
Also used : HashMap(java.util.HashMap) ImageMedia(com.bilibili.boxing.model.entity.impl.ImageMedia) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia)

Example 9 with BaseMedia

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

the class AbsBoxingViewActivity method onFinish.

/**
 * called the job is done.Click the ok button, take a photo from camera, crop a photo.
 * most of the time, you do not have to override.
 *
 * @param medias the list of selection
 */
@Override
public void onFinish(@NonNull List<BaseMedia> medias) {
    Intent intent = new Intent();
    intent.putParcelableArrayListExtra(Boxing.EXTRA_RESULT, (ArrayList<BaseMedia>) medias);
}
Also used : Intent(android.content.Intent) BaseMedia(com.bilibili.boxing.model.entity.BaseMedia)

Example 10 with BaseMedia

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

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