Java 从web服务加载数据后刷新时清除毕加索图像缓存

Java 从web服务加载数据后刷新时清除毕加索图像缓存,java,android,parse-platform,picasso,Java,Android,Parse Platform,Picasso,在使用SwipeRefreshLayout刷新时,我执行了以下代码。这将加载新的配置文件图片,但旧图像似乎以某种方式缓存在设备上。当我退出应用程序并返回活动时,新的个人资料图片可用。但提神并不能解决这个问题。我能在这里做什么 刷卡: private void setSwipeRefreshLayout(boolean isOnline, String userId) { mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById

在使用SwipeRefreshLayout刷新时,我执行了以下代码。这将加载新的配置文件图片,但旧图像似乎以某种方式缓存在设备上。当我退出应用程序并返回活动时,新的个人资料图片可用。但提神并不能解决这个问题。我能在这里做什么

刷卡:

private void setSwipeRefreshLayout(boolean isOnline, String userId) {
        mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
        mSwipeRefreshLayout.setOnRefreshListener(() -> {
            if (!isOnline) {
                mSwipeRefreshLayout.setRefreshing(false);
            } else {
                if (mSwipeRefreshLayout.isRefreshing()) {
                    mSwipeRefreshLayout.setRefreshing(false);
                }

                if (userId != null && userId.equals(ParseUser.getCurrentUser().getObjectId())) {
                    createProfileHeader(userId);
                    Picasso.with(getApplicationContext()).invalidate(imagePath);
                }

            }
        });
    }
if (headerUserObject.getParseFile("profilePicture") != null) {

    Picasso.with(getApplicationContext())
            .load(headerUserObject.getParseFile("profilePicture").getUrl())
            .placeholder(R.color.placeholderblue)
            .into(((ImageView) findViewById(R.id.profile_picture)));

    fadeInProfilePicture();
}
从解析中检索配置文件图片:

private void setSwipeRefreshLayout(boolean isOnline, String userId) {
        mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
        mSwipeRefreshLayout.setOnRefreshListener(() -> {
            if (!isOnline) {
                mSwipeRefreshLayout.setRefreshing(false);
            } else {
                if (mSwipeRefreshLayout.isRefreshing()) {
                    mSwipeRefreshLayout.setRefreshing(false);
                }

                if (userId != null && userId.equals(ParseUser.getCurrentUser().getObjectId())) {
                    createProfileHeader(userId);
                    Picasso.with(getApplicationContext()).invalidate(imagePath);
                }

            }
        });
    }
if (headerUserObject.getParseFile("profilePicture") != null) {

    Picasso.with(getApplicationContext())
            .load(headerUserObject.getParseFile("profilePicture").getUrl())
            .placeholder(R.color.placeholderblue)
            .into(((ImageView) findViewById(R.id.profile_picture)));

    fadeInProfilePicture();
}
我不确定如何获得上面的
imagePath
,因为我是从互联网下载图像的。但也许这不是我应该做的事?

试试这个

 Picasso.memoryPolicy(MemoryPolicy.NO_CACHE).into(image);
试试这个

 Picasso.memoryPolicy(MemoryPolicy.NO_CACHE).into(image);

下面是我的代码,它将首先从缓存加载图像(如果该文件的缓存存在),然后更新缓存文件。如果它不存在,则从internet(url)加载它


下面是我的代码,它将首先从缓存加载图像(如果该文件的缓存存在),然后更新缓存文件。如果它不存在,则从internet(url)加载它


我认为
Network.OFFLINE
应该是
NetworkPolicy.OFFLINE
,否则就解决了我的问题。干杯。是的,对不起,我只是在普通的记事本中键入,所以没有编辑器来查找我的错误。我认为
Network.OFFLINE
应该是
NetworkPolicy.OFFLINE
,否则就解决了我的问题。干杯。是的,对不起,我只是在普通的记事本上打字,所以没有编辑器来查找我的错误。