2016-03-21 47 views
2

私は画像を表示するためにGlideライブラリを使用しています。画像が消去されないようにdiskCacheStrategy(DiskCacheStrategy.Source)を設定しました。プロファイルの画像を更新すると、画像が更新されません。 clearDiskCacheとGlide.clearMemory())。それでは、どのように、より良く理解グライドを使って画像を強制的にリフレッシュする方法は?

if(!getBoolValueForProfilePicUploading()) 
    {  glide.with(context).load(imgData.url).asBitmap().centerCrop().diskCacheStrategy(DiskCacheStrategy.SOURCE).placeholder(R.drawable.default_profilepic).error(R.drawable.default_profilepic).into(new BitmapImageViewTarget(userImageView) { 
        @Override 
        protected void setResource(Bitmap resource) { 
         RoundedBitmapDrawable circularBitmapDrawable = 
           RoundedBitmapDrawableFactory.create(context.getResources(), resource); 
         circularBitmapDrawable.setCircular(true); 
         userImageView.setImageDrawable(circularBitmapDrawable); 
        } 
       }); 
      }else 
      { 
       new LongOperation(context,imgData,userImageView).execute(); 
      } 

これはasynctask背景()のためであるために以下のコードを参照しなさいインスタンスをクリアせずに画像をリフレッシュ強制的に

protected String doInBackground(String... params) { 
       try 
       { 
        Glide.get(context).clearDiskCache(); 
        Glide.get(context).clearMemory(); 
       }catch (Exception e) 
       { 
        e.printStackTrace(); 
       } 

       return null; 
      } 
+1

あなたは 'skipMemoryCache()'を試しましたか? –

+0

いいえ。返信いただきありがとうございます。私は確認してからuに戻ります。 – Ajay

+0

メソッドのクラス名は何ですか – Ajay

答えて

1

私は試しました

avatar.setImageURI(null); 
avatar.setImageURI(avatarUri); 

しかし、skipMemoryCache()保存された私の日。

関連する問題