2017-05-11 20 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)確實有助於提高您的帖子的質量。請記住,您將來會爲讀者回答問題,而這些人可能不知道您的代碼建議的原因。也請儘量不要用解釋性註釋來擠佔代碼,這會降低代碼和解釋的可讀性! –