打开相册多选视频及照片
1.依赖
//图片选择器
implementation 'com.github.LuckSiege.PictureSelector:picture_library:v2.6.0'
//Glide 4.x
implementation 'com.github.bumptech.glide:glide:4.11.0'
2.仓库
maven { url 'https://jitpack.io' }
3.跳转相册
private void selectImage() {
/**
* 参数一:打开系统相册的ACTION
* 参数二:返回数据的方式(从系统相册的数据库获取)
*/
// Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
// intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File("/sdcard/test.mp4")));
// startActivityForResult(intent, FLAG_REQUEST_CAMERA_VIDEO);
PictureSelector.create(this)
.openGallery(PictureMimeType.ofAll())
.maxSelectNum(9)
.loadImageEngine(GlideEngine.createGlideEngine()) // 请参考Demo GlideEngine.java
.forResult(PictureConfig.CHOOSE_REQUEST);
}
4.获取结果
PictureSelector.obtainMultipleResult(data);
附:工具类
package com.example.mylibrary.base.utils;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.bumptech.glide.request.target.ImageViewTarget;
import com.example.mylibrary.R;
import com.luck.picture.lib.engine.ImageEngine;
import com.luck