使用SwipeRefreshLayout進行刷新時,我執行了以下代碼。這應該加載新的配置文件圖片,但它看起來舊的圖像緩存在設備上。當我退出應用程序並返回活動時,新的個人資料圖片可用。但清爽並不能解決這個問題。我能在這裏做什麼?從Web服務加載數據後清除Picasso圖像緩存
刷卡:
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);
}
}
});
}
從parse檢索資料圖片:
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
上面,因爲我下載圖像來自網絡。但也許這不是我應該做的?
我認爲''Network.OFFLINE''應該是''NetworkPolicy.OFFLINE'',否則解決我的問題。乾杯。 – santafebound
是啊,對不起,我只是輸入簡單的記事本,所以沒有編輯器來尋找我的錯誤。 –