This commit is contained in:
zlzw 2024-04-07 17:50:10 +08:00
parent 1e91f4c716
commit 67cca1b4fb
5 changed files with 10 additions and 6 deletions

View File

@ -34,6 +34,7 @@ import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
import com.tencent.imsdk.v2.V2TIMUserInfo; import com.tencent.imsdk.v2.V2TIMUserInfo;
import com.umeng.analytics.MobclickAgent; import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure; import com.umeng.commonsdk.UMConfigure;
import com.yalantis.ucrop.UCropActivity;
import com.yunbao.common.BuildConfig; import com.yunbao.common.BuildConfig;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
@ -266,6 +267,7 @@ public class AppContext extends CommonAppContext {
MessageChatNotifyManager.getInstance().addShieldClass(EntryActivity.class); MessageChatNotifyManager.getInstance().addShieldClass(EntryActivity.class);
MessageChatNotifyManager.getInstance().addShieldClass(LoginActivity.class); MessageChatNotifyManager.getInstance().addShieldClass(LoginActivity.class);
MessageChatNotifyManager.getInstance().addShieldClass(RegisterActivity.class); MessageChatNotifyManager.getInstance().addShieldClass(RegisterActivity.class);
MessageChatNotifyManager.getInstance().addShieldClass(UCropActivity.class);
RongcloudIMManager.addRongcloudIMOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() { RongcloudIMManager.addRongcloudIMOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() {

View File

@ -31,7 +31,7 @@ public abstract class ImageResultCallback {
@Override @Override
public void onError(String error) { public void onError(String error) {
listener.onItemClick(null, -1); listener.onItemClick(error, -1);
} }
}); });
} }

View File

@ -112,7 +112,7 @@ public class MessageIMManager {
ToastUtil.showDebug(e.getMessage()); ToastUtil.showDebug(e.getMessage());
} }
}); });
getSystemMessages();
} }
public MessageIMManager setSystemNumber(int systemNumber) { public MessageIMManager setSystemNumber(int systemNumber) {
@ -126,7 +126,7 @@ public class MessageIMManager {
* 获取系统消息有未读数展示红点 * 获取系统消息有未读数展示红点
*/ */
public void getSystemMessages() { public void getSystemMessages() {
systemNumber = 0;
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
if (userInfo == null) { if (userInfo == null) {
return; return;
@ -138,6 +138,7 @@ public class MessageIMManager {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
if (code == 0) { if (code == 0) {
systemNumber = 0;
List<IMLoginModel> listUserBean = JSON.parseArray(Arrays.toString(info), IMLoginModel.class); List<IMLoginModel> listUserBean = JSON.parseArray(Arrays.toString(info), IMLoginModel.class);
if (listUserBean != null && listUserBean.size() >= 2) { if (listUserBean != null && listUserBean.size() >= 2) {
//目前就三条消息需求判断前两条消息是否有未读消息 //目前就三条消息需求判断前两条消息是否有未读消息
@ -217,7 +218,7 @@ public class MessageIMManager {
//整合未读消息数目并且发送出去 //整合未读消息数目并且发送出去
private final Runnable essagesRunnable = () -> { private final Runnable essagesRunnable = () -> {
number = imNumber + systemNumber; number = imNumber + systemNumber;
/*if(AppManager.getInstance().getMainActivity()==null){ /* if(AppManager.getInstance().getMainActivity()==null){
new Handler(Looper.getMainLooper()).postDelayed(() -> { new Handler(Looper.getMainLooper()).postDelayed(() -> {
DebugDialog.getInstance(AppManager.getInstance().getMainActivity()).setParams("消息", imNumber + ""); DebugDialog.getInstance(AppManager.getInstance().getMainActivity()).setParams("消息", imNumber + "");
DebugDialog.getInstance(AppManager.getInstance().getMainActivity()).setParams("系統", systemNumber + ""); DebugDialog.getInstance(AppManager.getInstance().getMainActivity()).setParams("系統", systemNumber + "");
@ -227,7 +228,7 @@ public class MessageIMManager {
DebugDialog.getInstance(AppManager.getInstance().getMainActivity()).setParams("系統", systemNumber + ""); DebugDialog.getInstance(AppManager.getInstance().getMainActivity()).setParams("系統", systemNumber + "");
}*/ }*/
Log.i("未读消息", "消息: "+imNumber+" | 系统: "+systemNumber); Log.i("未读消息", "消息: "+imNumber+" | 系统: "+systemNumber);
EventBus.getDefault().post(new MessageIMEvent().setNumber(number).setMessage(imNumber)); EventBus.getDefault().post(new MessageIMEvent().setNumber(imNumber).setMessage(imNumber));
}; };
/** /**

View File

@ -119,7 +119,7 @@ public class RongcloudIMManager {
*/ */
public static void connectIM(Context context) { public static void connectIM(Context context) {
// MessageIMManager.get(context).addImRongCloudObserver(); // MessageIMManager.get(context).addImRongCloudObserver();
MessageIMManager.get(context).getSystemMessages(); // MessageIMManager.get(context).getSystemMessages();
IMLoginModel userInfo = IMLoginManager.get(context).getUserInfo(); IMLoginModel userInfo = IMLoginManager.get(context).getUserInfo();
String IMToken = userInfo.getTokenRong(); String IMToken = userInfo.getTokenRong();
Log.e(CLASSNAME, "connectIM:" + IMToken); Log.e(CLASSNAME, "connectIM:" + IMToken);

View File

@ -235,6 +235,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
.postDelayed(new Runnable() { .postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
// DebugDialog.getInstance(mContext).setParams("测试版本","1.00");
ConversationIMListManager.get(mContext).addUserInfoProvider(); ConversationIMListManager.get(mContext).addUserInfoProvider();
MessageIMManager.get(mContext).resetImUnReadMessageCount(mContext); MessageIMManager.get(mContext).resetImUnReadMessageCount(mContext);
} }