Kaynağa Gözat

fix lint and spotbugs warnings

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 yıl önce
ebeveyn
işleme
a7792cb66e

+ 3 - 3
app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.java

@@ -199,7 +199,7 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
             holder.pinnedConversationImageView.setVisibility(View.GONE);
         }
 
-        if (!Conversation.ConversationType.ROOM_SYSTEM.equals(conversation.getType())) {
+        if (Conversation.ConversationType.ROOM_SYSTEM != conversation.getType()) {
             float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, appContext);
             holder.userStatusImage.setImageDrawable(new StatusDrawable(
                 status != null ? status.getStatus() : "",
@@ -214,13 +214,13 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
             holder.dialogDate.setText(DateUtils.getRelativeTimeSpanString(conversation.getLastActivity() * 1000L,
                                                                           System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
 
-            if (!TextUtils.isEmpty(conversation.getLastMessage().getSystemMessage()) || Conversation.ConversationType.ROOM_SYSTEM.equals(conversation.getType())) {
+            if (!TextUtils.isEmpty(conversation.getLastMessage().getSystemMessage()) || Conversation.ConversationType.ROOM_SYSTEM == conversation.getType()) {
                 holder.dialogLastMessage.setText(conversation.getLastMessage().getText());
             } else {
                 String authorDisplayName = "";
                 conversation.getLastMessage().setActiveUser(userEntity);
                 String text;
-                if (conversation.getLastMessage().getMessageType().equals(ChatMessage.MessageType.REGULAR_TEXT_MESSAGE)) {
+                if (conversation.getLastMessage().getMessageType() == ChatMessage.MessageType.REGULAR_TEXT_MESSAGE) {
                     if (conversation.getLastMessage().getActorId().equals(userEntity.getUserId())) {
                         text = String.format(appContext.getString(R.string.nc_formatted_message_you),
                                              conversation.getLastMessage().getLastMessageDisplayText());

+ 3 - 0
app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.java

@@ -174,7 +174,10 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
             holder.participantAvatar.setController(draweeController);
         }
 
+        drawStatus(holder);
+    }
 
+    private void drawStatus(UserItem.UserItemViewHolder holder) {
         if (holder.statusMessage != null && holder.participantEmoji != null && holder.userStatusImage != null) {
             float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
             holder.userStatusImage.setImageDrawable(new StatusDrawable(

+ 38 - 32
app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java

@@ -124,7 +124,9 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
     @Override
     public void bindViewHolder(FlexibleAdapter adapter, UserItemViewHolder holder, int position, List payloads) {
 
-        holder.participantAvatar.setController(null);
+        if (holder.participantAvatar != null) {
+            holder.participantAvatar.setController(null);
+        }
 
         if (holder.checkedImageView != null) {
             if (participant.isSelected()) {
@@ -134,37 +136,7 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
             }
         }
 
-        if (holder.statusMessage != null && holder.participantEmoji != null && holder.userStatusImage != null) {
-            float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
-            holder.userStatusImage.setImageDrawable(new StatusDrawable(
-                participant.status,
-                NO_ICON,
-                size,
-                context.getResources().getColor(R.color.bg_default),
-                context));
-
-            if (participant.statusMessage != null) {
-                holder.statusMessage.setText(participant.statusMessage);
-            } else {
-                holder.statusMessage.setText("");
-            }
-
-            if (participant.statusIcon != null && !participant.statusIcon.isEmpty()) {
-                holder.participantEmoji.setText(participant.statusIcon);
-            } else {
-                holder.participantEmoji.setVisibility(View.GONE);
-            }
-
-            if (participant.status != null && participant.status.equals(StatusType.DND.getString())) {
-                if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
-                    holder.statusMessage.setText(R.string.dnd);
-                }
-            } else if (participant.status != null && participant.status.equals(StatusType.AWAY.getString())) {
-                if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
-                    holder.statusMessage.setText(R.string.away);
-                }
-            }
-        }
+        drawStatus(holder);
 
         if (!isOnline) {
             holder.contactDisplayName.setTextColor(ResourcesCompat.getColor(
@@ -294,6 +266,40 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
         }
     }
 
+    private void drawStatus(UserItemViewHolder holder) {
+        if (holder.statusMessage != null && holder.participantEmoji != null && holder.userStatusImage != null) {
+            float size = DisplayUtils.convertDpToPixel(STATUS_SIZE_IN_DP, context);
+            holder.userStatusImage.setImageDrawable(new StatusDrawable(
+                participant.status,
+                NO_ICON,
+                size,
+                context.getResources().getColor(R.color.bg_default),
+                context));
+
+            if (participant.statusMessage != null) {
+                holder.statusMessage.setText(participant.statusMessage);
+            } else {
+                holder.statusMessage.setText("");
+            }
+
+            if (participant.statusIcon != null && !participant.statusIcon.isEmpty()) {
+                holder.participantEmoji.setText(participant.statusIcon);
+            } else {
+                holder.participantEmoji.setVisibility(View.GONE);
+            }
+
+            if (participant.status != null && participant.status.equals(StatusType.DND.getString())) {
+                if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
+                    holder.statusMessage.setText(R.string.dnd);
+                }
+            } else if (participant.status != null && participant.status.equals(StatusType.AWAY.getString())) {
+                if (participant.statusMessage == null || participant.statusMessage.isEmpty()) {
+                    holder.statusMessage.setText(R.string.away);
+                }
+            }
+        }
+    }
+
     @Override
     public boolean filter(String constraint) {
         return participant.getDisplayName() != null &&

+ 0 - 1
app/src/main/res/values/strings.xml

@@ -459,7 +459,6 @@
     <string name="starred">Favorite</string>
     <string name="user_status">Status</string>
     <string name="encrypted">Encrypted</string>
-    <string name="password_protected">Password protected</string>
 
     <string name="avatar">Avatar</string>
     <string name="account_icon">Account icon</string>