|
@@ -37,9 +37,13 @@ import com.cooleshow.student.contract.PersonalSettingContract;
|
|
|
import com.cooleshow.student.databinding.ActivityPersonalSettingBinding;
|
|
|
import com.cooleshow.student.presenter.mine.PersonalSettingPresenter;
|
|
|
import com.cooleshow.usercenter.bean.SetDetailBean;
|
|
|
+import com.daya.live_teaching.utils.GlideEngine;
|
|
|
+import com.luck.picture.lib.PictureSelector;
|
|
|
import com.luck.picture.lib.compress.CompressionPredicate;
|
|
|
import com.luck.picture.lib.compress.Luban;
|
|
|
import com.luck.picture.lib.compress.OnCompressListener;
|
|
|
+import com.luck.picture.lib.config.PictureConfig;
|
|
|
+import com.luck.picture.lib.config.PictureMimeType;
|
|
|
import com.luck.picture.lib.entity.LocalMedia;
|
|
|
import com.tbruyelle.rxpermissions3.RxPermissions;
|
|
|
|
|
@@ -257,14 +261,7 @@ public class PersonalSettingActivity extends BaseMVPActivity<ActivityPersonalSet
|
|
|
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
|
.subscribe(granted -> {
|
|
|
if (granted) {
|
|
|
- /* Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
|
- File file = new File(imagePath);
|
|
|
- Uri imageUri = Uri.fromFile(file);
|
|
|
- intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
|
|
|
- Log.e("asdfasdfasdfadfs", "111111" );
|
|
|
- ActivityUtils.startActivityForResult(this, intent, REQUEST_CODE_CAMERA);*/
|
|
|
- imagePath = Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera/" + System.currentTimeMillis() + ".jpg";
|
|
|
- requestCamera(imagePath);
|
|
|
+ goCamera();
|
|
|
} else {
|
|
|
ToastUtil.getInstance().show(this, "请选择存储和相机权限!");
|
|
|
}
|
|
@@ -317,21 +314,39 @@ public class PersonalSettingActivity extends BaseMVPActivity<ActivityPersonalSet
|
|
|
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
|
.subscribe(granted -> {
|
|
|
if (granted) {
|
|
|
- Intent intent;
|
|
|
- if (Build.VERSION.SDK_INT < 19) {
|
|
|
- intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
- intent.setType("image/*");
|
|
|
- } else {
|
|
|
- intent = new Intent(Intent.ACTION_PICK,
|
|
|
- MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
|
|
- }
|
|
|
- ActivityUtils.startActivityForResult(this, intent, REQUEST_CODE_LOCAL);
|
|
|
+ goAlbum();
|
|
|
} else {
|
|
|
ToastUtil.getInstance().show(this, "请选择存储和相机权限!");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void goCamera() {
|
|
|
+ PictureSelector.create(this)
|
|
|
+ .openCamera(PictureMimeType.ofImage())
|
|
|
+ .loadImageEngine(GlideEngine.createGlideEngine())
|
|
|
+ .theme(com.cooleshow.base.R.style.picture_daya_style)// 主题样式设置 具体参考 values/styles 用法:R .style.picture.white.style
|
|
|
+ .selectionMode(PictureConfig.SINGLE)// 多选 or 单选 PictureConfig.MULTIPLE or PictureConfig.SINGLE
|
|
|
+ .enableCrop(true)// 是否裁剪 true or false
|
|
|
+ .showCropGrid(false)// 是否显示裁剪矩形网格 圆形裁剪时建议设为false true or false
|
|
|
+ .compress(true)// 是否压缩 true or false
|
|
|
+ .circleDimmedLayer(true)// 是否圆形裁剪 true or false
|
|
|
+ .forResult(REQUEST_CODE_LOCAL);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void goAlbum() {
|
|
|
+ PictureSelector.create(this)
|
|
|
+ .openGallery(PictureMimeType.ofImage())//全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio()
|
|
|
+ .loadImageEngine(GlideEngine.createGlideEngine())
|
|
|
+ .theme(com.cooleshow.base.R.style.picture_daya_style)// 主题样式设置 具体参考 values/styles 用法:R .style.picture.white.style
|
|
|
+ .selectionMode(PictureConfig.SINGLE)// 多选 or 单选 PictureConfig.MULTIPLE or PictureConfig.SINGLE
|
|
|
+ .enableCrop(true)// 是否裁剪 true or false
|
|
|
+ .showCropGrid(false)// 是否显示裁剪矩形网格 圆形裁剪时建议设为false true or false
|
|
|
+ .compress(true)// 是否压缩 true or false
|
|
|
+ .circleDimmedLayer(true)// 是否圆形裁剪 true or false
|
|
|
+ .forResult(REQUEST_CODE_LOCAL);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
protected void initView() {
|
|
@@ -355,7 +370,6 @@ public class PersonalSettingActivity extends BaseMVPActivity<ActivityPersonalSet
|
|
|
@Override
|
|
|
protected void onResume() {
|
|
|
super.onResume();
|
|
|
- Log.e("afkjhkadsfas", "onResume: ===============");
|
|
|
presenter.queryUserInfo();
|
|
|
}
|
|
|
|
|
@@ -479,9 +493,13 @@ public class PersonalSettingActivity extends BaseMVPActivity<ActivityPersonalSet
|
|
|
}
|
|
|
} else if (requestCode == REQUEST_CODE_LOCAL) {
|
|
|
if (data != null) {
|
|
|
- Uri selectedImage = data.getData();
|
|
|
- if (selectedImage != null) {
|
|
|
- String v_path = FileUtils.getFilePathForN(selectedImage, PersonalSettingActivity.this);
|
|
|
+ // 图片、视频、音频选择结果回调
|
|
|
+ List<LocalMedia> selectList = PictureSelector.obtainMultipleResult(data);
|
|
|
+ String v_path = null;
|
|
|
+ if (selectList != null && selectList.size() > 0) {
|
|
|
+ v_path = selectList.get(0).getCompressPath();
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(v_path)) {
|
|
|
boolean isImg = MyFileUtils.isImg(v_path);
|
|
|
if (isImg) {
|
|
|
compressImg(v_path);
|