Переглянути джерело

增加群公告跳转状态校验

Pq 1 місяць тому
батько
коміт
c508281278

+ 34 - 4
chatModule/src/main/java/com/cooleshow/chatmodule/message/holder/TUIChatGroupNoticeMessageHolder.java

@@ -5,12 +5,24 @@ import android.view.View;
 import android.widget.TextView;
 
 import com.alibaba.android.arouter.launcher.ARouter;
+import com.cooleshow.base.common.BaseConstant;
+import com.cooleshow.base.data.net.BaseResponse;
+import com.cooleshow.base.data.net.RetrofitFactory;
+import com.cooleshow.base.router.RouterPath;
+import com.cooleshow.base.rx.BaseObserver;
+import com.cooleshow.base.utils.ErrorParse;
 import com.cooleshow.chatmodule.R;
+import com.cooleshow.chatmodule.api.IMApi;
+import com.cooleshow.chatmodule.bean.GroupNoticeBean;
 import com.cooleshow.chatmodule.constants.TCChatRouterPath;
 import com.cooleshow.chatmodule.message.bean.TUIChatGroupNoticeMessageBean;
 import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
 import com.tencent.qcloud.tuikit.timcommon.classicui.widget.message.MessageContentHolder;
 
+import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
+import io.reactivex.rxjava3.core.Observable;
+import io.reactivex.rxjava3.schedulers.Schedulers;
+
 /**
  * Author by pq, Date on 2023/8/9.
  */
@@ -43,13 +55,31 @@ public class TUIChatGroupNoticeMessageHolder extends MessageContentHolder {
                 public void onClick(View v) {
                     if (noticeMessageBean != null && !TextUtils.isEmpty(noticeMessageBean.getMsgId())) {
                         String groupId = noticeMessageBean.getGroupId();
-                        ARouter.getInstance().build(TCChatRouterPath.CHAT_GROUP_NOTICE_DETAIL)
-                                .withString("targetId", groupId)
-                                .withString("targetMsgId", noticeMessageBean.getMsgId())
-                                .navigation();
+                        checkNoticeStatus(groupId,noticeMessageBean.getMsgId());
                     }
                 }
             });
         }
     }
+
+    private void checkNoticeStatus(String groupId, String targetMsgId) {
+        Observable<BaseResponse<GroupNoticeBean.RowsBean>> baseResponseObservable = RetrofitFactory.Companion.getInstance().create(IMApi.class).noticeDetail(BaseConstant.CLIENT_API_GROUP_NAME,targetMsgId);
+        baseResponseObservable.subscribeOn(Schedulers.newThread())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new BaseObserver<GroupNoticeBean.RowsBean>() {
+                    @Override
+                    protected void onSuccess(GroupNoticeBean.RowsBean data) {
+                        ARouter.getInstance().build(TCChatRouterPath.CHAT_GROUP_NOTICE_DETAIL)
+                                .withString("targetId", groupId)
+                                .withString("targetMsgId", targetMsgId)
+                                .navigation();
+                    }
+
+                    @Override
+                    public void onError(Throwable e) {
+                        super.onError(e);
+                        ErrorParse.getInstance().parseError(e);
+                    }
+                });
+    }
 }