From a11bf58bac4b0f36d3e3b45f897b0741ce8e7ad8 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Wed, 21 Nov 2018 23:51:31 +0100 Subject: [PATCH] Fix contacts list Signed-off-by: Mario Danic --- .../com/nextcloud/talk/adapters/items/UserItem.java | 6 ++++-- .../talk/controllers/ContactsController.java | 11 +++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java index 8b9ea11aa..d627e68e0 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java @@ -21,6 +21,7 @@ package com.nextcloud.talk.adapters.items; import android.text.TextUtils; +import android.util.Log; import android.view.View; import android.widget.TextView; @@ -139,7 +140,8 @@ public class UserItem extends AbstractFlexibleItem if (TextUtils.isEmpty(participant.getSource()) || participant.getSource().equals("users")) { - if (participant.getType().equals(Participant.ParticipantType.GUEST) || participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK)) { + if (Participant.ParticipantType.GUEST.equals(participant.getType()) || + Participant.ParticipantType.USER_FOLLOWING_LINK.equals(participant.getType())) { // TODO: Show generated avatar for guests } else { GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(), @@ -157,7 +159,7 @@ public class UserItem extends AbstractFlexibleItem .apply(RequestOptions.bitmapTransform(new CircleCrop())) .into(flipView.getFrontImageView()); } - } else if (participant.getSource().equals("groups")) { + } else if ("groups".equals(participant.getSource())) { GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()) .asBitmap() diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index a3a048674..e42d65b07 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java @@ -523,7 +523,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ for (Sharee sharee : shareeHashSet) { if (!sharee.getValue().getShareWith().equals(currentUser.getUserId())) { participant = new Participant(); - participant.setName(sharee.getLabel()); + participant.setDisplayName(sharee.getLabel()); String headerTitle; headerTitle = sharee.getLabel().substring(0, 1).toUpperCase(); @@ -554,14 +554,14 @@ public class ContactsController extends BaseController implements SearchView.OnQ for (AutocompleteUser autocompleteUser : autocompleteUsersHashSet) { if (!autocompleteUser.getId().equals(currentUser.getUserId())) { participant = new Participant(); - participant.setName(autocompleteUser.getLabel()); participant.setUserId(autocompleteUser.getId()); + participant.setDisplayName(autocompleteUser.getLabel()); participant.setSource(autocompleteUser.getSource()); String headerTitle; if (!autocompleteUser.getSource().equals("groups")) { - headerTitle = participant.getName().substring(0, 1).toUpperCase(); + headerTitle = participant.getDisplayName().substring(0, 1).toUpperCase(); } else { headerTitle = getResources().getString(R.string.nc_groups); } @@ -572,7 +572,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ userHeaderItems.put(headerTitle, genericTextHeaderItem); } - participant.setUserId(participant.getUserId()); UserItem newContactItem = new UserItem(participant, currentUser, userHeaderItems.get(headerTitle)); @@ -611,13 +610,13 @@ public class ContactsController extends BaseController implements SearchView.OnQ if (o1 instanceof UserItem) { - firstName = ((UserItem) o1).getModel().getName(); + firstName = ((UserItem) o1).getModel().getDisplayName(); } else { firstName = ((GenericTextHeaderItem) o1).getModel(); } if (o2 instanceof UserItem) { - secondName = ((UserItem) o2).getModel().getName(); + secondName = ((UserItem) o2).getModel().getDisplayName(); } else { secondName = ((GenericTextHeaderItem) o2).getModel(); }