2017-08-12 22 views
1

Firebase UIのGlideを使用してImageViewをFirebase Storageにリンクしています。今は正常に動作しますが、Imは現在、ユーザーが自分のProfileimageを変更できるアップデートを実装しています。imagenameとpathは同じままです。私の英語は、Glideからのドキュメントを理解するのに弱いですか、単にGlideによる更新を認識する方法ではありません。私はここで要求について何かを読んでhttp://bumptech.github.io/glide/doc/options.htmlしかし、私はそれを把握できません。私はイライラしてみました以下のコードでは、Firebase UI - View doesnt Update

Glide.with(getContext()) 
      .using(new FirebaseImageLoader()) 
      .load(profileRef) 
      .into(this.imgProfile); 

が、画像を更新するためにグライドを伝える方法を知らない:機能のonCreateを呼び出す

this.profileRef = this.mStorageRef.child("images").child(FirebaseAuth.getInstance() 
      .getCurrentUser().getUid()).child("Profile"); 

:REF権を設定し

グライドを再び設定するには、待っていたので、何もしなかったので、ImageViewはまだキャッシュ画像をロードしています。 Glide.clear(view)を試しても何も起こりません。たぶん、誰かがこの問題に直面して、すでに私を助けることができます。

profileRef.putFile(file).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { 
       @Override 
       public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { 
        Glide.with(getContext()) 
          .using(new FirebaseImageLoader()) 
          .load(profileRef) 
          .into(imgProfile); 
       } 
      }); 

答えて

0

しばらくしてから解決しました。 Glide cantは、名前が変わらないか、URLが同じであれば変更を認識します。だからあなたはあなたの写真に署名を​​付けることによってキャッシュを無効にする必要があります。ここではそれについての詳細を読む https://github.com/bumptech/glide/wiki/Caching-and-Cache-Invalidation

Glide.with(getContext() /* context */) 
      .using(new FirebaseImageLoader()) 
      .load(profileRef) 
      .signature(new StringSignature(getCurrentTimeStamp())) 
      .into(this.imgHeader); 

public static String getCurrentTimeStamp(){ 
    try { 

     SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
     String currentDateTime = dateFormat.format(new Date()); // Find todays date 

     return currentDateTime; 
    } catch (Exception e) { 
     e.printStackTrace(); 

     return null; 
    } 
+0

訂正:私は、SharedPreferencesにUUIDで)バージョン管理のその種をgetCurrentTimeStampを(置き換えます。上記のコードでは、Glideは常に写真をダウンロードしているので、私はそれをしました! – niksn