修复 [反餽問題]
This commit is contained in:
parent
fb81ca8c54
commit
088868201d
@ -1,7 +1,9 @@
|
|||||||
package com.yunbao.share.ui;
|
package com.yunbao.share.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@ -9,20 +11,28 @@ import android.widget.EditText;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.lxj.xpopup.XPopup;
|
import com.lxj.xpopup.XPopup;
|
||||||
import com.pdlive.shayu.R;
|
import com.pdlive.shayu.R;
|
||||||
|
import com.yunbao.common.bean.UserBean;
|
||||||
import com.yunbao.common.dialog.AbsDialogFullScreenPopupWindow;
|
import com.yunbao.common.dialog.AbsDialogFullScreenPopupWindow;
|
||||||
import com.yunbao.common.dialog.DebugDialog;
|
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.interfaces.OnItemClickListener;
|
||||||
|
import com.yunbao.common.manager.InstructorRemarkManager;
|
||||||
import com.yunbao.common.utils.AppManager;
|
import com.yunbao.common.utils.AppManager;
|
||||||
import com.yunbao.common.utils.StringUtil;
|
import com.yunbao.common.utils.StringUtil;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
import com.yunbao.share.adapters.InternalShareAdapter;
|
import com.yunbao.share.adapters.InternalShareAdapter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
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.SmartRefreshLayout;
|
||||||
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
import io.rong.imkit.widget.refresh.api.RefreshLayout;
|
||||||
import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener;
|
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.IRongCoreEnum;
|
||||||
import io.rong.imlib.RongCoreClient;
|
import io.rong.imlib.RongCoreClient;
|
||||||
import io.rong.imlib.model.Conversation;
|
import io.rong.imlib.model.Conversation;
|
||||||
|
import io.rong.imlib.model.UserInfo;
|
||||||
|
|
||||||
public class AppInternalShareDialog extends AbsDialogFullScreenPopupWindow {
|
public class AppInternalShareDialog extends AbsDialogFullScreenPopupWindow {
|
||||||
EditText search;
|
EditText search;
|
||||||
@ -151,22 +162,72 @@ public class AppInternalShareDialog extends AbsDialogFullScreenPopupWindow {
|
|||||||
|
|
||||||
private void refreshData() {
|
private void refreshData() {
|
||||||
RongCoreClient.getInstance().getConversationListByPage(new IRongCoreCallback.ResultCallback<List<Conversation>>() {
|
RongCoreClient.getInstance().getConversationListByPage(new IRongCoreCallback.ResultCallback<List<Conversation>>() {
|
||||||
|
boolean isNeedData = false;
|
||||||
|
List<String> needUidList = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Conversation> conversations) {
|
public void onSuccess(List<Conversation> conversations) {
|
||||||
|
isNeedData = false;
|
||||||
|
needUidList.clear();
|
||||||
if (conversations.isEmpty()) {
|
if (conversations.isEmpty()) {
|
||||||
mRefreshLayout.finishLoadMoreWithNoMoreData();
|
mRefreshLayout.finishLoadMoreWithNoMoreData();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<SingleConversation> tmp = new ArrayList<>();
|
List<SingleConversation> tmp = new ArrayList<>();
|
||||||
for (Conversation conversation : conversations) {
|
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));
|
tmp.add(new SingleConversation(getContext(), conversation));
|
||||||
}
|
}
|
||||||
|
if (isNeedData) {
|
||||||
|
checkUserData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
startTime = conversations.get(conversations.size() - 1).getSentTime();
|
startTime = conversations.get(conversations.size() - 1).getSentTime();
|
||||||
listData.addAll(tmp);
|
listData.addAll(tmp);
|
||||||
adapter.setList(listData);
|
adapter.setList(listData);
|
||||||
mRefreshLayout.finishRefresh(true);
|
mRefreshLayout.finishRefresh(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkUserData() {
|
||||||
|
Iterator<String> 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
|
@Override
|
||||||
public void onError(IRongCoreEnum.CoreErrorCode e) {
|
public void onError(IRongCoreEnum.CoreErrorCode e) {
|
||||||
ToastUtil.show("出错了:" + e.getMessage());
|
ToastUtil.show("出错了:" + e.getMessage());
|
||||||
|
@ -6,4 +6,14 @@ import com.yunbao.common.bean.BaseModel;
|
|||||||
* 融云连接状态监听通知
|
* 融云连接状态监听通知
|
||||||
*/
|
*/
|
||||||
public class RongIMConnectionStatusEvent extends BaseModel {
|
public class RongIMConnectionStatusEvent extends BaseModel {
|
||||||
|
private int status;
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RongIMConnectionStatusEvent setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,13 +190,14 @@ public class RongcloudIMManager {
|
|||||||
break;
|
break;
|
||||||
//用户账号在其它设备登录,此设备被踢下线
|
//用户账号在其它设备登录,此设备被踢下线
|
||||||
case KICKED_OFFLINE_BY_OTHER_CLIENT:
|
case KICKED_OFFLINE_BY_OTHER_CLIENT:
|
||||||
EventBus.getDefault().post(new RongIMConnectionStatusEvent());
|
EventBus.getDefault().post(new RongIMConnectionStatusEvent().setStatus(-1));
|
||||||
break;
|
break;
|
||||||
//连接暂时挂起(多是由于网络问题导致),SDK 会在合适时机进行自动重连
|
//连接暂时挂起(多是由于网络问题导致),SDK 会在合适时机进行自动重连
|
||||||
case SUSPEND:
|
case SUSPEND:
|
||||||
break;
|
break;
|
||||||
//连接成功
|
//连接成功
|
||||||
case CONNECTED:
|
case CONNECTED:
|
||||||
|
EventBus.getDefault().post(new RongIMConnectionStatusEvent().setStatus(1));
|
||||||
break;
|
break;
|
||||||
//连接超时,SDK 将停止连接,用户需要做超时处理,再自行调用连接接口进行连接
|
//连接超时,SDK 将停止连接,用户需要做超时处理,再自行调用连接接口进行连接
|
||||||
case TIMEOUT:
|
case TIMEOUT:
|
||||||
|
@ -1438,9 +1438,13 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
*/
|
*/
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void userSignOut(RongIMConnectionStatusEvent model) {
|
public void userSignOut(RongIMConnectionStatusEvent model) {
|
||||||
IMLoginManager.get(mContext).logout(this);
|
if(model.getStatus()==-1) {
|
||||||
CommonAppConfig.getInstance().clearLoginInfo();
|
IMLoginManager.get(mContext).logout(this);
|
||||||
LoginActivity.forward();
|
CommonAppConfig.getInstance().clearLoginInfo();
|
||||||
|
LoginActivity.forward();
|
||||||
|
}else if(model.getStatus()==1){
|
||||||
|
ConversationIMListManager.get(mContext).addUserInfoProvider();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,7 @@ public class MessageStatusConfigDialog extends AbsDialogCenterPopupWindow {
|
|||||||
.setOpenOff(status, new HttpCallback<List<BaseModel>>() {
|
.setOpenOff(status, new HttpCallback<List<BaseModel>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<BaseModel> data) {
|
public void onSuccess(List<BaseModel> data) {
|
||||||
ToastUtil.show("成功");
|
ToastUtil.show(WordUtil.isNewZh()?"成功":"Success");
|
||||||
dismiss();
|
dismiss();
|
||||||
UserInfoManager.updateMyInfo(mContext, null);
|
UserInfoManager.updateMyInfo(mContext, null);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
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.ToastUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.live.activity.PDLIiveChatActivity;
|
import com.yunbao.live.activity.PDLIiveChatActivity;
|
||||||
import com.yunbao.main.activity.PDLiveConversationActivity;
|
|
||||||
import com.yunbao.live.bean.SearchUserBean;
|
import com.yunbao.live.bean.SearchUserBean;
|
||||||
import com.yunbao.live.dialog.PDLIiveChatConversationFragment;
|
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.activity.PDLiveConversationListActivity;
|
||||||
import com.yunbao.main.dialog.MsgChatClickDialog;
|
import com.yunbao.main.dialog.MsgChatClickDialog;
|
||||||
import com.yunbao.main.utils.PDLiveCustomConversationProvider;
|
import com.yunbao.main.utils.PDLiveCustomConversationProvider;
|
||||||
import com.yunbao.main.utils.PDLiveMessageProcessor;
|
import com.yunbao.main.utils.PDLiveMessageProcessor;
|
||||||
import com.yunbao.main.utils.PDSightMessageItemProvider;
|
import com.yunbao.main.utils.PDSightMessageItemProvider;
|
||||||
|
import com.yunbao.main.views.MessageChatExtensionConfig;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -58,9 +61,6 @@ import io.rong.imlib.model.Conversation;
|
|||||||
import io.rong.imlib.model.UserInfo;
|
import io.rong.imlib.model.UserInfo;
|
||||||
import io.rong.sight.SightExtensionModule;
|
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() {
|
public void addUserInfoProvider() {
|
||||||
RongUserInfoManager.getInstance().setUserInfoProvider(userId -> {
|
RongUserInfoManager.getInstance().setUserInfoProvider(userId -> {
|
||||||
|
Log.i("刷新用户", "1>" + userId);
|
||||||
CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() {
|
CommonHttpUtil.getUserBaseinfo(userId, new HttpCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(int code, String msg, String[] info) {
|
public void onSuccess(int code, String msg, String[] info) {
|
||||||
if (code == 0 && info.length > 0 && !TextUtils.equals("__system__", userId)) {
|
if (code == 0 && info.length > 0 && !TextUtils.equals("__system__", userId)) {
|
||||||
JSONObject obj = JSON.parseObject(info[0]);
|
JSONObject obj = JSON.parseObject(info[0]);
|
||||||
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
|
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
|
||||||
|
Log.i("刷新用户2", "2>" + userBean.getId() + "|" + userId + "|" + userBean.getAvatar());
|
||||||
String userNiceName = "";
|
String userNiceName = "";
|
||||||
String remark = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
|
String remark = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
|
||||||
if (!TextUtils.isEmpty(remark)) {
|
if (!TextUtils.isEmpty(remark)) {
|
||||||
@ -180,6 +182,8 @@ public class ConversationIMListManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.i("刷新用户", "3>" + code + "|" + msg + "|" + info.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user