mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-27 23:49:40 +01:00
Fix avatar loading for conversations list
This commit is contained in:
parent
312570e51c
commit
2ec45391de
@ -73,6 +73,7 @@ import com.nextcloud.talk.models.database.UserEntity;
|
|||||||
import com.nextcloud.talk.models.json.participants.Participant;
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
import com.nextcloud.talk.models.json.rooms.Conversation;
|
import com.nextcloud.talk.models.json.rooms.Conversation;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
import com.nextcloud.talk.utils.KeyboardUtils;
|
import com.nextcloud.talk.utils.KeyboardUtils;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
@ -191,27 +192,28 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadUserAvatar(MenuItem menuItem) {
|
private void loadUserAvatar(MenuItem menuItem) {
|
||||||
int avatarSize = menuItem.getIcon().getIntrinsicHeight();
|
if (getActivity() != null) {
|
||||||
|
int avatarSize = (int) DisplayUtils.convertDpToPixel(menuItem.getIcon().getIntrinsicHeight(), getActivity());
|
||||||
|
|
||||||
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(currentUser.getBaseUrl(),
|
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithNameAndPixels(currentUser.getBaseUrl(),
|
||||||
currentUser.getUserId(), R.dimen.avatar_size), new LazyHeaders.Builder()
|
currentUser.getUserId(), avatarSize), new LazyHeaders.Builder()
|
||||||
.setHeader("Accept", "image/*")
|
.setHeader("Accept", "image/*")
|
||||||
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
menuItem.getActionView().getima
|
GlideApp.with(getActivity())
|
||||||
GlideApp.with(getActivity())
|
.asBitmap()
|
||||||
.asBitmap()
|
.centerInside()
|
||||||
.centerInside()
|
.override(avatarSize, avatarSize)
|
||||||
.override(avatarSize, avatarSize)
|
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||||
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
.load(glideUrl)
|
||||||
.load(glideUrl)
|
.into(new SimpleTarget<Bitmap>() {
|
||||||
.into(new SimpleTarget<Bitmap>() {
|
@Override
|
||||||
@Override
|
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
menuItem.setIcon(new BitmapDrawable(resource));
|
||||||
menuItem.setIcon(new BitmapDrawable(resource));
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -219,10 +221,7 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
super.onAttach(view);
|
super.onAttach(view);
|
||||||
eventBus.register(this);
|
eventBus.register(this);
|
||||||
|
|
||||||
UserEntity tempUser;
|
currentUser = userUtils.getCurrentUser();
|
||||||
if (currentUser != (tempUser = userUtils.getCurrentUser())) {
|
|
||||||
currentUser = tempUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
credentials = ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken());
|
credentials = ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken());
|
||||||
|
@ -195,6 +195,10 @@ public class ApiUtils {
|
|||||||
return "/status.php";
|
return "/status.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUrlForAvatarWithNameAndPixels(String baseUrl, String name, int avatarSize) {
|
||||||
|
return baseUrl + "/index.php/avatar/" + Uri.encode(name) + "/" + avatarSize;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getUrlForAvatarWithName(String baseUrl, String name, @DimenRes int avatarSize) {
|
public static String getUrlForAvatarWithName(String baseUrl, String name, @DimenRes int avatarSize) {
|
||||||
avatarSize = Math.round(NextcloudTalkApplication
|
avatarSize = Math.round(NextcloudTalkApplication
|
||||||
.getSharedApplication().getResources().getDimension(avatarSize));
|
.getSharedApplication().getResources().getDimension(avatarSize));
|
||||||
|
Loading…
Reference in New Issue
Block a user