|
@@ -0,0 +1,113 @@
|
|
|
+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.LOG;
|
|
|
+import com.cooleshow.base.widgets.dialog.CommonDialog;
|
|
|
+import com.cooleshow.chatmodule.api.IMApi;
|
|
|
+import com.cooleshow.chatmodule.bean.IMGroupInfo;
|
|
|
+import com.cooleshow.chatmodule.bean.IMUserInfo;
|
|
|
+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.classicui.page.TUIC2CChatActivity;
|
|
|
+
|
|
|
+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 2024/9/18.
|
|
|
+ */
|
|
|
+public class TUIC2CChatActivityV2 extends TUIC2CChatActivity {
|
|
|
+
|
|
|
+ private String conversationId;
|
|
|
+ private CommonDialog mTipdialog;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initChat(ChatInfo chatInfo) {
|
|
|
+ super.initChat(chatInfo);
|
|
|
+ LOG.i("TUIC2CChatActivityV2","id:"+chatInfo.getId());
|
|
|
+ conversationId = getIntent().getStringExtra(TUIConstants.TUIChat.CONVERSATION_ID);
|
|
|
+ if(chatInfo!=null && !TextUtils.isEmpty(chatInfo.getId())){
|
|
|
+ checkUserStatus(chatInfo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void checkUserStatus(String targetId) {
|
|
|
+
|
|
|
+ Observable<BaseResponse<IMUserInfo>> observable = RetrofitFactory.Companion.getInstance().create(IMApi.class).queryUserDetail(targetId,BaseConstant.CLIENT_API_GROUP_NAME);
|
|
|
+ observable.subscribeOn(Schedulers.newThread())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new Observer<BaseResponse<IMUserInfo>>() {
|
|
|
+ @Override
|
|
|
+ public void onSubscribe(@NonNull Disposable d) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(@NonNull BaseResponse<IMUserInfo> updateAppBeanBaseResponse) {
|
|
|
+ if (updateAppBeanBaseResponse != null && updateAppBeanBaseResponse.getData()!=null) {
|
|
|
+ IMUserInfo data = updateAppBeanBaseResponse.getData();
|
|
|
+ if (data.isDelFlag()) {
|
|
|
+ showTipDialog("该用户已注销,是否删除会话?");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @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();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|