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