记录一下使用过的框架大全



1.

// 一款图片选择框架
compile 'com.bilibili:boxing-impl:0.6.0'

代码片段

private void selectImage() {
    BoxingConfig config = new BoxingConfig(BoxingConfig.Mode.SINGLE_IMG); // Mode:Mode.SINGLE_IMG, Mode.MULTI_IMG, Mode.VIDEO
    config.needCamera().needGif().withMaxCount(1); // 支持gif,相机,设置最大选图数
    Boxing.of(config).withIntent(EnrollActivity.this, BoxingActivity.class).start(EnrollActivity.this, 1000);
}

效果如下:


2.

// picasso 好用的图片开源框架

compile 'com.squareup.picasso:picasso:2.5.2'

代码片段

Picasso.with(EnrollActivity.this).load(new File(path)).placeholder(R.drawable.head).error(R.drawable.head).into(imageView);

3.

//时间总线框架

compile 'org.greenrobot:eventbus:3.0.0'

代码片段


注册 解除

@Override
protected void onStart() {
    super.onStart();
    EventBus.getDefault().register(this);
}

@Override
protected void onStop() {
    super.onStop();
    EventBus.getDefault().unregister(this);
}

发送事件

EventBus.getDefault().post(new FaceResponse(0, FaceResponse.FaceType.DETECTION, list));

接收事件

@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(FaceResponse event) {
    if(event.getCode() != 0){
        showError("错误","出错步骤:" + event.getType() + "  错误码:" + event.getCode());
        Log.e("Tag","错误码:" + event.getCode());
    }else {
        Log.e("Tag","成功:" + event.getType());
        if(event.getType() == FaceResponse.FaceType.RECOGNITION){
            showSuccess("成功","");
        }
    }
};


4.

// 好用的弹窗动画框架

compile 'cn.pedant.sweetalert:library:1.3'

代码片段

@Override
public void showSuccess(final String title, final String msg) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (dialog == null) {
                dialog = new SweetAlertDialog(EnrollActivity.this, SweetAlertDialog.SUCCESS_TYPE);
            } else {
                dialog.changeAlertType(SweetAlertDialog.SUCCESS_TYPE);
            }
            dialog.setConfirmText("确定").setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
                @Override
                public void onClick(SweetAlertDialog sweetAlertDialog) {
                    sweetAlertDialog.dismiss();
                    Intent intent = new Intent();
                    intent.putExtra("isUpdate", true);
                    setResult(RESULT_OK, intent);
                    finish();
                }
            });
            dialog.setTitleText(title).setContentText(msg).show();
        }
    });

}

效果

记录一下使用过的框架大全


5.

// 好用的图片裁剪框架  配合bilibili 一起使用效果更佳

compile('com.yalantis:ucrop:2.2.0')

代码片段

                    @NonNull String path, int requestCode) {
Uri uri = new Uri.Builder()
        .scheme("file")
        .appendPath(path)
        .build();

UCrop.Options crop = new UCrop.Options();

// do not copy exif information to crop pictures
// because png do not have exif and png is not Distinguishable

crop.setCompressionFormat(Bitmap.CompressFormat.PNG);
crop.withMaxResultSize(cropConfig.getMaxWidth(), cropConfig.getMaxHeight());
crop.withAspectRatio(cropConfig.getAspectRatioX(), cropConfig.getAspectRatioY());

UCrop.of(uri, cropConfig.getDestination())
        .withOptions(crop)
        .start(context, fragment, requestCode);


public Uri onCropFinish(int resultCode, Intent data) {
    if (data == null) {
        return null;
    }
    Throwable throwable = UCrop.getError(data);
    if (throwable != null) {
        return null;
    }
    return UCrop.getOutput(data);
}



6. 

// glide  图片加载框架

compile 'com.github.bumptech.glide:glide:3.7.0'

代码片段

Glide.with(this)
        .load(path)
        .dontAnimate()
        .diskCacheStrategy(DiskCacheStrategy.NONE)
        .skipMemoryCache(true)
        .error(R.mipmap.user_icon)
        .placeholder(R.mipmap.user_icon)
        .bitmapTransform(new CropCircleTransformation(this))
        .into(head);


7. 


// https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15
compile group: 'org.bouncycastle', name: 'bcprov-jdk15', version: '1.45'

// https://mvnrepository.com/artifact/commons-codec/commons-codec
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
return new String(Base64.encodeBase64(tmp));