Explorar o código

增加IM消息点击事件回调

Pq hai 1 ano
pai
achega
696e0aa4c5

+ 15 - 0
TUIKit/TIMCommon/timcommon/src/main/java/com/tencent/qcloud/tuikit/timcommon/component/MessageProperties.java

@@ -3,6 +3,7 @@ package com.tencent.qcloud.tuikit.timcommon.component;
 import android.graphics.drawable.Drawable;
 import android.widget.EditText;
 
+import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
 import com.tencent.qcloud.tuikit.timcommon.interfaces.IMessageProperties;
 import com.tencent.qcloud.tuikit.timcommon.util.ScreenUtil;
 
@@ -31,6 +32,8 @@ public class MessageProperties implements IMessageProperties {
     private int mainStyleColor = -1;
     private int searchTextColor = -1;
 
+    private OnEventListener mEventListener;
+
     private MessageProperties() {
     }
 
@@ -270,4 +273,16 @@ public class MessageProperties implements IMessageProperties {
             }
         }
     }
+
+    public void setOnEventListener(OnEventListener eventListener) {
+        this.mEventListener = eventListener;
+    }
+
+    public OnEventListener getEventListener() {
+        return mEventListener;
+    }
+
+    public interface OnEventListener {
+        boolean onMessageClick(TUIMessageBean messageBean);
+    }
 }

+ 5 - 0
TUIKit/TUIChat/tuichat/src/main/java/com/tencent/qcloud/tuikit/tuichat/classicui/page/MessageReplyDetailActivity.java

@@ -14,6 +14,7 @@ import com.tencent.qcloud.tuicore.TUICore;
 import com.tencent.qcloud.tuicore.util.ToastUtil;
 import com.tencent.qcloud.tuikit.timcommon.bean.MessageRepliesBean;
 import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
+import com.tencent.qcloud.tuikit.timcommon.component.MessageProperties;
 import com.tencent.qcloud.tuikit.timcommon.component.TitleBarLayout;
 import com.tencent.qcloud.tuikit.timcommon.component.activities.BaseLightActivity;
 import com.tencent.qcloud.tuikit.timcommon.component.interfaces.ITitleBarLayout;
@@ -102,6 +103,10 @@ public class MessageReplyDetailActivity extends BaseLightActivity implements Inp
             messageRecyclerView.setOnItemClickListener(new OnItemClickListener() {
                 @Override
                 public void onMessageClick(View view, int position, TUIMessageBean messageBean) {
+                    MessageProperties.OnEventListener eventListener = MessageProperties.getInstance().getEventListener();
+                    if (eventListener != null && eventListener.onMessageClick(messageBean)) {
+                        return;
+                    }
                     if (messageBean instanceof MergeMessageBean) {
                         Bundle bundle = new Bundle();
                         bundle.putSerializable(TUIChatConstants.FORWARD_MERGE_MESSAGE_KEY, messageBean);

+ 5 - 0
TUIKit/TUIChat/tuichat/src/main/java/com/tencent/qcloud/tuikit/tuichat/classicui/page/TUIBaseChatFragment.java

@@ -29,6 +29,7 @@ import com.tencent.qcloud.tuicore.TUICore;
 import com.tencent.qcloud.tuicore.TUILogin;
 import com.tencent.qcloud.tuicore.util.ToastUtil;
 import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
+import com.tencent.qcloud.tuikit.timcommon.component.MessageProperties;
 import com.tencent.qcloud.tuikit.timcommon.component.TitleBarLayout;
 import com.tencent.qcloud.tuikit.timcommon.component.fragments.BaseFragment;
 import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
@@ -170,6 +171,10 @@ public class TUIBaseChatFragment extends BaseFragment {
         chatView.getMessageLayout().setOnItemClickListener(new OnItemClickListener() {
             @Override
             public void onMessageClick(View view, int position, TUIMessageBean messageBean) {
+                MessageProperties.OnEventListener eventListener = MessageProperties.getInstance().getEventListener();
+                if (eventListener != null && eventListener.onMessageClick(messageBean)) {
+                    return;
+                }
                 if (messageBean instanceof MergeMessageBean && getChatInfo() != null) {
                     Bundle bundle = new Bundle();
                     bundle.putSerializable(TUIChatConstants.FORWARD_MERGE_MESSAGE_KEY, messageBean);

+ 5 - 0
TUIKit/TUIChat/tuichat/src/main/java/com/tencent/qcloud/tuikit/tuichat/classicui/page/TUIForwardChatActivity.java

@@ -7,6 +7,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
 import com.tencent.qcloud.tuicore.TUICore;
 import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
 import com.tencent.qcloud.tuikit.timcommon.component.CustomLinearLayoutManager;
+import com.tencent.qcloud.tuikit.timcommon.component.MessageProperties;
 import com.tencent.qcloud.tuikit.timcommon.component.TitleBarLayout;
 import com.tencent.qcloud.tuikit.timcommon.component.activities.BaseLightActivity;
 import com.tencent.qcloud.tuikit.timcommon.component.interfaces.ITitleBarLayout;
@@ -73,6 +74,10 @@ public class TUIForwardChatActivity extends BaseLightActivity {
 
             @Override
             public void onMessageClick(View view, int position, TUIMessageBean messageBean) {
+                MessageProperties.OnEventListener eventListener = MessageProperties.getInstance().getEventListener();
+                if (eventListener != null && eventListener.onMessageClick(messageBean)) {
+                    return;
+                }
                 if (messageBean instanceof MergeMessageBean) {
                     Bundle bundle = new Bundle();
                     bundle.putSerializable(TUIChatConstants.FORWARD_MERGE_MESSAGE_KEY, messageBean);

+ 5 - 0
TUIKit/TUIChat/tuichat/src/main/java/com/tencent/qcloud/tuikit/tuichat/classicui/page/TUIGroupChatFragment.java

@@ -11,6 +11,7 @@ import com.tencent.qcloud.tuicore.TUICore;
 import com.tencent.qcloud.tuicore.interfaces.TUIExtensionEventListener;
 import com.tencent.qcloud.tuicore.interfaces.TUIExtensionInfo;
 import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
+import com.tencent.qcloud.tuikit.timcommon.component.MessageProperties;
 import com.tencent.qcloud.tuikit.timcommon.interfaces.OnItemClickListener;
 import com.tencent.qcloud.tuikit.tuichat.TUIChatConstants;
 import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
@@ -64,6 +65,10 @@ public class TUIGroupChatFragment extends TUIBaseChatFragment {
 
             @Override
             public void onMessageClick(View view, int position, TUIMessageBean messageBean) {
+                MessageProperties.OnEventListener eventListener = MessageProperties.getInstance().getEventListener();
+                if (eventListener != null && eventListener.onMessageClick(messageBean)) {
+                    return;
+                }
                 if (messageBean instanceof MergeMessageBean && getChatInfo() != null) {
                     Bundle bundle = new Bundle();
                     bundle.putSerializable(TUIChatConstants.FORWARD_MERGE_MESSAGE_KEY, messageBean);