Browse Source

1.修改bug

王鹏鹏 2 years ago
parent
commit
39a8575576

+ 33 - 27
tuichat/src/main/java/com/tencent/qcloud/tuikit/tuichat/classicui/widget/ChatView.java

@@ -281,7 +281,9 @@ public class ChatView extends LinearLayout implements IChatLayout {
         this.presenter = presenter;
         mMessageRecyclerView.setPresenter(presenter);
         mInputView.setPresenter(presenter);
-        presenter.setMessageListAdapter(mAdapter);
+        if (mAdapter != null) {
+            presenter.setMessageListAdapter(mAdapter);
+        }
         mAdapter.setPresenter(presenter);
         presenter.setMessageRecycleView(mMessageRecyclerView);
     }
@@ -319,7 +321,7 @@ public class ChatView extends LinearLayout implements IChatLayout {
         mMessageRecyclerView.setMenuEmojiOnClickListener(this::reactMessage);
 
         loadMessages(
-            chatInfo.getLocateMessage(), chatInfo.getLocateMessage() == null ? TUIChatConstants.GET_MESSAGE_FORWARD : TUIChatConstants.GET_MESSAGE_TWO_WAY);
+                chatInfo.getLocateMessage(), chatInfo.getLocateMessage() == null ? TUIChatConstants.GET_MESSAGE_FORWARD : TUIChatConstants.GET_MESSAGE_TWO_WAY);
         setTotalUnread();
     }
 
@@ -349,7 +351,8 @@ public class ChatView extends LinearLayout implements IChatLayout {
         List<TUIMessageBean> tuiMessageBeans = mAdapter.getItemList(firstPosition, lastPosition);
         presenter.sendMessageReadReceipt(tuiMessageBeans, new IUIKitCallback<Void>() {
             @Override
-            public void onSuccess(Void data) {}
+            public void onSuccess(Void data) {
+            }
 
             @Override
             public void onError(String module, int errCode, String errMsg) {
@@ -398,7 +401,7 @@ public class ChatView extends LinearLayout implements IChatLayout {
         Object result = TUICore.callService(TUIConstants.TUIConversation.SERVICE_NAME, TUIConstants.TUIConversation.METHOD_GET_TOTAL_UNREAD_COUNT, null);
         if (result != null && result instanceof Long) {
             unreadCount =
-                (long) TUICore.callService(TUIConstants.TUIConversation.SERVICE_NAME, TUIConstants.TUIConversation.METHOD_GET_TOTAL_UNREAD_COUNT, null);
+                    (long) TUICore.callService(TUIConstants.TUIConversation.SERVICE_NAME, TUIConstants.TUIConversation.METHOD_GET_TOTAL_UNREAD_COUNT, null);
         }
         updateUnreadCount(unreadCountTextView, unreadCount);
         unreadCountListener = totalUnreadCount -> updateUnreadCount(unreadCountTextView, totalUnreadCount);
@@ -531,15 +534,16 @@ public class ChatView extends LinearLayout implements IChatLayout {
             @Override
             public void onDeleteMessageClick(TUIMessageBean msg) {
                 TUIKitDialog tipsDialog =
-                    new TUIKitDialog(getContext())
-                        .builder()
-                        .setCancelable(true)
-                        .setCancelOutside(true)
-                        .setTitle(getContext().getString(R.string.chat_delete_msg_tip))
-                        .setDialogWidth(0.75f)
-                        .setPositiveButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.sure),
-                                v -> deleteMessage(msg))
-                        .setNegativeButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.cancel), v -> {});
+                        new TUIKitDialog(getContext())
+                                .builder()
+                                .setCancelable(true)
+                                .setCancelOutside(true)
+                                .setTitle(getContext().getString(R.string.chat_delete_msg_tip))
+                                .setDialogWidth(0.75f)
+                                .setPositiveButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.sure),
+                                        v -> deleteMessage(msg))
+                                .setNegativeButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.cancel), v -> {
+                                });
                 tipsDialog.show();
             }
 
@@ -796,7 +800,8 @@ public class ChatView extends LinearLayout implements IChatLayout {
     }
 
     @Override
-    public void setParentLayout(Object parentContainer) {}
+    public void setParentLayout(Object parentContainer) {
+    }
 
     public void scrollToEnd() {
         getMessageLayout().scrollToEnd();
@@ -935,17 +940,18 @@ public class ChatView extends LinearLayout implements IChatLayout {
 
     private void showForwardLimitDialog(final List<TUIMessageBean> messageInfoList) {
         TUIKitDialog tipsDialog = new TUIKitDialog(getContext())
-                                      .builder()
-                                      .setCancelable(true)
-                                      .setCancelOutside(true)
-                                      .setTitle(getContext().getString(R.string.forward_oneByOne_limit_number_tip))
-                                      .setDialogWidth(0.75f)
-                                      .setPositiveButton(getContext().getString(R.string.forward_mode_merge),
-                                              v -> {
-                                                  startSelectForwardActivity(TUIChatConstants.FORWARD_MODE_MERGE, messageInfoList);
-                                                  resetForwardState("返回");
-                                              })
-                                      .setNegativeButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.cancel), v -> {});
+                .builder()
+                .setCancelable(true)
+                .setCancelOutside(true)
+                .setTitle(getContext().getString(R.string.forward_oneByOne_limit_number_tip))
+                .setDialogWidth(0.75f)
+                .setPositiveButton(getContext().getString(R.string.forward_mode_merge),
+                        v -> {
+                            startSelectForwardActivity(TUIChatConstants.FORWARD_MODE_MERGE, messageInfoList);
+                            resetForwardState("返回");
+                        })
+                .setNegativeButton(getContext().getString(com.tencent.qcloud.tuicore.R.string.cancel), v -> {
+                });
         tipsDialog.show();
     }
 
@@ -975,7 +981,7 @@ public class ChatView extends LinearLayout implements IChatLayout {
 //                    showNotSupportDialog();
                     if (messageBean.isNeedReadReceipt()) {
                         toastMsg = getResources().getString(R.string.chat_message_read_receipt)
-                            + getResources().getString(com.tencent.qcloud.tuicore.R.string.TUIKitErrorUnsupporInterfaceSuffix);
+                                + getResources().getString(com.tencent.qcloud.tuicore.R.string.TUIKitErrorUnsupporInterfaceSuffix);
                     }
                 }
                 ToastUtil.toastLongMessage(toastMsg);
@@ -1014,7 +1020,7 @@ public class ChatView extends LinearLayout implements IChatLayout {
 //                    showNotSupportDialog();
                     if (msg.isNeedReadReceipt()) {
                         toastMsg = getResources().getString(R.string.chat_message_read_receipt)
-                            + getResources().getString(com.tencent.qcloud.tuicore.R.string.TUIKitErrorUnsupporInterfaceSuffix);
+                                + getResources().getString(com.tencent.qcloud.tuicore.R.string.TUIKitErrorUnsupporInterfaceSuffix);
                     }
                 }
                 ToastUtil.toastLongMessage(toastMsg);