diff --git a/Share/src/main/java/com/yunbao/share/ui/AppInternalShareDialog.java b/Share/src/main/java/com/yunbao/share/ui/AppInternalShareDialog.java index 3b267141f..b18b8e781 100644 --- a/Share/src/main/java/com/yunbao/share/ui/AppInternalShareDialog.java +++ b/Share/src/main/java/com/yunbao/share/ui/AppInternalShareDialog.java @@ -1,7 +1,9 @@ package com.yunbao.share.ui; import android.content.Context; +import android.net.Uri; import android.text.Editable; +import android.text.TextUtils; import android.text.TextWatcher; import android.util.Log; import android.widget.EditText; @@ -9,20 +11,28 @@ import android.widget.EditText; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.lxj.xpopup.XPopup; import com.pdlive.shayu.R; +import com.yunbao.common.bean.UserBean; import com.yunbao.common.dialog.AbsDialogFullScreenPopupWindow; import com.yunbao.common.dialog.DebugDialog; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.manager.InstructorRemarkManager; import com.yunbao.common.utils.AppManager; import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.share.adapters.InternalShareAdapter; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import io.rong.imkit.conversationlist.model.SingleConversation; +import io.rong.imkit.userinfo.RongUserInfoManager; import io.rong.imkit.widget.refresh.SmartRefreshLayout; import io.rong.imkit.widget.refresh.api.RefreshLayout; import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener; @@ -32,6 +42,7 @@ import io.rong.imlib.IRongCoreCallback; import io.rong.imlib.IRongCoreEnum; import io.rong.imlib.RongCoreClient; import io.rong.imlib.model.Conversation; +import io.rong.imlib.model.UserInfo; public class AppInternalShareDialog extends AbsDialogFullScreenPopupWindow { EditText search; @@ -151,22 +162,72 @@ public class AppInternalShareDialog extends AbsDialogFullScreenPopupWindow { private void refreshData() { RongCoreClient.getInstance().getConversationListByPage(new IRongCoreCallback.ResultCallback>() { + boolean isNeedData = false; + List needUidList = new ArrayList<>(); + @Override public void onSuccess(List conversations) { + isNeedData = false; + needUidList.clear(); if (conversations.isEmpty()) { mRefreshLayout.finishLoadMoreWithNoMoreData(); return; } List tmp = new ArrayList<>(); for (Conversation conversation : conversations) { + if(conversation.getTargetId().contains("__system__")){ + continue; + } + if (StringUtil.isEmpty(conversation.getPortraitUrl())) { + isNeedData = true; + needUidList.add(conversation.getTargetId()); + continue; + } tmp.add(new SingleConversation(getContext(), conversation)); } + if (isNeedData) { + checkUserData(); + return; + } startTime = conversations.get(conversations.size() - 1).getSentTime(); listData.addAll(tmp); adapter.setList(listData); mRefreshLayout.finishRefresh(true); } + private void checkUserData() { + Iterator iterator = needUidList.iterator(); + while (iterator.hasNext()) { + String userId = iterator.next(); + CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0 && !TextUtils.equals("__system__", userId)) { + JSONObject obj = JSON.parseObject(info[0]); + UserBean userBean = JSON.toJavaObject(obj, UserBean.class); + needUidList.remove(userBean.getId()); + UserInfo userInfo = new UserInfo(userBean.getId(), userBean.getUserNiceName(), Uri.parse(userBean.getAvatar())); + userInfo.setExtra(obj.toString()); + RongUserInfoManager.getInstance().refreshUserInfoCache(userInfo); + Conversation conversation=new Conversation(); + conversation.setTargetId(userBean.getId()); + conversation.setConversationTitle(userBean.getUserNiceName()); + conversation.setPortraitUrl(userBean.getAvatar()); + SingleConversation singleConversation = new SingleConversation(getContext(), conversation); + listData.add(singleConversation); + if (needUidList.isEmpty()) { + adapter.setList(listData); + mRefreshLayout.finishRefresh(true); + } + } else { + Log.i("刷新用户", "3>" + code + "|" + msg + "|" + info.length); + } + + } + }); + } + } + @Override public void onError(IRongCoreEnum.CoreErrorCode e) { ToastUtil.show("出错了:" + e.getMessage()); diff --git a/common/src/main/java/com/yunbao/common/event/RongIMConnectionStatusEvent.java b/common/src/main/java/com/yunbao/common/event/RongIMConnectionStatusEvent.java index 699c92e0c..bdc38a57e 100644 --- a/common/src/main/java/com/yunbao/common/event/RongIMConnectionStatusEvent.java +++ b/common/src/main/java/com/yunbao/common/event/RongIMConnectionStatusEvent.java @@ -6,4 +6,14 @@ import com.yunbao.common.bean.BaseModel; * 融云连接状态监听通知 */ public class RongIMConnectionStatusEvent extends BaseModel { + private int status; + + public int getStatus() { + return status; + } + + public RongIMConnectionStatusEvent setStatus(int status) { + this.status = status; + return this; + } } diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java index 64f626a57..073f3d4cb 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java @@ -190,13 +190,14 @@ public class RongcloudIMManager { break; //用户账号在其它设备登录,此设备被踢下线 case KICKED_OFFLINE_BY_OTHER_CLIENT: - EventBus.getDefault().post(new RongIMConnectionStatusEvent()); + EventBus.getDefault().post(new RongIMConnectionStatusEvent().setStatus(-1)); break; //连接暂时挂起(多是由于网络问题导致),SDK 会在合适时机进行自动重连 case SUSPEND: break; //连接成功 case CONNECTED: + EventBus.getDefault().post(new RongIMConnectionStatusEvent().setStatus(1)); break; //连接超时,SDK 将停止连接,用户需要做超时处理,再自行调用连接接口进行连接 case TIMEOUT: diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index b2f28448a..c70c8fc49 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -1438,9 +1438,13 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene */ @Subscribe(threadMode = ThreadMode.MAIN) public void userSignOut(RongIMConnectionStatusEvent model) { - IMLoginManager.get(mContext).logout(this); - CommonAppConfig.getInstance().clearLoginInfo(); - LoginActivity.forward(); + if(model.getStatus()==-1) { + IMLoginManager.get(mContext).logout(this); + CommonAppConfig.getInstance().clearLoginInfo(); + LoginActivity.forward(); + }else if(model.getStatus()==1){ + ConversationIMListManager.get(mContext).addUserInfoProvider(); + } } /** diff --git a/main/src/main/java/com/yunbao/main/dialog/MessageStatusConfigDialog.java b/main/src/main/java/com/yunbao/main/dialog/MessageStatusConfigDialog.java index c9d5e8f06..d1ea4ead2 100644 --- a/main/src/main/java/com/yunbao/main/dialog/MessageStatusConfigDialog.java +++ b/main/src/main/java/com/yunbao/main/dialog/MessageStatusConfigDialog.java @@ -55,7 +55,7 @@ public class MessageStatusConfigDialog extends AbsDialogCenterPopupWindow { .setOpenOff(status, new HttpCallback>() { @Override public void onSuccess(List data) { - ToastUtil.show("成功"); + ToastUtil.show(WordUtil.isNewZh()?"成功":"Success"); dismiss(); UserInfoManager.updateMyInfo(mContext, null); } diff --git a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java index e22a7a2aa..764e37433 100644 --- a/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java +++ b/main/src/main/java/com/yunbao/main/manager/imrongcloud/ConversationIMListManager.java @@ -11,6 +11,7 @@ import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; +import android.util.Log; import android.view.View; import com.alibaba.fastjson.JSON; @@ -29,14 +30,16 @@ import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.activity.PDLIiveChatActivity; -import com.yunbao.main.activity.PDLiveConversationActivity; import com.yunbao.live.bean.SearchUserBean; import com.yunbao.live.dialog.PDLIiveChatConversationFragment; +import com.yunbao.main.R; +import com.yunbao.main.activity.PDLiveConversationActivity; import com.yunbao.main.activity.PDLiveConversationListActivity; import com.yunbao.main.dialog.MsgChatClickDialog; import com.yunbao.main.utils.PDLiveCustomConversationProvider; import com.yunbao.main.utils.PDLiveMessageProcessor; import com.yunbao.main.utils.PDSightMessageItemProvider; +import com.yunbao.main.views.MessageChatExtensionConfig; import java.util.Arrays; import java.util.List; @@ -58,9 +61,6 @@ import io.rong.imlib.model.Conversation; import io.rong.imlib.model.UserInfo; import io.rong.sight.SightExtensionModule; -import com.yunbao.main.R; -import com.yunbao.main.views.MessageChatExtensionConfig; - /** * 会话列表管理 */ @@ -157,12 +157,14 @@ public class ConversationIMListManager { */ public void addUserInfoProvider() { RongUserInfoManager.getInstance().setUserInfoProvider(userId -> { + Log.i("刷新用户", "1>" + userId); CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { if (code == 0 && info.length > 0 && !TextUtils.equals("__system__", userId)) { JSONObject obj = JSON.parseObject(info[0]); SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class); + Log.i("刷新用户2", "2>" + userBean.getId() + "|" + userId + "|" + userBean.getAvatar()); String userNiceName = ""; String remark = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId); if (!TextUtils.isEmpty(remark)) { @@ -180,6 +182,8 @@ public class ConversationIMListManager { } } + } else { + Log.i("刷新用户", "3>" + code + "|" + msg + "|" + info.length); } }