gpt4 book ai didi

android - 如何从 Fresco Simple drawee 中删除缓存

转载 作者:行者123 更新时间:2023-11-29 01:15:36 28 4
gpt4 key购买 nike

我想使用 Fresco 库从 simple drawee 中删除缓存,因为如果 imageserver 更改然后仍然在 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>

最佳答案

@Sakib Syed 你可以试试这个代码希望这能帮助你。

    ImagePipeline imagePipeline = Fresco.getImagePipeline();
imagePipeline.clearMemoryCaches();
imagePipeline.clearDiskCaches();

//合并以上两行

    imagePipeline.clearCaches();

关于android - 如何从 Fresco Simple drawee 中删除缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39901525/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com