【问题标题】:Glide does not load image from cache locationGlide 不会从缓存位置加载图像
【发布时间】:2021-05-30 03:38:27
【问题描述】:

我使用以下代码将图片从firebase storage 下载到本地文件:

val sharedReference = FirebaseStorage.getInstance().getReferenceFromUrl("url to my bucket")
    val localFile = File.createTempFile("images", "jpg")
    sharedReference.getFile(localFile).addOnSuccessListener {
   
    Glide.with(context).load(localFile.toUri().path).into(myImageView)

    }

但是我从那里得到的网址是这样的:

/data/user/0/com.example.myapp/cache/images1018011169077473514jpg

并且glide不会加载图像。如何在imageView中使用glide加载图像。

我们将不胜感激任何帮助或建议。

【问题讨论】:

    标签: android kotlin firebase-storage android-glide


    【解决方案1】:

    不要创建临时文件,直接通过 Glide 显示图像。 无论如何它都会缓存它。

    【讨论】:

    • 感谢您的回复。我现在看到它确实会自动缓存图像,所以当设备离线时我仍然可以使用它。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2017-09-13
    • 2017-07-01
    • 1970-01-01
    • 2019-10-13
    • 1970-01-01
    • 1970-01-01
    • 2016-06-23
    • 2020-09-23
    相关资源
    最近更新 更多