mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
Clear cached avatar
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
6fb5d3f9bb
commit
43108661e9
@ -245,8 +245,10 @@ public class ProfileController extends BaseController {
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull GenericOverall genericOverall) {
|
||||
DisplayUtils.loadAvatarImage(currentUser,
|
||||
getActivity().findViewById(R.id.avatar_image));
|
||||
DisplayUtils.loadAvatarImage(
|
||||
currentUser,
|
||||
getActivity().findViewById(R.id.avatar_image),
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -300,7 +302,7 @@ public class ProfileController extends BaseController {
|
||||
.findViewById(R.id.userinfo_baseurl))
|
||||
.setText(Uri.parse(currentUser.getBaseUrl()).getHost());
|
||||
|
||||
DisplayUtils.loadAvatarImage(currentUser, getActivity().findViewById(R.id.avatar_image));
|
||||
DisplayUtils.loadAvatarImage(currentUser, getActivity().findViewById(R.id.avatar_image), false);
|
||||
|
||||
if (!TextUtils.isEmpty(userInfo.getDisplayName())) {
|
||||
((TextView) getActivity().findViewById(R.id.userinfo_fullName)).setText(userInfo.getDisplayName());
|
||||
@ -591,7 +593,7 @@ public class ProfileController extends BaseController {
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull GenericOverall genericOverall) {
|
||||
DisplayUtils.loadAvatarImage(currentUser, getActivity().findViewById(R.id.avatar_image));
|
||||
DisplayUtils.loadAvatarImage(currentUser, getActivity().findViewById(R.id.avatar_image), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -562,7 +562,7 @@ public class SettingsController extends BaseController {
|
||||
displayNameTextView.setText(currentUser.getDisplayName());
|
||||
}
|
||||
|
||||
DisplayUtils.loadAvatarImage(currentUser, avatarImageView);
|
||||
DisplayUtils.loadAvatarImage(currentUser, avatarImageView, false);
|
||||
|
||||
profileQueryDisposable = ncApi.getUserProfile(credentials,
|
||||
ApiUtils.getUrlForUserProfile(currentUser.getBaseUrl()))
|
||||
|
@ -534,7 +534,7 @@ public class DisplayUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadAvatarImage(UserEntity user, SimpleDraweeView avatarImageView) {
|
||||
public static void loadAvatarImage(UserEntity user, SimpleDraweeView avatarImageView, boolean deleteCache) {
|
||||
String avatarId;
|
||||
if (!TextUtils.isEmpty(user.getUserId())) {
|
||||
avatarId = user.getUserId();
|
||||
@ -542,11 +542,21 @@ public class DisplayUtils {
|
||||
avatarId = user.getUsername();
|
||||
}
|
||||
|
||||
// clear cache
|
||||
if (deleteCache) {
|
||||
String avatarString = ApiUtils.getUrlForAvatarWithName(user.getBaseUrl(), avatarId, R.dimen.avatar_size_big);
|
||||
Uri avatarUri = Uri.parse(avatarString);
|
||||
|
||||
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
||||
imagePipeline.evictFromMemoryCache(avatarUri);
|
||||
imagePipeline.evictFromDiskCache(avatarUri);
|
||||
imagePipeline.evictFromCache(avatarUri);
|
||||
}
|
||||
|
||||
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
||||
.setOldController(avatarImageView.getController())
|
||||
.setAutoPlayAnimations(true)
|
||||
.setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(user.getBaseUrl(),
|
||||
avatarId, R.dimen.avatar_size_big), null))
|
||||
.setImageRequest(DisplayUtils.getImageRequestForUrl(avatarString, null))
|
||||
.build();
|
||||
avatarImageView.setController(draweeController);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user