use of com.luck.picture.lib.weiui.library.entity.EventEntity in project weiui by kuaifan.
the class PictureBaseActivity method compressImage.
/**
* compressImage
*/
protected void compressImage(final List<LocalMedia> result) {
showCompressDialog();
if (config.synOrAsy) {
Flowable.just(result).observeOn(Schedulers.io()).map(new Function<List<LocalMedia>, List<File>>() {
@Override
public List<File> apply(@NonNull List<LocalMedia> list) throws Exception {
List<File> files = Luban.with(mContext).setTargetDir(config.compressSavePath).ignoreBy(config.minimumCompressSize).loadLocalMedia(list).get();
if (files == null) {
files = new ArrayList<>();
}
return files;
}
}).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<List<File>>() {
@Override
public void accept(@NonNull List<File> files) throws Exception {
handleCompressCallBack(result, files);
}
});
} else {
Luban.with(this).loadLocalMedia(result).ignoreBy(config.minimumCompressSize).setTargetDir(config.compressSavePath).setCompressListener(new OnCompressListener() {
@Override
public void onStart() {
}
@Override
public void onSuccess(List<LocalMedia> list) {
RxBus.getDefault().post(new EventEntity(PictureConfig.CLOSE_PREVIEW_FLAG));
onResult(list);
}
@Override
public void onError(Throwable e) {
RxBus.getDefault().post(new EventEntity(PictureConfig.CLOSE_PREVIEW_FLAG));
onResult(result);
}
}).launch();
}
}
use of com.luck.picture.lib.weiui.library.entity.EventEntity in project weiui by kuaifan.
the class PicturePreviewActivity method updateSelector.
/**
* 更新图片列表选中效果
*
* @param isRefresh
*/
private void updateSelector(boolean isRefresh) {
if (isRefresh) {
EventEntity obj = new EventEntity(PictureConfig.UPDATE_FLAG, selectImages, index);
RxBus.getDefault().post(obj);
}
}
use of com.luck.picture.lib.weiui.library.entity.EventEntity in project weiui by kuaifan.
the class PicturePreviewActivity method singleRadioMediaImage.
/**
* 单选图片
*/
private void singleRadioMediaImage() {
if (selectImages != null && selectImages.size() > 0) {
LocalMedia media = selectImages.get(0);
RxBus.getDefault().post(new EventEntity(PictureConfig.UPDATE_FLAG, selectImages, media.getPosition()));
selectImages.clear();
}
}
use of com.luck.picture.lib.weiui.library.entity.EventEntity in project weiui by kuaifan.
the class PictureBaseActivity method handleCompressCallBack.
/**
* 重新构造已压缩的图片返回集合
*
* @param images
* @param files
*/
private void handleCompressCallBack(List<LocalMedia> images, List<File> files) {
if (files.size() == images.size()) {
for (int i = 0, j = images.size(); i < j; i++) {
// 压缩成功后的地址
String path = files.get(i).getPath();
LocalMedia image = images.get(i);
// 如果是网络图片则不压缩
boolean http = PictureMimeType.isHttp(path);
boolean eqTrue = !TextUtils.isEmpty(path) && http;
image.setCompressed(eqTrue ? false : true);
image.setCompressPath(eqTrue ? "" : path);
}
}
RxBus.getDefault().post(new EventEntity(PictureConfig.CLOSE_PREVIEW_FLAG));
onResult(images);
}
Aggregations