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