1.APP的build.gradle
2.Glide的版本
3.AndroidManifest 中application节点配置
4.PictureSelector的版本
com.github.LuckSiege.PictureSelector:picture_library:v2.2.3
使用:
/**
* 拍照上传照片
*/
private void getTakePhoto() {
PictureSelector.create(this)
.openCamera(PictureMimeType.ofImage())
.imageFormat(PictureMimeType.PNG)
.withAspectRatio(1, 1)
.circleDimmedLayer(true)
.enableCrop(true)
.compress(true)
.isZoomAnim(true)
.showCropFrame(false)
.showCropGrid(false)
.rotateEnabled(false)
.scaleEnabled(true)
.minimumCompressSize(100)
.synOrAsy(true)
.forResult(PictureConfig.CHOOSE_REQUEST);
}
/**
* 从相册选择图片上传
*/
private void getChoosePhoto() {
PictureSelector.create(this)
.openGallery(PictureMimeType.ofImage())
.theme(R.style.picture_default_style)
.maxSelectNum(1)
.minSelectNum(1)
.imageSpanCount(3)
.previewImage(false)
.previewVideo(false)
.selectionMode(PictureConfig.SINGLE)
.previewImage(false)
.isCamera(false)
.withAspectRatio(1, 1)
.imageFormat(PictureMimeType.PNG)
.circleDimmedLayer(true)
.enableCrop(true)
.compress(true)
.showCropFrame(false)
.showCropGrid(false)
.rotateEnabled(false)
.scaleEnabled(true)
.isGif(false)
.minimumCompressSize(100)
.synOrAsy(true)
.forResult(PictureConfig.CHOOSE_REQUEST);
}
/**
* 获取图片返回结果
*
* @param requestCode
* @param resultCode
* @param data
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
switch (requestCode) {
case PictureConfig.CHOOSE_REQUEST:
List<LocalMedia> selectList = PictureSelector.obtainMultipleResult(data);
if (selectList.get(0).isCompressed()) {
LogUtils.e("======",selectList.get(0).getCompressPath());
// upLoadingPic(selectList.get(0).getCompressPath());
}
break;
default:
}
}
}