有人能帮助我如何检索文件路径,其中的图像存储使用滑动缓存?我想将加载了glide的图像发送到图像视图服务器。我可以知道如何获取缓存图像的文件路径吗?选择glide缓存图像的原因是它要上传到服务器的大小要小得多。
如果不可能,有人能建议压缩图像的方法吗?
我尝试过不同的图像压缩算法,但没有一种能像glide那样提供最好的压缩效果。

最佳答案

glide支持simpletarget,在加载完成时提供位图。

 private SimpleTarget target = new SimpleTarget<Bitmap>() {
    @Override
    public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {

        // upload bitmap here after saving it to your disk

    }
  };

然后将目标用作
Glide
    .with( context ) // could be an issue!
    .load( eatFoodyImages[0] )
    .asBitmap()
    .into( target );

https://futurestud.io/tutorials/glide-callbacks-simpletarget-and-viewtarget-for-custom-view-classes学习更多

关于android - 获取 Glide 加载的图像的文件路径,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43762266/

10-08 21:21
查看更多