LuckSiege / LuckSiege/PictureSelector

setCompressEngine设置压缩后,拿不到压缩后的图片地址

Open
#2,800 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
13.6k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

## Current use version?
#### 当前使用的版本是多少?
3.11.1
```

```

## Will this problem occur in demo?
#### Demo能否复现这问题?

```

```

## Describe the problem or provide an error log?
#### 描述问题或提供错误log?

在setCompressEngine中使用鲁班luban后,forResult回调函数里的localmedia.getCompressPath() 一直null,感觉是没有把compresspath传出来。 检查了一下图片压缩后的存储路径,存在被压缩后的图片,但在forresult回调函数的 localmedia.getCompressPath() 却为null

![image](https://github.com/LuckSiege/PictureSelector/assets/56991995/3eb1c18c-9c1c-4efc-9e5b-190cbb43fcd7)

```
PictureSelector.create(FreeDrawActivity.this)
.openGallery(SelectMimeType.TYPE_IMAGE)
.setSelectionMode(SelectModeConfig.SINGLE)
.isDisplayCamera(true)
.isPreviewImage(true) // 是否可预览图片 true or false
.isDirectReturnSingle(true)
.setImageEngine(GlideEngine.createGlideEngine())
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
.setCompressEngine((CompressFileEngine) (context, source, call) -> {
//bug: 压缩后的地址没有传到localMedia.getCompressPath()。 PictureSelector3.0 的 Bug??
Luban.with(context).load(source)
.setTargetDir(SystemDirPath.getDefaultProjectWorkspaceTempDir()) //设置压缩的临时存储
.ignoreBy(100).setCompressListener(new OnNewCompressListener() {
@Override
public void onStart() {

}

@Override
public void onSuccess(String source, File compressFile) {
if (call != null) {
call.onCallback(source, compressFile.getAbsolutePath());
}
}

@Override
public void onError(String source, Throwable e) {
if (call != null) {
call.onCallback(source, null);
}
}
}).launch();
})

.forResult(new OnResultCallbackListener() {
@Override
public void onResult(ArrayList selectList) {

if (selectList.size() > 0) {
LocalMedia localMedia = selectList.get(0);
//获取压缩后的路径
String path = localMedia.getPath();
// 这里返回的compressPath 为null
String compressPath = localMedia.getCompressPath();
String realPath = localMedia.getRealPath();
String availablePath = localMedia.getAvailablePath();

if (new File(compressPath).exists()) //这里拿到的压缩后的地址为null
img_open(compressPath);
else {
img_open(realPath);
}

}

}

@Override
public void onCancel() {

}
});
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the setCompressEngine callback into the forResult LocalMedia result, focusing on how compressPath is assigned after call.onCallback(source, compressFile.getAbsolutePath()). Reproduce the issue with the supplied PictureSelector configuration and verify that localMedia.getCompressPath() contains the generated file path when compression succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.