Permalink
Browse files

Fixed big bug in the last commit, mainly for FriendsList. Updated to …

…new for much better CPU usage.
  • Loading branch information...
1 parent c7590af commit 871b7c2290f4b48df3e941a0ca127d651d2685d0 @Jman012 committed Mar 2, 2014
@@ -58,21 +58,6 @@ - (void)viewDidLoad {
else
self.title = _friendInfo.nickname;
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(updateUserInfo)
- name:@"FriendAdded"
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(newMessage:)
- name:@"NewMessage"
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(updateColoredStatusIndicator)
- name:@"FriendUserStatusChanged"
- object:nil];
-
//setup the colored status indicator on the navbar
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
@@ -95,6 +80,21 @@ - (void)viewWillAppear:(BOOL)animated {
- (void)viewDidAppear:(BOOL)animated {
// [self viewDidAppear:animated];
[self.navigationController.navigationBar addSubview:statusNavBarImageView];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(updateUserInfo)
+ name:@"FriendAdded"
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(newMessage:)
+ name:@"NewMessage"
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(updateColoredStatusIndicator)
+ name:@"FriendUserStatusChanged"
+ object:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
@@ -18,36 +18,6 @@ - (void)viewDidLoad {
[super viewDidLoad];
_mainFriendList = [[Singleton sharedSingleton] mainFriendList];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(friendListUpdate)
- name:@"FriendAdded"
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(friendListUpdate)
- name:@"GroupAdded"
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(friendListUpdate)
- name:@"FriendUserStatusChanged"
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(updateRequestsButton)
- name:@"FriendRequestReceived"
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(updateRequestsButton)
- name:@"RejectedFriendRequest"
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(updateRequestsButton)
- name:@"GroupInviteReceived"
- object:nil];
/***** Appearance *****/
@@ -93,6 +63,37 @@ - (void)viewDidLoad {
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self updateRequestsButton];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(friendListUpdate)
+ name:@"FriendAdded"
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(friendListUpdate)
+ name:@"GroupAdded"
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(friendListUpdate)
+ name:@"FriendUserStatusChanged"
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(updateRequestsButton)
+ name:@"FriendRequestReceived"
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(updateRequestsButton)
+ name:@"RejectedFriendRequest"
+ object:nil];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(updateRequestsButton)
+ name:@"GroupInviteReceived"
+ object:nil];
+ [self friendListUpdate];
}
- (void)viewWillDisappear:(BOOL)animated {
@@ -59,12 +59,6 @@ - (void)viewDidLoad
} else {
self.title = _groupInfo.groupName;
}
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(newMessage:)
- name:@"NewMessage"
- object:nil];
-
}
- (void)viewWillAppear:(BOOL)animated {
@@ -74,6 +68,10 @@ - (void)viewWillAppear:(BOOL)animated {
- (void)viewDidAppear:(BOOL)animated {
// [super viewDidAppear:animated];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(newMessage:)
+ name:@"NewMessage"
+ object:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
@@ -26,16 +26,6 @@ - (id)initWithStyle:(UITableViewStyle)style
- (void)viewDidLoad
{
[super viewDidLoad];
-
- // Uncomment the following line to preserve selection between presentations.
- // self.clearsSelectionOnViewWillAppear = NO;
-
- // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
- // self.navigationItem.rightBarButtonItem = self.editButtonItem;
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didGetFriendRequest) name:@"FriendRequestReceived" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didGetGroupInvite) name:@"GroupInviteReceived" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(returnToFriendsList) name:@"QRReaderDidAddFriend" object:nil];
_arrayOfRequests = [[[Singleton sharedSingleton] pendingFriendRequests] allKeys];
_arrayOfInvites = [[[Singleton sharedSingleton] pendingGroupInvites] allKeys];
@@ -112,6 +102,22 @@ - (void)viewWillAppear:(BOOL)animated {
[self.navigationController setToolbarHidden:NO animated:NO];
}
+- (void)viewDidAppear:(BOOL)animated {
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(didGetFriendRequest)
+ name:@"FriendRequestReceived"
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(didGetGroupInvite)
+ name:@"GroupInviteReceived"
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(returnToFriendsList)
+ name:@"QRReaderDidAddFriend"
+ object:nil];
+}
+
- (void)viewWillDisappear:(BOOL)animated {
[self.navigationController setToolbarHidden:YES animated:YES];
[[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -35,12 +35,6 @@ - (void)viewDidLoad
_dhtNodeList = [[Singleton sharedSingleton] dhtNodeList];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addDHTServer:) name:@"NewDHT" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dhtConnected:) name:@"DHTConnected" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dhtDisonnected:) name:@"DHTDisonnected" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didStartDHTNodeConnection:) name:@"DidStartDHTNodeConnection" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFailToConnect:) name:@"DHTFailedToConnect" object:nil];
-
}
- (void)addDHTServer:(NSNotification *)notification {
@@ -95,6 +89,14 @@ - (void)addDHTServer:(NSNotification *)notification {
}
}
+- (void)viewDidAppear:(BOOL)animated {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addDHTServer:) name:@"NewDHT" object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dhtConnected:) name:@"DHTConnected" object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dhtDisonnected:) name:@"DHTDisonnected" object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didStartDHTNodeConnection:) name:@"DidStartDHTNodeConnection" object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFailToConnect:) name:@"DHTFailedToConnect" object:nil];
+}
+
- (void)viewWillDisappear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

0 comments on commit 871b7c2

Please sign in to comment.