【问题标题】:Firebase Storage UI and Glide not showing imagesFirebase 存储 UI 和 Glide 不显示图像
【发布时间】:2017-10-11 00:06:28
【问题描述】:

所以我有一个从 Firebase 存储加载图片的回收视图。我使用 Glide 库和 FirebaseImageLoader 来实现这一点。直到上周一,一切都运行良好。图像不再显示,没有错误、异常或其他帮助我弄清楚图像不再加载的原因:这里有一些代码 sn-ps:

分级:

compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.firebaseui:firebase-ui-storage:1.2.0'

ImageView 我用来显示图片的:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="130dp"
    android:id="@+id/imageView_promotions"
    android:scaleType="centerCrop"/>

构建 Firebase 存储链接的 Java 代码:

public StorageReference getThumbUri(String municipality){
       return Constants.STORAGE_REFERENCE.child(Constants.PROMOTIONS).child(municipality).child(promo_thumb);
        //returns e.g. gs://myfirebaseapp.com/promotions/Mahikeng/spar_thumb.png
    }

加载图片的代码:

Glide.with(context).using(new FirebaseImageLoader()).load(promotions.get(position).
                        getThumbUri(municipality)).into(holder.imageView_promotions);

附注这段代码一直运行良好,从未改变过我向上帝发誓的任何东西。我所做的只是将我的 Android Studio 更新到 2.3.1 并将 Google 支持库更新到 25.3.1

【问题讨论】:

    标签: android firebase firebase-storage android-glide


    【解决方案1】:

    我设法解决了。如果有人遇到同样的问题,请恢复到 Firebase SDK 版本 10.2.1,如果您最近将其更新到 10.2.4,那么最新的 SDK 似乎存在错误。

    一切都好

    【讨论】:

      【解决方案2】:

      我在 Kotlin 中的解决方案:

      if (reference != null && reference.isNotEmpty()) {
                  val storageReference = FirebaseStorage.getInstance().reference.child(reference)
                  storageReference.downloadUrl.addOnSuccessListener { uri -> Glide.with(context)
                      .load(uri)
                      //.centerCrop()
                      .into(mImage) }
      

      reference 是一个文件名的字符串

      分级:

      compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
      annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
      compile 'com.firebaseui:firebase-ui:2.0.1'
      

      【讨论】:

      • 欢迎来到 Stack Overflow!虽然这段代码 sn-p 可以解决问题,但including an explanation 确实有助于提高帖子的质量。请记住,您正在为将来的读者回答问题,而这些人可能不知道您的代码建议的原因。也请尽量不要用解释性的 cmets 挤满你的代码,这会降低代码和解释的可读性!
      猜你喜欢
      • 2018-11-21
      • 2018-08-13
      • 2018-10-29
      • 2017-01-12
      • 1970-01-01
      • 2017-12-01
      • 2018-10-30
      • 1970-01-01
      • 2020-04-20
      相关资源
      最近更新 更多