Luban
Luban copied to clipboard
api 29 无法压缩
获取到图标uri也是无法压缩的, 除非把文件复制到私有目录
private File compress(Context context, InputStreamProvider path) throws IOException {
File result;
File outFile = getImageCacheFile(context, Checker.SINGLE.extSuffix(path));
if (mRenameListener != null) {
String filename = mRenameListener.rename(path.getPath());
outFile = getImageCustomFile(context, filename);
}
if (mCompressionPredicate != null) {
if (mCompressionPredicate.apply(path.getPath())
&& Checker.SINGLE.needCompress(mLeastCompressSize, path.getPath())) {
result = new Engine(path, outFile, focusAlpha).compress();
} else {
result = new File(path.getPath());
}
} else {
result = Checker.SINGLE.needCompress(mLeastCompressSize, path.getPath()) ?
new Engine(path, outFile, focusAlpha).compress() :
new File(path.getPath());
}
return result;
}
boolean needCompress(int leastCompressSize, String path) {
if (leastCompressSize > 0) {
File source = new File(path);
return source.exists() && source.length() > (leastCompressSize << 10);
}
return true;
}
非常希望作者能继续维护这个库.
刚接入了,也发现了这个问题。这个判断文件是否存在的代码得改一下。 我在 InputStreamProvider 接口新增了一个方法,通过流获取大小。 @Override public long getInputStreamSize() throws IOException { return inputStream == null ? 0 : inputStream.available(); }
刚接入了,也发现了这个问题。这个判断文件是否存在的代码得改一下。 我在 InputStreamProvider 接口新增了一个方法,通过流获取大小。 @override public long getInputStreamSize() throws IOException { return inputStream == null ? 0 : inputStream.available(); }
这个方法在哪具体怎么使用呀?