视频直播源码,图片选择器ImagePicker
引入
gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0'
//使用的三方
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'com.yalantis:ucrop:2.2.0'
implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0'
implementation 'com.github.DL-ZhangTeng:Utils:2.2.0'
使用
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder()
.provider(getPackageName() + ".FileProvider")
.imageLoader(new GlideImageLoader()) //图片加载器
.iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效)
.multiSelect(true) //是否多选
.isShowCamera(true)
.isVideoPicker(true) //是否选择视频 默认false
.isImagePicker(true)
.imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型
.isMirror(false) //是否旋转镜头
.maxImageSelectable(9) //图片可选择数
.maxHeight(1920) //图片最大高度
.maxWidth(1920) //图片最大宽度
.maxImageSize(15) //图片最大大小Mb
.maxVideoLength(5 * 1000)
.maxVideoSize(180)
.isCrop(true)
.pathList(new ArrayList<>())
.pickerThemeColorRes(R.color.image_picker_white)
.pickerTitleColorRes(R.color.image_picker_text_black)
.cropThemeColorRes(R.color.image_picker_white)
.cropTitleColorRes(R.color.image_picker_text_black)
.pickerBackRes(R.mipmap.image_picker_back_black)
.pickerFolderRes(R.mipmap.image_picker_folder_black)
.build();
findViewById(R.id.iv).setOnClickListener(v -> {
// imagePickerConfig.getPathList().clear();
ImagePickerOpen.getInstance()
.setImagePickerConfig(imagePickerConfig)
.pathList(new ArrayList<>())
.open(this, 100);
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 100 && data != null) {
List<String> paths = ImagePickerOpen.getResultData(this, resultCode, data);
ImagePickerOpen.getInstance().getImagePickerConfig().getImageLoader().loadImage(this, findViewById(R.id.iv), paths.get(0));
}
}
}
public class HandlerCallBack implements IHandlerCallBack<ImageInfo> {
private String TAG = "---ImagePicker---";
List<ImageInfo> photoList = new ArrayList<>();
@Override
public void onStart() {
Log.i(TAG, "onStart: 开启");
}
@Override
public void onSuccess(List<ImageInfo> photoList) {
this.photoList = photoList;
Log.i(TAG, "onSuccess: 返回数据");
}
@Override
public void onCancel() {
Log.i(TAG, "onCancel: 取消");
}
@Override
public void onFinish(List<ImageInfo> selectImage) {
}
@Override
public void one rror() {
Log.i(TAG, "onError: 出错");
}
}
以上就是视频直播源码,图片选择器ImagePicker, 更多内容欢迎关注之后的文章
标签:picker,void,public,源码,ImagePicker,Override,image,选择器 From: https://www.cnblogs.com/yunbaomengnan/p/17843817.html