Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

循环压缩图片 可能会把压缩的图片输出在相同的文件地址导致覆盖 #61

Closed
Baifann opened this issue Sep 6, 2016 · 5 comments

Comments

@Baifann
Copy link

Baifann commented Sep 6, 2016

rt,我是这么循环压缩的

for(String fileUrl : fileList){
            Luban.get(this).putGear(Luban.THIRD_GEAR)
            .load(new File(fileUrl))
//            .setFilename(getCurrentPhotoFile().getAbsolutePath())
            .setCompressListener(new OnCompressListener() {

                @Override
                public void onSuccess(File file) {
                    DLog.i("完成剪裁:" + file.getAbsolutePath());
                    mCompressList.add(file.getAbsolutePath());
                    if(mCompressList.size() == fileList.size()){
                        uploadFile(mCompressList);
                    }
                }

                @Override
                public void onStart() {
                    DLog.i("开始剪裁");
                }

                @Override
                public void onError(Throwable e) {
                    DLog.i("error:" + e.toString());
                }
            }).launch();

结果发现剪裁完的地址可能会出现相同的结果。

@silentcmz
Copy link

同问,有什么解决办法了么

@Baifann
Copy link
Author

Baifann commented Sep 14, 2016

我是这么处理的 在他时间戳命名里再加了原有的文件名

 private File thirdCompress(@NonNull File file) {
        String thumb = mCacheDir.getAbsolutePath() + File.separator +
                (TextUtils.isEmpty(filename) ? System.currentTimeMillis() + "_" + file.getName() : filename);

        //...
}

@silentcmz
Copy link

@Baifann 没有问题了?我试了,还是不行

@Baifann
Copy link
Author

Baifann commented Sep 19, 2016

@silentcmz 我是没问题了,我是把作者rxjava那段去掉了,自己弄得线程,可能和原来的不大一样吧。

@silentcmz
Copy link

@Baifann 你是对的,我的也没问题,就是排序的时候没弄好,现在也可以了

@Baifann Baifann closed this as completed Sep 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants