瀏覽代碼

Fix contacts list

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 年之前
父節點
當前提交
a11bf58bac

+ 4 - 2
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<UserItem.UserItemViewHolder>
 
         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<UserItem.UserItemViewHolder>
                         .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()

+ 5 - 6
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();
                                 }