Commit 35f2acad1cda86a3fd2aa6b04a68e6be18634c59
1 parent
beafeb7e
Exists in
yxb_dev
and in
2 other branches
no message
Showing
1 changed file
with
13 additions
and
0 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/manager/MessageManager.java
1 | 1 | package com.shunzhi.parent.manager; |
2 | 2 | |
3 | 3 | import android.content.Context; |
4 | +import android.content.Intent; | |
4 | 5 | import android.content.SharedPreferences; |
5 | 6 | import android.support.annotation.NonNull; |
6 | 7 | |
7 | 8 | import com.netease.nimlib.sdk.NIMClient; |
8 | 9 | import com.netease.nimlib.sdk.Observer; |
9 | 10 | import com.netease.nimlib.sdk.RequestCallback; |
11 | +import com.netease.nimlib.sdk.StatusCode; | |
10 | 12 | import com.netease.nimlib.sdk.auth.AuthService; |
13 | +import com.netease.nimlib.sdk.auth.AuthServiceObserver; | |
11 | 14 | import com.netease.nimlib.sdk.auth.LoginInfo; |
12 | 15 | import com.netease.nimlib.sdk.msg.MsgServiceObserve; |
13 | 16 | import com.netease.nimlib.sdk.msg.model.CustomNotification; |
... | ... | @@ -15,6 +18,7 @@ import com.netease.nimlib.sdk.msg.model.IMMessage; |
15 | 18 | import com.share.mvpsdk.utils.ToastUtils; |
16 | 19 | import com.shunzhi.parent.AppContext; |
17 | 20 | import com.shunzhi.parent.bean.NIMLoginResultBean; |
21 | +import com.shunzhi.parent.ui.activity.LoginAndRegistActivity; | |
18 | 22 | |
19 | 23 | import java.util.List; |
20 | 24 | |
... | ... | @@ -53,6 +57,15 @@ public class MessageManager { |
53 | 57 | private MessageManager() { |
54 | 58 | NIMClient.getService(MsgServiceObserve.class).observeReceiveMessage(messageObserver, true); |
55 | 59 | NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(customNotificationObserver, true); |
60 | + NIMClient.getService(AuthServiceObserver.class).observeOnlineStatus(new Observer<StatusCode>() { | |
61 | + @Override | |
62 | + public void onEvent(StatusCode statusCode) { | |
63 | + if (statusCode==StatusCode.KICKOUT){ | |
64 | + Intent i = new Intent(AppContext.getInstance(), LoginAndRegistActivity.class); | |
65 | + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); | |
66 | + } | |
67 | + } | |
68 | + },true); | |
56 | 69 | |
57 | 70 | } |
58 | 71 | ... | ... |