mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-28 08:00:19 +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,15 +192,15 @@ 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()
|
||||||
@ -213,16 +214,14 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAttach(@NonNull View view) {
|
protected void onAttach(@NonNull View view) {
|
||||||
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