XMGMainViewController.m 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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(onXmppLoginChanged:) name:kXmppLoginNotifaction object:nil];
  48. [g_notify addObserver:self selector:@selector(hasLoginOther:) name:kXMPPLoginOtherNotification object:nil];
  49. [g_notify addObserver:self selector:@selector(showDeviceAuth:) name:kDeviceAuthNotification object:nil];
  50. }
  51. return self;
  52. }
  53. - (void)viewDidLoad {
  54. [super viewDidLoad];
  55. [self initViewControllers];
  56. self.tabBar.backgroundColor = [UIColor whiteColor];
  57. // 获取服务器时间
  58. }
  59. - (void)viewDidAppear:(BOOL)animated {
  60. }
  61. - (void)didReceiveMemoryWarning {
  62. [super didReceiveMemoryWarning];
  63. }
  64. - (void)initViewControllers {
  65. JXMsgViewController *controller1 = [[JXMsgViewController alloc] init];
  66. XMGOpenGLNavVc *nav1 = [[XMGOpenGLNavVc alloc] initWithRootViewController:controller1];
  67. nav1.yp_tabItemTitle = @"主页";
  68. JXWellBeingVc *controller2 = [[JXWellBeingVc alloc] init];
  69. controller2.yp_tabItemTitle = @"福利";
  70. JXXMGMyVc *controller3 = [[JXXMGMyVc alloc] init];
  71. controller3.yp_tabItemTitle = @"我";
  72. self.viewControllers = [NSMutableArray arrayWithObjects:nav1, controller2, controller3, nil];
  73. }
  74. - (void)appEnterForegroundNotif:(NSNotification *)noti {
  75. // [g_server offlineOperation:(g_server.lastOfflineTime *1000 + g_server.timeDifference)/1000 toView:self];
  76. }
  77. - (void)getUserInfo:(NSNotification *)noti {
  78. JXMessageObject *msg = noti.object;
  79. [g_server getUser:msg.toUserId toView:self];
  80. }
  81. - (void)getRoomSet:(NSNotification *)noti {
  82. JXMessageObject *msg = noti.object;
  83. // [g_server getRoom:msg.toUserId toView:self];
  84. }
  85. -(void)dealloc{
  86. // [_psMyviewVC.view release];
  87. // [_msgVc.view release];
  88. [g_notify removeObserver:self name:kXmppLoginNotifaction object:nil];
  89. [g_notify removeObserver:self name:kSystemLoginNotifaction object:nil];
  90. [g_notify removeObserver:self name:kXmppClickLoginNotifaction object:nil];
  91. [g_notify removeObserver:self name:kXMPPLoginOtherNotification object:nil];
  92. [g_notify removeObserver:self name:kApplicationWillEnterForeground object:nil];
  93. [g_notify removeObserver:self name:kXMPPMessageUpadteUserInfoNotification object:nil];
  94. [g_notify removeObserver:self name:kDeviceAuthNotification object:nil];
  95. // [super dealloc];
  96. }
  97. - (void)appDidEnterForeground {
  98. // 获取服务器时间
  99. // [g_server getCurrentTimeToView:self];
  100. }
  101. - (void)loginSynchronizeFriends:(NSNotification*)notification{
  102. //判断服务器好友数量是否与本地一致
  103. // _friendArray = [g_server.myself fetchAllFriendsOrNotFromLocal];
  104. // og(@"%d -------%ld",[g_server.myself.friendCount intValue] , [_friendArray count]);
  105. // if ([g_server.myself.friendCount intValue] > [_friendArray count] && [g_server.myself.friendCount intValue] >0) {
  106. // [g_App showAlert:Localized(@"JXAlert_SynchFirendOK") delegate:self];
  107. if (self.isLoadFriendAndGroup) {
  108. [g_server listAttention:0 userId:MY_USER_ID toView:self];
  109. }else{
  110. [[JXXMPP sharedInstance] performSelector:@selector(login) withObject:nil afterDelay:2];//2秒后执行xmpp登录
  111. }
  112. [[JXXMPP sharedInstance] performSelector:@selector(login) withObject:nil afterDelay:2];//2秒后执行xmpp登录
  113. // }
  114. }
  115. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
  116. if (alertView.tag == 10002) {
  117. [g_server performSelector:@selector(showLogin) withObject:nil afterDelay:0.5];
  118. return;
  119. }else if (buttonIndex == 1) {
  120. [g_server listAttention:0 userId:MY_USER_ID toView:self];
  121. }
  122. }
  123. -(void)buildTop{
  124. ///NSMutableArray *remindArray = [[JXBlogRemind sharedInstance] doFetchUnread];
  125. }
  126. -(void)actionSegment:(UIButton*)sender{
  127. //[self doSelected:(int)sender.tag];
  128. }
  129. -(void)onXmppLoginChanged:(NSNumber*)isLogin{
  130. if([JXXMPP sharedInstance].isLogined == login_status_yes){
  131. // 获取离线调用接口列表
  132. CGFloat lastOffLineTime=(g_server.lastOfflineTime *1000 + 0)/1000;
  133. CGFloat lastOffLineTime2=(g_server.timeDifference)/1000;
  134. // [g_server offlineOperation:(g_server.lastOfflineTime *1000 + g_server.timeDifference)/1000 toView:self];
  135. [self onAfterLogin];
  136. }
  137. }
  138. -(void)onAfterLogin{
  139. // [_msgVc scrollToPageUp];
  140. }
  141. -(void)hasLoginOther:(NSNotification *)notifcation{
  142. [g_App showAlert:Localized(@"JXXMPP_Other") delegate:self tag:10002 onlyConfirm:YES];
  143. }
  144. - (void)showDeviceAuth:(NSNotification *)notification{
  145. JXMessageObject *msg = notification.object;
  146. JXDeviceAuthController *authCon = [[JXDeviceAuthController alloc] initWithMsg:msg];
  147. UIViewController *lastVC = (UIViewController *)g_navigation.subViews.lastObject;
  148. [lastVC presentViewController:authCon animated:YES completion:nil];
  149. }
  150. @end