我想使用simple drawee
库从Fresco
删除缓存,因为如果从image
更改server
,则仍会在simple drawee
中显示旧图像。以下是我的代码。
public class FrescoSimpleDraweeActivity extends Activity {
private SimpleDraweeView simpleDraweeView1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fresco.initialize(this);
setContentView(R.layout.activity_fresco_simple_drawee);
Log.e("Fresco simple activity ","is calling...");
simpleDraweeView1 = (SimpleDraweeView) findViewById(R.id.simpleDraweeView1);
Uri imageUri = Uri.parse("http://i.imgur.com/76Jfv9b.jpg");
// simpleDraweeView1.setImageURI(imageUri);
//If we used to load image from network then use it otherwiese not.
// return immidiate result if thumb store using (.setProgressiveRenderingEnabled(true)) (only local URI)
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(imageUri)
.setProgressiveRenderingEnabled(true)
.setLocalThumbnailPreviewsEnabled(true)
.build();
ControllerListener listener = new BaseControllerListener();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(imageUri)
.setImageRequest(request)
.setTapToRetryEnabled(true)
.setOldController(simpleDraweeView1.getController())
.setControllerListener(listener)
.setTapToRetryEnabled(true)
.build();
simpleDraweeView1.setController(controller);
}
}
这是我的xml代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activity.Fresco.FrescoSimpleDraweeActivity">
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="This is Fresco Drawee Example" />
<!--fresco:failureImage="@drawable/failure"-->
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/simpleDraweeView1"
android:layout_width="200dp"
android:layout_height="200dp"
fresco:failureImage="@drawable/failure"
fresco:progressBarImage="@drawable/progress"
fresco:progressBarImageScaleType="centerInside"
fresco:roundAsCircle="true"
fresco:roundBottomLeft="true"
fresco:roundBottomRight="true"
fresco:roundTopLeft="true"
fresco:roundTopRight="true"
fresco:roundedCornerRadius="50dp"
fresco:roundingBorderColor="@color/red"
fresco:roundingBorderWidth="2dp"
fresco:retryImage="@drawable/retry"
fresco:retryImageScaleType="centerCrop"
fresco:actualImageScaleType="centerCrop"
android:layout_below="@+id/tvTitle"
/>
<!--for round image border use below-->
<!--fresco:roundedCornerRadius="50dp"-->
<!--fresco:roundTopLeft="true"-->
<!--fresco:roundTopRight="true"-->
<!--fresco:roundBottomLeft="true"-->
<!--fresco:roundBottomRight="true"-->
</RelativeLayout>
答案 0 :(得分:0)
@Sakib Syed您可以尝试使用此代码,希望这可以帮助您。
ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.clearMemoryCaches();
imagePipeline.clearDiskCaches();
//结合以上两行
imagePipeline.clearCaches();