XMGMainViewController.m 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. //
  2. // XMGMainViewController.m
  3. // 备课-百思不得姐
  4. //
  5. // Created by MJ Lee on 15/6/15.
  6. // Copyright © 2015年 小码哥. All rights reserved.
  7. // 20200714
  8. #import "XMGMainViewController.h"
  9. #import "JXMsgViewController.h"
  10. #import "CYWebAddPointVC.h"
  11. #import "XMGNavigationViewController.h"
  12. #import "MJTabBar.h"
  13. #import "JXXMGMyVc.h"
  14. #import "JXBigReelVc.h"
  15. #import "JXWellBeingVc.h"
  16. #import "JXTabMenuView.h"
  17. #import "JXFriendViewController.h"
  18. #import "AppDelegate.h"
  19. #import "JXNewFriendViewController.h"
  20. #import "JXFriendObject.h"
  21. #import "PSMyViewController.h"
  22. #ifdef Live_Version
  23. #import "JXLiveViewController.h"
  24. #endif
  25. #import "JXProgressVC.h"
  26. #import "JXGroupViewController.h"
  27. #import "OrganizTreeViewController.h"
  28. #import "JXLabelObject.h"
  29. #import "JXBlogRemind.h"
  30. #import "JXRoomPool.h"
  31. #import "JXDeviceAuthController.h"
  32. #import "UIColor+Util.h"
  33. #import "UIColor+XQColor.h"
  34. #import "JXBlogRemind.h"
  35. #import "JXBigReelVc.h"
  36. #import "JXShowMainView.h"
  37. #import "JXNewRegisterVc.h"
  38. @interface XMGMainViewController ()
  39. @end
  40. @implementation XMGMainViewController
  41. -(instancetype)init{
  42. if (self=[super init]) {
  43. [g_notify addObserver:self selector:@selector(loginSynchronizeFriends:) name:kXmppClickLoginNotifaction object:nil];
  44. [g_notify addObserver:self selector:@selector(appDidEnterForeground) name:kApplicationWillEnterForeground object:nil];
  45. [g_notify addObserver:self selector:@selector(getUserInfo:) name:kXMPPMessageUpadteUserInfoNotification object:nil];
  46. [g_notify addObserver:self selector:@selector(getRoomSet:) name:kXMPPMessageUpadteGroupNotification object:nil];
  47. [g_notify addObserver:self selector:@selector(hasLoginOther:) name:kXMPPLoginOtherNotification object:nil];
  48. [g_notify addObserver:self selector:@selector(showDeviceAuth:) name:kDeviceAuthNotification object:nil];
  49. }
  50. return self;
  51. }
  52. - (void)viewDidLoad {
  53. [super viewDidLoad];
  54. [self initViewControllers];
  55. self.tabBar.backgroundColor = [UIColor whiteColor];
  56. // 获取服务器时间
  57. }
  58. - (void)viewDidAppear:(BOOL)animated {
  59. }
  60. - (void)didReceiveMemoryWarning {
  61. [super didReceiveMemoryWarning];
  62. }
  63. - (void)initViewControllers {
  64. JXMsgViewController *controller1 = [[JXMsgViewController alloc] init];
  65. XMGOpenGLNavVc *nav1 = [[XMGOpenGLNavVc alloc] initWithRootViewController:controller1];
  66. nav1.yp_tabItemTitle = @"主页";
  67. JXWellBeingVc *controller2 = [[JXWellBeingVc alloc] init];
  68. controller2.yp_tabItemTitle = @"福利";
  69. JXXMGMyVc *controller3 = [[JXXMGMyVc alloc] init];
  70. controller3.yp_tabItemTitle = @"我";
  71. self.viewControllers = [NSMutableArray arrayWithObjects:nav1, controller2, controller3, nil];
  72. }
  73. - (void)appEnterForegroundNotif:(NSNotification *)noti {
  74. // [g_server offlineOperation:(g_server.lastOfflineTime *1000 + g_server.timeDifference)/1000 toView:self];
  75. }
  76. - (void)getUserInfo:(NSNotification *)noti {
  77. JXMessageObject *msg = noti.object;
  78. [g_server getUser:msg.toUserId toView:self];
  79. }
  80. - (void)getRoomSet:(NSNotification *)noti {
  81. JXMessageObject *msg = noti.object;
  82. // [g_server getRoom:msg.toUserId toView:self];
  83. }
  84. -(void)dealloc{
  85. // [_psMyviewVC.view release];
  86. // [_msgVc.view release];
  87. [g_notify removeObserver:self name:kXmppLoginNotifaction object:nil];
  88. [g_notify removeObserver:self name:kSystemLoginNotifaction object:nil];
  89. [g_notify removeObserver:self name:kXmppClickLoginNotifaction object:nil];
  90. [g_notify removeObserver:self name:kXMPPLoginOtherNotification object:nil];
  91. [g_notify removeObserver:self name:kApplicationWillEnterForeground object:nil];
  92. [g_notify removeObserver:self name:kXMPPMessageUpadteUserInfoNotification object:nil];
  93. [g_notify removeObserver:self name:kDeviceAuthNotification object:nil];
  94. // [super dealloc];
  95. }
  96. - (void)appDidEnterForeground {
  97. // 获取服务器时间
  98. // [g_server getCurrentTimeToView:self];
  99. }
  100. - (void)loginSynchronizeFriends:(NSNotification*)notification{
  101. //判断服务器好友数量是否与本地一致
  102. // _friendArray = [g_server.myself fetchAllFriendsOrNotFromLocal];
  103. // og(@"%d -------%ld",[g_server.myself.friendCount intValue] , [_friendArray count]);
  104. // if ([g_server.myself.friendCount intValue] > [_friendArray count] && [g_server.myself.friendCount intValue] >0) {
  105. // [g_App showAlert:Localized(@"JXAlert_SynchFirendOK") delegate:self];
  106. if (self.isLoadFriendAndGroup) {
  107. [g_server listAttention:0 userId:MY_USER_ID toView:self];
  108. }else{
  109. [[JXXMPP sharedInstance] performSelector:@selector(login) withObject:nil afterDelay:2];//2秒后执行xmpp登录
  110. }
  111. [[JXXMPP sharedInstance] performSelector:@selector(login) withObject:nil afterDelay:2];//2秒后执行xmpp登录
  112. // }
  113. }
  114. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
  115. if (alertView.tag == 10002) {
  116. [g_server performSelector:@selector(showLogin) withObject:nil afterDelay:0.5];
  117. return;
  118. }else if (buttonIndex == 1) {
  119. [g_server listAttention:0 userId:MY_USER_ID toView:self];
  120. }
  121. }
  122. -(void)buildTop{
  123. ///NSMutableArray *remindArray = [[JXBlogRemind sharedInstance] doFetchUnread];
  124. }
  125. -(void)actionSegment:(UIButton*)sender{
  126. //[self doSelected:(int)sender.tag];
  127. }
  128. -(void)hasLoginOther:(NSNotification *)notifcation{
  129. [g_App showAlert:Localized(@"JXXMPP_Other") delegate:self tag:10002 onlyConfirm:YES];
  130. }
  131. - (void)showDeviceAuth:(NSNotification *)notification{
  132. JXMessageObject *msg = notification.object;
  133. JXDeviceAuthController *authCon = [[JXDeviceAuthController alloc] initWithMsg:msg];
  134. UIViewController *lastVC = (UIViewController *)g_navigation.subViews.lastObject;
  135. [lastVC presentViewController:authCon animated:YES completion:nil];
  136. }
  137. @end