Search in sources :

Example 21 with BoxingConfig

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

the class MainActivity method onClick.

@Override
public void onClick(View v) {
    int id = v.getId();
    switch(id) {
        case R.id.first_btn:
            Intent intent1 = new Intent(MainActivity.this, FirstActivity.class);
            startActivity(intent1);
            break;
        case R.id.second_btn:
            BoxingConfig singleImgConfig = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG);
            Boxing.of(singleImgConfig).withIntent(this, SecondActivity.class).start(this);
            break;
        default:
            break;
    }
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) Intent(android.content.Intent)

Example 22 with BoxingConfig

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

the class IntentFilterActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // in DCIM/bili/boxing
    String cropPath = BoxingFileHelper.getBoxingPathInDCIM();
    if (TextUtils.isEmpty(cropPath)) {
        Toast.makeText(getApplicationContext(), R.string.boxing_storage_deny, Toast.LENGTH_SHORT).show();
        return;
    }
    Uri destUri = new Uri.Builder().scheme("file").appendPath(cropPath).appendPath(String.format(Locale.US, "%s.jpg", System.currentTimeMillis())).build();
    BoxingConfig config = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG).needCamera(R.drawable.ic_boxing_camera_white).withCropOption(new BoxingCropOption(destUri));
    BoxingManager.getInstance().setBoxingConfig(config);
    super.onCreate(savedInstanceState);
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) BoxingCropOption(com.bilibili.boxing.model.config.BoxingCropOption) Uri(android.net.Uri)

Example 23 with BoxingConfig

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

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

the class AbsBoxingViewFragment method initCameraPhotoPicker.

private void initCameraPhotoPicker(Bundle savedInstanceState) {
    BoxingConfig config = BoxingManager.getInstance().getBoxingConfig();
    if (config == null || !config.isNeedCamera()) {
        return;
    }
    mCameraPicker = new CameraPickerHelper(savedInstanceState);
    mCameraPicker.setPickCallback(new CameraListener(this));
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) CameraPickerHelper(com.bilibili.boxing.utils.CameraPickerHelper)

Example 25 with BoxingConfig

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

the class AbsBoxingViewActivity method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    BoxingConfig config;
    if (savedInstanceState != null) {
        config = savedInstanceState.getParcelable(Boxing.EXTRA_CONFIG);
    } else {
        config = BoxingManager.getInstance().getBoxingConfig();
    }
    setPickerConfig(config);
    parseSelectedMedias(savedInstanceState, getIntent());
    setPresenter(new PickerPresenter(this));
}
Also used : BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) 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