毕加索作废无效

时间:2018-06-20 06:54:01

标签: android picasso

我正在使用毕加索在应用程序中加载图像。这是我正在使用的代码:

  if(!USE_MEMORY_CACHE)
                {
                    picasso.invalidate(url);
                }
                RequestCreator request = picasso.load(url);
                if (drawableWhileLoading != null) {
                    request.placeholder(drawableWhileLoading);
                }
                if (drawableOnFailure != null) {
                    request.error(drawableOnFailure);
                }
                request.config(BITMAP_CONFIG);
                request.networkPolicy(NetworkPolicy.OFFLINE);
                if (!USE_MEMORY_CACHE) {
                    request.memoryPolicy(MemoryPolicy.NO_CACHE);
                    request.networkPolicy(NetworkPolicy.OFFLINE,NetworkPolicy.NO_CACHE);
                }
                String finalUrl = url;
                request.into(imageView, new Callback() {
                    @Override
                    public void onSuccess() {
                        Log.d(TAG, "Image loaded successfully from Disk, url = " + finalUrl);
                    }

                    @Override
                    public void onError() {
                        Log.d(TAG, "Image could not be loaded from Disk, lets try network. url = " + finalUrl);
                        RequestCreator secondRequest = picasso.load(finalUrl);
                        if (drawableWhileLoading != null) {
                            secondRequest.placeholder(drawableWhileLoading);
                        }
                        if (drawableOnFailure != null) {
                            secondRequest.error(drawableOnFailure);
                        }
                        secondRequest.config(BITMAP_CONFIG);
                        if (!USE_MEMORY_CACHE) {
                            secondRequest.memoryPolicy(MemoryPolicy.NO_CACHE);
                        }
                        secondRequest.into(imageView);
                    }
                });

但是我面临的问题是,即使服务器上的图像已更改并且我正在使用picasso.invalidate(url),它仍显示旧图像。

0 个答案:

没有答案