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