撸吧坑死宝宝了

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

luban图片压缩 我想多图压缩完成有后缀名 .setFilename(f.getAbsolutePath()) 里面是setFilename(“data/data/img.png”)不然里面会截取 截取找不到 / 就抛出异常了

rivate void initFile() {
    for (int i = 0; i < photoPaths.size(); i++) {

        File f = new File(photoPaths.get(i));
        Luban.get(this)
                .load(f)
                .setFilename(f.getAbsolutePath())
                .putGear(Luban.THIRD_GEAR)
                .setCompressListener(new OnCompressListener() {
                    @Override
                    public void onStart() {
                        Toast.makeText(MainRepairsActivity.this, "正在压缩,请不要上传!", Toast.LENGTH_SHORT).show();
                    }

                    @Override
                    public void onSuccess(File file) {
                        Toast.makeText(MainRepairsActivity.this, "压缩成功了,快去上传吧!", Toast.LENGTH_SHORT).show();
                        files.add(file);
                    }

                    @Override
                    public void onError(Throwable e) {
                        e.printStackTrace();
                        Toast.makeText(MainRepairsActivity.this, "图片压缩失败!", Toast.LENGTH_SHORT).show();
                    }
                }).launch();

    }
}

转载于:https://my.oschina.net/u/3407708/blog/1358791

你可能感兴趣的:(撸吧坑死宝宝了)