|
@@ -0,0 +1,117 @@
|
|
|
+package com.cooleshow.chatmodule.ui;
|
|
|
+
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.view.View;
|
|
|
+
|
|
|
+import com.cooleshow.base.common.BaseConstant;
|
|
|
+import com.cooleshow.base.data.net.BaseResponse;
|
|
|
+import com.cooleshow.base.data.net.RetrofitFactory;
|
|
|
+import com.cooleshow.base.utils.ErrorParse;
|
|
|
+import com.cooleshow.base.widgets.dialog.CommonDialog;
|
|
|
+import com.cooleshow.chatmodule.api.IMApi;
|
|
|
+import com.cooleshow.chatmodule.bean.IMGroupInfo;
|
|
|
+import com.cooleshow.chatmodule.manager.IMCenter;
|
|
|
+import com.tencent.qcloud.tuicore.TUIConstants;
|
|
|
+import com.tencent.qcloud.tuikit.timcommon.component.interfaces.IUIKitCallback;
|
|
|
+import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
|
|
|
+import com.tencent.qcloud.tuikit.tuichat.bean.GroupInfo;
|
|
|
+import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity;
|
|
|
+
|
|
|
+import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
|
|
+import io.reactivex.rxjava3.annotations.NonNull;
|
|
|
+import io.reactivex.rxjava3.core.Observable;
|
|
|
+import io.reactivex.rxjava3.core.Observer;
|
|
|
+import io.reactivex.rxjava3.disposables.Disposable;
|
|
|
+import io.reactivex.rxjava3.schedulers.Schedulers;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Author by pq, Date on 2023/8/8.
|
|
|
+ * 为了实现checkInGroup这个逻辑,所以继承TUIGroupChatActivity
|
|
|
+ */
|
|
|
+public class TUIChatGroupActivityV2 extends TUIGroupChatActivity {
|
|
|
+ public static int GROUP_INFO_ERROR = 5434;//群组相关信息异常
|
|
|
+ private String groupId;
|
|
|
+ private CommonDialog mTipdialog;
|
|
|
+ private String conversationId;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initChat(ChatInfo chatInfo) {
|
|
|
+ super.initChat(chatInfo);
|
|
|
+ conversationId = getIntent().getStringExtra(TUIConstants.TUIChat.CONVERSATION_ID);
|
|
|
+ GroupInfo groupInfo = (GroupInfo) chatInfo;
|
|
|
+ groupId = groupInfo.getId();
|
|
|
+ if (groupInfo != null) {
|
|
|
+ checkInGroup(groupInfo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void checkInGroup(String groupId) {
|
|
|
+ //根据用户编号获取用户基本信息
|
|
|
+ Observable<BaseResponse<IMGroupInfo>> observable = RetrofitFactory.Companion.getInstance().create(IMApi.class).queryGroupDetail(groupId, BaseConstant.CLIENT_API_GROUP_NAME);
|
|
|
+ observable.subscribeOn(Schedulers.newThread())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new Observer<BaseResponse<IMGroupInfo>>() {
|
|
|
+ @Override
|
|
|
+ public void onSubscribe(@NonNull Disposable d) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(@NonNull BaseResponse<IMGroupInfo> updateAppBeanBaseResponse) {
|
|
|
+ if (updateAppBeanBaseResponse != null) {
|
|
|
+ int errorCode = updateAppBeanBaseResponse.getErrorCode();
|
|
|
+ if (errorCode == GROUP_INFO_ERROR) {
|
|
|
+ showTipDialog(updateAppBeanBaseResponse.getErrorMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(@NonNull Throwable e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showTipDialog(String tip) {
|
|
|
+ if (TextUtils.isEmpty(conversationId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (mTipdialog == null) {
|
|
|
+ mTipdialog = new CommonDialog(this);
|
|
|
+ }
|
|
|
+ if (!mTipdialog.isShowing()) {
|
|
|
+ mTipdialog.show();
|
|
|
+ }
|
|
|
+ mTipdialog.setOnCancelClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mTipdialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mTipdialog.setOnConfirmClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ delConversation();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mTipdialog.setTitle("提示");
|
|
|
+ mTipdialog.setContent(tip);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void delConversation() {
|
|
|
+ IMCenter.getInstance().deleteConversation(conversationId, new IUIKitCallback<Void>() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(Void data) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|