// // XMGMainViewController.m // 备课-百思不得姐 // // Created by MJ Lee on 15/6/15. // Copyright © 2015年 小码哥. All rights reserved. // 20200714 #import "XMGMainViewController.h" #import "JXMsgViewController.h" #import "CYWebAddPointVC.h" #import "XMGNavigationViewController.h" #import "MJTabBar.h" #import "JXXMGMyVc.h" #import "JXBigReelVc.h" #import "JXWellBeingVc.h" #import "JXTabMenuView.h" #import "JXFriendViewController.h" #import "AppDelegate.h" #import "JXNewFriendViewController.h" #import "JXFriendObject.h" #import "PSMyViewController.h" #ifdef Live_Version #import "JXLiveViewController.h" #endif #import "JXProgressVC.h" #import "JXGroupViewController.h" #import "OrganizTreeViewController.h" #import "JXLabelObject.h" #import "JXBlogRemind.h" #import "JXRoomPool.h" #import "JXDeviceAuthController.h" #import "UIColor+Util.h" #import "UIColor+XQColor.h" #import "JXBlogRemind.h" #import "JXBigReelVc.h" #import "JXShowMainView.h" #import "JXNewRegisterVc.h" @interface XMGMainViewController () @end @implementation XMGMainViewController -(instancetype)init{ if (self=[super init]) { [g_notify addObserver:self selector:@selector(loginSynchronizeFriends:) name:kXmppClickLoginNotifaction object:nil]; [g_notify addObserver:self selector:@selector(appDidEnterForeground) name:kApplicationWillEnterForeground object:nil]; [g_notify addObserver:self selector:@selector(getUserInfo:) name:kXMPPMessageUpadteUserInfoNotification object:nil]; [g_notify addObserver:self selector:@selector(getRoomSet:) name:kXMPPMessageUpadteGroupNotification object:nil]; [g_notify addObserver:self selector:@selector(hasLoginOther:) name:kXMPPLoginOtherNotification object:nil]; [g_notify addObserver:self selector:@selector(showDeviceAuth:) name:kDeviceAuthNotification object:nil]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self initViewControllers]; self.tabBar.backgroundColor = [UIColor whiteColor]; // 获取服务器时间 } - (void)viewDidAppear:(BOOL)animated { } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)initViewControllers { JXMsgViewController *controller1 = [[JXMsgViewController alloc] init]; XMGOpenGLNavVc *nav1 = [[XMGOpenGLNavVc alloc] initWithRootViewController:controller1]; nav1.yp_tabItemTitle = @"主页"; JXWellBeingVc *controller2 = [[JXWellBeingVc alloc] init]; controller2.yp_tabItemTitle = @"福利"; JXXMGMyVc *controller3 = [[JXXMGMyVc alloc] init]; controller3.yp_tabItemTitle = @"我"; self.viewControllers = [NSMutableArray arrayWithObjects:nav1, controller2, controller3, nil]; } - (void)appEnterForegroundNotif:(NSNotification *)noti { // [g_server offlineOperation:(g_server.lastOfflineTime *1000 + g_server.timeDifference)/1000 toView:self]; } - (void)getUserInfo:(NSNotification *)noti { JXMessageObject *msg = noti.object; [g_server getUser:msg.toUserId toView:self]; } - (void)getRoomSet:(NSNotification *)noti { JXMessageObject *msg = noti.object; // [g_server getRoom:msg.toUserId toView:self]; } -(void)dealloc{ // [_psMyviewVC.view release]; // [_msgVc.view release]; [g_notify removeObserver:self name:kXmppLoginNotifaction object:nil]; [g_notify removeObserver:self name:kSystemLoginNotifaction object:nil]; [g_notify removeObserver:self name:kXmppClickLoginNotifaction object:nil]; [g_notify removeObserver:self name:kXMPPLoginOtherNotification object:nil]; [g_notify removeObserver:self name:kApplicationWillEnterForeground object:nil]; [g_notify removeObserver:self name:kXMPPMessageUpadteUserInfoNotification object:nil]; [g_notify removeObserver:self name:kDeviceAuthNotification object:nil]; // [super dealloc]; } - (void)appDidEnterForeground { // 获取服务器时间 // [g_server getCurrentTimeToView:self]; } - (void)loginSynchronizeFriends:(NSNotification*)notification{ //判断服务器好友数量是否与本地一致 // _friendArray = [g_server.myself fetchAllFriendsOrNotFromLocal]; // og(@"%d -------%ld",[g_server.myself.friendCount intValue] , [_friendArray count]); // if ([g_server.myself.friendCount intValue] > [_friendArray count] && [g_server.myself.friendCount intValue] >0) { // [g_App showAlert:Localized(@"JXAlert_SynchFirendOK") delegate:self]; if (self.isLoadFriendAndGroup) { [g_server listAttention:0 userId:MY_USER_ID toView:self]; }else{ [[JXXMPP sharedInstance] performSelector:@selector(login) withObject:nil afterDelay:2];//2秒后执行xmpp登录 } [[JXXMPP sharedInstance] performSelector:@selector(login) withObject:nil afterDelay:2];//2秒后执行xmpp登录 // } } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (alertView.tag == 10002) { [g_server performSelector:@selector(showLogin) withObject:nil afterDelay:0.5]; return; }else if (buttonIndex == 1) { [g_server listAttention:0 userId:MY_USER_ID toView:self]; } } -(void)buildTop{ ///NSMutableArray *remindArray = [[JXBlogRemind sharedInstance] doFetchUnread]; } -(void)actionSegment:(UIButton*)sender{ //[self doSelected:(int)sender.tag]; } -(void)hasLoginOther:(NSNotification *)notifcation{ [g_App showAlert:Localized(@"JXXMPP_Other") delegate:self tag:10002 onlyConfirm:YES]; } - (void)showDeviceAuth:(NSNotification *)notification{ JXMessageObject *msg = notification.object; JXDeviceAuthController *authCon = [[JXDeviceAuthController alloc] initWithMsg:msg]; UIViewController *lastVC = (UIViewController *)g_navigation.subViews.lastObject; [lastVC presentViewController:authCon animated:YES completion:nil]; } @end