TakePhoto的照片选择器的使用(多选)

参考项目地址 https://blog.csdn.net/iamchan/article/details/81261524
https://github.com/bumptech/glide 此项目中glide使用 3.7.0 高版本的报错 为啥`````俺也不知

github地址 https://github.com/crazycodeboy/TakePhoto
在按钮里面直接调用onClickTake(getTakePhoto);即可
public void onClickTake(TakePhoto takePhoto) {
configCompress(takePhoto);
takePhoto.onPickMultiple(1);//根据需求这里面放最大图片数 单选使用takePhoto.onPickFromGallery();
}

private void configCompress(TakePhoto takePhoto) {//压缩的配置
int maxSize = Integer.parseInt("409600");//最大 压缩
int width = Integer.parseInt("800");//宽
int height = Integer.parseInt("800");//高
CompressConfig config;
config = new CompressConfig.Builder().setMaxSize(maxSize)
.setMaxPixel(width >= height ? width : height)

.enableReserveRaw(false)//拍照压缩后是否显示原图
.create();
takePhoto.onEnableCompress(config, false);//是否显示进度条

}

需要实现继承 TakePhotoActivity 或者 TakePhotoFragment
实现 takeSuccess() takeFail() takeCancel()

takeSuccess 方法中可以取到返回值的图片 像这样
public void takeSuccess(TResult result) {
super.takeSuccess(result);
Glide.with(getApplicationContext()).load(result.getImages().get(0).getCompressPath()).into(ivTest);
}

猜你喜欢

转载自www.cnblogs.com/manong-xxf/p/10766987.html