Search in sources :

Example 16 with BoxingConfig

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

the class ConfigTest method testCameraRes.

@Test
public void testCameraRes() {
    mPickerManager.setBoxingConfig(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG));
    BoxingConfig config = mPickerManager.getBoxingConfig();
    assertEquals(config.getCameraRes(), 0);
    assertEquals(BoxingResHelper.getCameraRes(), 0);
    mPickerManager.setBoxingConfig(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).needCamera(R.drawable.ic_boxing_broken_image));
    config = mPickerManager.getBoxingConfig();
    assertEquals(config.getCameraRes(), R.drawable.ic_boxing_broken_image);
    assertEquals(BoxingResHelper.getCameraRes(), R.drawable.ic_boxing_broken_image);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) Test(org.junit.Test)

Example 17 with BoxingConfig

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

the class Boxing method get.

/**
 * call {@link #of(BoxingConfig)} first to specify the mode otherwise {@link BoxingConfig.Mode#MULTI_IMG} is used.<br/>
 */
public static Boxing get() {
    BoxingConfig config = BoxingManager.getInstance().getBoxingConfig();
    if (config == null) {
        config = new BoxingConfig(BoxingConfig.Mode.MULTI_IMG).needGif();
        BoxingManager.getInstance().setBoxingConfig(config);
    }
    return new Boxing(config);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig)

Example 18 with BoxingConfig

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

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

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

the class TestBlankActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_boxing);
    BoxingMediaLoader.getInstance().init(new IBoxingMediaLoader() {

        @Override
        public void displayThumbnail(@NonNull ImageView img, @NonNull String absPath, int width, int height) {
        }

        @Override
        public void displayRaw(@NonNull ImageView img, @NonNull String absPath, int width, int height, IBoxingCallback callback) {
        }
    });
    BoxingViewFragment fragment = BoxingViewFragment.newInstance();
    fragment.setTitleTxt((TextView) findViewById(R.id.pick_album_txt));
    fragment.setPresenter(new PickerPresenter(fragment));
    fragment.setPickerConfig(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG));
    final FragmentManager manager = getSupportFragmentManager();
    manager.beginTransaction().add(R.id.content_layout, fragment).commit();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) IBoxingCallback(com.bilibili.boxing.loader.IBoxingCallback) IBoxingMediaLoader(com.bilibili.boxing.loader.IBoxingMediaLoader) ImageView(android.widget.ImageView) BoxingViewFragment(com.bilibili.boxing_impl.ui.BoxingViewFragment) PickerPresenter(com.bilibili.boxing.presenter.PickerPresenter)

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