Przeglądaj źródła

会话列表与结构微调

xuqm 1 rok temu
rodzic
commit
ef3e5bb0bc

+ 1 - 1
SzyxImSdk/src/main/java/cn/org/bjca/trust/android/lib/im/im/manager/ImManager.java

@@ -268,7 +268,7 @@ public class ImManager implements IMInterface {
         szyxMessage.setDescribe(describe);
         szyxMessage.setGroup(isGroup);
         szyxMessage.setStatus(1);
-        szyxMessage.setFromClient(UserManager.getInstance().getUserInfoForMsg());
+        szyxMessage.setFromClientId(Constant.getUserId());
         if (isGroup)
             szyxMessage.setGroupID(toUserId);
         else

+ 6 - 16
SzyxImSdk/src/main/java/cn/org/bjca/trust/android/lib/im/im/msg/ConversationMessage.java

@@ -18,8 +18,7 @@ public class ConversationMessage extends PacketMessage {
     private SZYXMessage message;
 
     private GroupInfo groupEntity;
-    private UserInfo userInfo;
-    private UserInfo self;
+    private String userId;
 
     public ConversationMessage(PacketType packetType) {
         super(packetType);
@@ -57,20 +56,12 @@ public class ConversationMessage extends PacketMessage {
         this.groupEntity = groupEntity;
     }
 
-    public UserInfo getUserInfo() {
-        return userInfo;
+    public String getUserId() {
+        return userId;
     }
 
-    public void setUserInfo(UserInfo userInfo) {
-        this.userInfo = userInfo;
-    }
-
-    public UserInfo getSelf() {
-        return self;
-    }
-
-    public void setSelf(UserInfo self) {
-        this.self = self;
+    public void setUserId(String userId) {
+        this.userId = userId;
     }
 
     @Override
@@ -80,8 +71,7 @@ public class ConversationMessage extends PacketMessage {
                 ", isGroup=" + isGroup +
                 ", message=" + message +
                 ", groupEntity=" + groupEntity +
-                ", userInfo=" + userInfo +
-                ", self=" + self +
+                ", userId=" + userId +
                 '}';
     }
 }

+ 6 - 6
SzyxImSdk/src/main/java/cn/org/bjca/trust/android/lib/im/im/msg/message/SZYXMessage.java

@@ -17,7 +17,7 @@ public class SZYXMessage extends PacketMessage {
     /**
      * 发送者信息
      */
-    private UserInfo fromClient;
+    private String fromClientId;
     /**
      * 接收者信息
      */
@@ -48,12 +48,12 @@ public class SZYXMessage extends PacketMessage {
     private MsgType msgType;
     private SZYXTextMessage textMessage;
 
-    public UserInfo getFromClient() {
-        return fromClient;
+    public String getFromClientId() {
+        return fromClientId;
     }
 
-    public void setFromClient(UserInfo fromClient) {
-        this.fromClient = fromClient;
+    public void setFromClientId(String fromClientId) {
+        this.fromClientId = fromClientId;
     }
 
     public String getToClientId() {
@@ -124,7 +124,7 @@ public class SZYXMessage extends PacketMessage {
     @Override
     public String toString() {
         return "SZYXMessage{" +
-                "fromClient=" + fromClient +
+                "fromClient=" + fromClientId +
                 ", toClientId='" + toClientId + '\'' +
                 ", groupID='" + groupID + '\'' +
                 ", describe='" + describe + '\'' +

+ 2 - 2
app/src/main/java/cn/org/bjca/trust/android/imdemo/ui/adapter/ChatAdapter.java

@@ -34,8 +34,8 @@ public class ChatAdapter extends BaseNormalAdapter<SZYXMessage> {
 
             @Override
             public void convert(ViewHolder holder, SZYXMessage item, int position) {
-                holder.setImage(R.id.avatar, item.getFromClient().getFaceUrl());
-                holder.setText(R.id.name, item.getFromClient().getNickName());
+                holder.setImage(R.id.avatar, SZYXImSdk.getInstance().getUser(item.getFromClientId()).getFaceUrl());
+                holder.setText(R.id.name, SZYXImSdk.getInstance().getUser(item.getFromClientId()).getNickName());
                 ChatAdapter.this.convert(holder, item, position);
             }
         });

+ 0 - 1
app/src/main/res/layout/activity_chat.xml

@@ -26,7 +26,6 @@
                 <androidx.recyclerview.widget.RecyclerView
                     android:id="@+id/baseRecyclerView"
                     android:layout_width="match_parent"
-                    android:paddingHorizontal="20dp"
                     android:layout_height="match_parent"
                     android:overScrollMode="never" />
 

+ 1 - 16
app/src/main/res/layout/chat_view_root_r.xml

@@ -23,34 +23,19 @@
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/time" />
 
-
-    <TextView
-        android:id="@+id/name"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginEnd="5dp"
-        android:text="小明"
-        android:textColor="#767581"
-        android:textSize="10sp"
-        android:visibility="gone"
-        app:layout_constraintEnd_toStartOf="@+id/avatar"
-        app:layout_constraintTop_toTopOf="@+id/avatar" />
-
     <LinearLayout
         android:id="@+id/content"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginStart="20dp"
-        android:layout_marginTop="5dp"
         android:layout_marginEnd="5dp"
         android:background="#FFFFFF"
         android:gravity="right"
-        android:minWidth="70dp"
         android:minHeight="40dp"
         android:orientation="horizontal"
         android:padding="10dp"
         app:layout_constraintEnd_toStartOf="@+id/avatar"
-        app:layout_constraintTop_toBottomOf="@+id/name"
+        app:layout_constraintTop_toTopOf="@+id/avatar"
         app:layout_constraintWidth_max="240dp">