Android-ImageLoader => 当我从服务器调用同名图像时,imageLoader 从缓存中获取旧图像。我该如何解决?

Android-ImageLoader => When I call image with the same name from server, imageLoader takes older one from Cache. How can I fix it?

首先我的静态配置文件是这样的:

public static DisplayImageOptions getDisplayImageOptions(){
    options = new DisplayImageOptions.Builder()
            .showImageForEmptyUri(R.mipmap.ic_empty)
            .showImageOnFail(R.mipmap.ic_error)
            .resetViewBeforeLoading(true)
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .imageScaleType(ImageScaleType.EXACTLY)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(300))
            .build();
    return options;
}

public static ImageLoaderConfiguration getImageLoaderConfiguration(Context context){
    config = new ImageLoaderConfiguration.Builder(context)
            .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
            .diskCacheExtraOptions(480, 800, null)
            .threadPriority(Thread.NORM_PRIORITY - 2) // default
            .tasksProcessingOrder(QueueProcessingType.FIFO) // default
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .memoryCacheSizePercentage(13) // default
            .diskCacheSize(50 * 1024 * 1024)
            .diskCacheFileCount(100)
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
            .writeDebugLogs()
            .build();

    return config;
}

我的服务器包含名为:example.jpg 的图像 当我从 android 应用程序调用时,没有任何问题。但是如果我用另一个图像更改这个图像并且它的名称是相同的(example.jpg),当我再次调用这个图像时,我的 android 应用程序会得到旧的(缓存的)图像。

我认为 imageLoader 必须理解缓存图像和服务器图像是不同的,即使它们具有相同的名称。但是我想不通。

我该如何解决?

    imageLoader = ImageLoader.getInstance();
    ImageLoaderConfiguration config = ConfigFile.getImageLoaderConfiguration(getActivity());
    ImageLoader.getInstance().init(config);

    imageLoader.displayImage(newImageUrl, editProfileImageView, ConfigFile.getDisplayImageOptions(), new ImageLoadingListener() {
        @Override
        public void onLoadingStarted(String imageUri, View view) {

        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {

        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {

        }
    }, new ImageLoadingProgressListener() {
        @Override
        public void onProgressUpdate(String imageUri, View view, int current, int total) {

        }
    });

DisplayImageOptions 配置中设置 cacheOnDisk(false)cacheInMemory(false) 以加载图像的动态特性。

例如:

imageLoader = ImageLoader.getInstance();
ImageLoaderConfiguration config = ConfigFile.getImageLoaderConfiguration(getActivity());
ImageLoader.getInstance().init(config);

DisplayImageOptions options = ConfigFile.getDisplayImageOptions();
options.cacheOnDisk(false);
options.cacheInMemory(false);



imageLoader.displayImage(newImageUrl, editProfileImageView, options, new ImageLoadingListener() {
    @Override
    public void onLoadingStarted(String imageUri, View view) {

    }

    @Override
    public void onLoadingFailed(String imageUri, View view, FailReason failReason) {

    }

    @Override
    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {

    }

    @Override
    public void onLoadingCancelled(String imageUri, View view) {

    }
}, new ImageLoadingProgressListener() {
    @Override
    public void onProgressUpdate(String imageUri, View view, int current, int total) {

    }
});