Commit b932b573b1b2cd4bce5151eee1e1b3a1b2cce8a7
1 parent
7138f165
Exists in
yxb_dev
and in
2 other branches
no message
Showing
3 changed files
with
11 additions
and
2 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/AppContext.java
| ... | ... | @@ -14,7 +14,6 @@ import com.netease.nimlib.sdk.SDKOptions; |
| 14 | 14 | import com.netease.nimlib.sdk.StatusBarNotificationConfig; |
| 15 | 15 | import com.netease.nimlib.sdk.auth.LoginInfo; |
| 16 | 16 | import com.share.mvpsdk.global.GlobalApplication; |
| 17 | -import com.amap.api.location.AMapLocationClientOption.AMapLocationMode; | |
| 18 | 17 | import com.share.mvpsdk.helper.RetrofitCreateHelper; |
| 19 | 18 | import com.shunzhi.parent.bean.message.DaoMaster; |
| 20 | 19 | import com.shunzhi.parent.bean.message.DaoMaster.DevOpenHelper; |
| ... | ... | @@ -24,6 +23,8 @@ import com.shunzhi.parent.ui.MainActivity; |
| 24 | 23 | |
| 25 | 24 | import org.greenrobot.greendao.database.Database; |
| 26 | 25 | |
| 26 | +import timber.log.Timber; | |
| 27 | + | |
| 27 | 28 | /** |
| 28 | 29 | * Created by Administrator on 2018/3/7 0007. |
| 29 | 30 | */ |
| ... | ... | @@ -97,6 +98,7 @@ public class AppContext extends GlobalApplication { |
| 97 | 98 | SharedPreferences sp = getSharedPreferences("info", Context.MODE_PRIVATE); |
| 98 | 99 | String account = sp.getString("account", ""); |
| 99 | 100 | String token = sp.getString("token", ""); |
| 101 | + Timber.i("---===account: %s token : %s",account,token); | |
| 100 | 102 | if (account.length() > 0 && token.length() > 0) { |
| 101 | 103 | return new LoginInfo(account, token); |
| 102 | 104 | } | ... | ... |
app/src/main/java/com/shunzhi/parent/manager/MessageManager.java
| ... | ... | @@ -78,6 +78,7 @@ public class MessageManager { |
| 78 | 78 | @Override |
| 79 | 79 | public void onEvent(StatusCode statusCode) { |
| 80 | 80 | if (statusCode == StatusCode.KICKOUT) { |
| 81 | + MessageManager.getInstance().logout(); | |
| 81 | 82 | Context context = AppContext.getInstance(); |
| 82 | 83 | Intent i = new Intent(context, LoginAndRegistActivity.class); |
| 83 | 84 | i.putExtra("type", "登录"); |
| ... | ... | @@ -175,7 +176,7 @@ public class MessageManager { |
| 175 | 176 | sp.edit().putString("token", password).apply(); |
| 176 | 177 | NIMClient.getService(AuthService.class) |
| 177 | 178 | .login(new LoginInfo(account, password)) |
| 178 | - .setCallback(new RequestCallback() { | |
| 179 | + .setCallback(new RequestCallback<Object>() { | |
| 179 | 180 | @Override |
| 180 | 181 | public void onSuccess(Object o) { |
| 181 | 182 | NIMLoginResultBean bean = new NIMLoginResultBean(true, 200, null); |
| ... | ... | @@ -204,9 +205,13 @@ public class MessageManager { |
| 204 | 205 | |
| 205 | 206 | |
| 206 | 207 | public void logout() { |
| 208 | + SharedPreferences sp = AppContext.getInstance().getApplicationContext().getSharedPreferences("info", Context.MODE_PRIVATE); | |
| 209 | + sp.edit().putString("account", "").apply(); | |
| 210 | + sp.edit().putString("token", "").apply(); | |
| 207 | 211 | NIMClient.getService(MsgServiceObserve.class).observeReceiveMessage(messageObserver, false); |
| 208 | 212 | NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(customNotificationObserver, false); |
| 209 | 213 | NIMClient.getService(AuthService.class).logout(); |
| 214 | + | |
| 210 | 215 | } |
| 211 | 216 | |
| 212 | 217 | public interface NIMLoginCallback { | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java
| ... | ... | @@ -21,6 +21,7 @@ import com.shunzhi.parent.AppContext; |
| 21 | 21 | import com.shunzhi.parent.R; |
| 22 | 22 | import com.shunzhi.parent.contract.loginandregister.LoginAndRegisterContract; |
| 23 | 23 | import com.shunzhi.parent.contract.mine.MineContract; |
| 24 | +import com.shunzhi.parent.manager.MessageManager; | |
| 24 | 25 | import com.shunzhi.parent.presenter.mine.MinePresenter; |
| 25 | 26 | import com.shunzhi.parent.ui.activity.LoginAndRegistActivity; |
| 26 | 27 | import com.shunzhi.parent.ui.activity.MyChildActivity; |
| ... | ... | @@ -190,6 +191,7 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract |
| 190 | 191 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.LOGIN_NAME, ""); |
| 191 | 192 | AppConfig.ISLOGIN = false; |
| 192 | 193 | setPersonInfo(); |
| 194 | + MessageManager.getInstance().logout(); | |
| 193 | 195 | startActivity(new Intent().putExtra("type", "登录").setClass(getActivity(), LoginAndRegistActivity.class)); |
| 194 | 196 | // getActivity().finish(); |
| 195 | 197 | } | ... | ... |