2017-05-11 61 views
1

因此,我有一个从Firebase存储加载图片的recyclerview。我使用Glide库与FirebaseImageLoader配合实现此目的。在过去的星期一之前,所有工作都很顺利。图片不显示了,没有错误,异常或东西来帮助我弄清楚为什么图像将不会加载了:这里有一些代码段:Firebase存储用户界面和滑动不显示图像

摇篮:

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"/> 
该构建火力地堡存储链接

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); 

P.S.这段代码一直工作得很好,从不改变我向上帝发誓的任何事情。我所做的只是更新我的Android Studio到2.3.1并更新谷歌支持库到25.3.1

回答

2

我设法整理出来。如果有人遇到同样的问题,如果您最近将其更新至10.2.4,则还原为Firebase SDK版本10.2.1,但似乎存在最新SDK的错误。

一切都很好

2

我在科特林解决方案:

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

参考与文件

摇篮的名称的字符串:

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' 
+0

欢迎堆栈溢出!尽管这段代码可以解决这个问题,但[包括一个解释](// meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)确实有助于提高您的帖子的质量。请记住,您将来会为读者回答问题,而这些人可能不知道您的代码建议的原因。也请尽量不要用解释性注释来挤占代码,这会降低代码和解释的可读性! –