退出登录时增加过程弹窗, 防止过早或过慢清除token造成的页面错误
This commit is contained in:
@ -273,7 +273,7 @@ public class LoginUtils {
|
||||
}
|
||||
|
||||
// 注销登录
|
||||
public static void logout(final Context context) {
|
||||
public static void logout(final Context context, final OnLogoutListener listener) {
|
||||
|
||||
RetrofitManager.getInstance(context)
|
||||
.getUsersea()
|
||||
@ -281,9 +281,19 @@ public class LoginUtils {
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
super.onResponse(response);
|
||||
cleanUserData(context);
|
||||
listener.onCompleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
super.onFailure(e);
|
||||
cleanUserData(context);
|
||||
listener.onCompleted();
|
||||
if (e == null) {
|
||||
Utils.toast(context, "请检查网络是否可用");
|
||||
return;
|
||||
@ -299,8 +309,6 @@ public class LoginUtils {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cleanUserData(context);
|
||||
}
|
||||
|
||||
// 清除本地用户相关信息
|
||||
@ -663,6 +671,11 @@ public class LoginUtils {
|
||||
|
||||
}
|
||||
|
||||
// 更改用户信息回调
|
||||
public interface OnLogoutListener {
|
||||
void onCompleted();
|
||||
}
|
||||
|
||||
// 更改用户信息回调
|
||||
public interface onChangeUserInfoListener {
|
||||
void onChange();
|
||||
|
||||
Reference in New Issue
Block a user