|
@@ -16,6 +16,12 @@
|
|
|
|
|
|
#import "CoursewareDownloadManager.h"
|
|
|
|
|
|
+@interface KSLoginManager ()
|
|
|
+
|
|
|
+@property (nonatomic, assign) BOOL isQuitting; // 是否正在退出
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
@implementation KSLoginManager
|
|
|
|
|
|
+ (instancetype)shareInstance {
|
|
@@ -35,17 +41,35 @@
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
+- (void)configSetting {
|
|
|
+ NSLog(@"------configSetting ");
|
|
|
+}
|
|
|
+
|
|
|
- (void)otherLogin {
|
|
|
dispatch_main_async_safe(^{
|
|
|
+ UIWindow *window = [NSObject getKeyWindow];
|
|
|
+ UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController;
|
|
|
|
|
|
+ if ([vc isKindOfClass:[UITabBarController class]]) {
|
|
|
+ UITabBarController *tab = (UITabBarController *)window.rootViewController;
|
|
|
+ CustomNavViewController *ctrl = (CustomNavViewController *)tab.selectedViewController;
|
|
|
+ if ([ctrl.visibleViewController isKindOfClass:NSClassFromString(@"TXClassroomViewController")]) {
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"classroomLogout" object:nil];
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if ([vc.presentedViewController isKindOfClass:NSClassFromString(@"CustomNavViewController")]) {
|
|
|
+ CustomNavViewController *nav = (CustomNavViewController *)vc.presentedViewController;
|
|
|
+ if ([nav.visibleViewController isKindOfClass:NSClassFromString(@"TXLiveRoomViewController")]) {
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"liveroomLogout" object:nil];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ [APPLOGIN_MANAGER logoutActionWithMsg:@"登录过期,请重新登录"];
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-- (void)loginAction {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
- (void)clearUMCount {
|
|
|
[USER_MANAGER sendUMEvent:@"klx_logout"];
|
|
|
[USER_MANAGER stopCountUMEvent];
|
|
@@ -57,12 +81,19 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)logoutAction {
|
|
|
- [self closeDownload];
|
|
|
+- (void)logoutActionWithMsg:(NSString *)msg {
|
|
|
+ if (self.isQuitting) {
|
|
|
+ NSLog(@"----1");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ self.isQuitting = YES;
|
|
|
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshLiveClickStatus" object:nil];
|
|
|
+ [self closeDownload];
|
|
|
[self clearUMCount];
|
|
|
+
|
|
|
+ [KSNetworkingManager cancelAllRequest];
|
|
|
[KSNetworkingManager clearRequestHeader];
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshLiveClickStatus" object:nil];
|
|
|
|
|
|
// 取消推送别名
|
|
|
[JPUSHService deleteAlias:nil seq:0];
|
|
@@ -87,37 +118,36 @@
|
|
|
if (ctrl.presentedViewController) {
|
|
|
UIViewController *presentCtrl = ctrl.presentedViewController;
|
|
|
[presentCtrl dismissViewControllerAnimated:YES completion:^{
|
|
|
- [ctrl popToRootViewControllerAnimated:YES];
|
|
|
- [self resetToLoginViewController:tab];
|
|
|
+ [ctrl popToRootViewControllerAnimated:NO];
|
|
|
+ [self performSelector:@selector(resetToLoginViewController:) withObject:msg afterDelay:0.1];
|
|
|
}];
|
|
|
}
|
|
|
else {
|
|
|
- [ctrl popToRootViewControllerAnimated:YES];
|
|
|
- [self resetToLoginViewController:tab];
|
|
|
+ [ctrl popToRootViewControllerAnimated:NO];
|
|
|
+ [self performSelector:@selector(resetToLoginViewController:) withObject:msg afterDelay:0.1];
|
|
|
}
|
|
|
}
|
|
|
else if ([vc isKindOfClass:NSClassFromString(@"CustomNavViewController")]) {
|
|
|
- // dismiss
|
|
|
if (vc.presentedViewController) {
|
|
|
UIViewController *presentCtrl = vc.presentedViewController;
|
|
|
[presentCtrl dismissViewControllerAnimated:YES completion:^{
|
|
|
CustomNavViewController *ctrl = (CustomNavViewController *)vc;
|
|
|
- [ctrl popToRootViewControllerAnimated:YES];
|
|
|
+ [ctrl popToRootViewControllerAnimated:NO];
|
|
|
+ self.isQuitting = NO;
|
|
|
}];
|
|
|
}
|
|
|
else {
|
|
|
CustomNavViewController *ctrl = (CustomNavViewController *)vc;
|
|
|
- [ctrl popToRootViewControllerAnimated:YES];
|
|
|
+ [ctrl popToRootViewControllerAnimated:NO];
|
|
|
+ self.isQuitting = NO;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)resetToLoginViewController:(UITabBarController *)tab {
|
|
|
+- (void)resetToLoginViewController:(NSString *)tipsMsg {
|
|
|
LoginViewController *logonVC = [[LoginViewController alloc] init];
|
|
|
CustomNavViewController *navCtrl = [[CustomNavViewController alloc] initWithRootViewController:logonVC];
|
|
|
- navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
- [tab.selectedViewController presentViewController:navCtrl animated:YES completion:nil];
|
|
|
-
|
|
|
+ [AppDelegate shareAppDelegate].window.rootViewController = navCtrl;
|
|
|
// 切换到横屏
|
|
|
AppDelegate* delegate = [AppDelegate shareAppDelegate];
|
|
|
if (delegate.allowAutoRotate) {
|
|
@@ -127,6 +157,10 @@
|
|
|
}
|
|
|
[UIDevice switchNewOrientation:UIInterfaceOrientationPortrait inController:logonVC];
|
|
|
}
|
|
|
+ if (![NSString isEmptyString:tipsMsg]) {
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:tipsMsg];
|
|
|
+ }
|
|
|
+ self.isQuitting = NO;
|
|
|
}
|
|
|
|
|
|
- (NSString *)getVisableControllerName {
|