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

api 29 无法压缩 #383

Open
Liangwenb opened this issue Oct 31, 2020 · 2 comments
Open

api 29 无法压缩 #383

Liangwenb opened this issue Oct 31, 2020 · 2 comments

Comments

@Liangwenb
Copy link

获取到图标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;
}

非常希望作者能继续维护这个库.

@Love667767
Copy link

Love667767 commented Nov 8, 2020

刚接入了,也发现了这个问题。这个判断文件是否存在的代码得改一下。
我在 InputStreamProvider 接口新增了一个方法,通过流获取大小。
@OverRide
public long getInputStreamSize() throws IOException {
return inputStream == null ? 0 : inputStream.available();
}

@ziyouxiaozi
Copy link

刚接入了,也发现了这个问题。这个判断文件是否存在的代码得改一下。
我在 InputStreamProvider 接口新增了一个方法,通过流获取大小。
@OverRide
public long getInputStreamSize() throws IOException {
return inputStream == null ? 0 : inputStream.available();
}

这个方法在哪具体怎么使用呀?

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

3 participants