Browse Source

replace @implementation NSNotificationCenter (MainThread)

Marino Faggiana 7 years ago
parent
commit
22ca84681f

+ 5 - 5
iOSClient/AppDelegate.m

@@ -352,7 +352,7 @@
             [_activeMain requestServerCapabilities];
     
         NSLog(@"[LOG] Initialize Camera Upload");
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"initStateCameraUpload" object:nil];
+        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initStateCameraUpload" object:nil];
         
         NSLog(@"[LOG] Listning Favorites");
         [[CCSynchronize sharedSynchronize] readListingFavorites];        
@@ -982,7 +982,7 @@
         [NCBrandColor sharedInstance].brand = [NCBrandColor sharedInstance].customer;
     }
     
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"changeTheming" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"changeTheming" object:nil];
 }
 
 - (void)changeTheming:(UIViewController *)vc
@@ -1191,7 +1191,7 @@
     if ([self.reachability isReachableViaWiFi]) NSLog(@"[LOG] Reachability Changed: WiFi");
     if ([self.reachability isReachableViaWWAN]) NSLog(@"[LOG] Reachability Changed: WWAn");
     
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"setTitleMain" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"setTitleMain" object:nil];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -1203,7 +1203,7 @@
     NSLog(@"[LOG] Start Fetch");
     
     // Verify new photo
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"initStateCameraUpload" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initStateCameraUpload" object:nil];
     
     // after 20 sec verify Re
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 20 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
@@ -1537,7 +1537,7 @@
     // Progress Task
     NSDictionary* userInfo = @{@"fileID": (fileID), @"serverUrl": (serverUrl), @"cryptated": ([NSNumber numberWithBool:NO]), @"progress": ([NSNumber numberWithFloat:0.0])};
     
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"NotificationProgressTask" object:nil userInfo:userInfo];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"NotificationProgressTask" object:nil userInfo:userInfo];
 
     // Refresh
     if (_activeMain && [_listChangeTask count] == 0) {

+ 1 - 1
iOSClient/Favorites/CCSynchronize.m

@@ -154,7 +154,7 @@
         if (![filesEtag containsObject:metadata.fileID])
             [[NCManageDatabase sharedInstance] setMetadataFavoriteWithFileID:metadata.fileID favorite:NO];
     
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"clearDateReadDataSource" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"clearDateReadDataSource" object:nil];
 }
 
 - (void)listingFavoritesFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode

+ 22 - 41
iOSClient/Main/CCMain.m

@@ -1130,9 +1130,7 @@
             appDelegate.listOfNotifications = [[NSMutableArray alloc] initWithArray:sortedListOfNotifications];
         
             // reload Notification view
-            dispatch_async(dispatch_get_main_queue(), ^{
-                [[NSNotificationCenter defaultCenter] postNotificationName:@"notificationReloadData" object:nil];
-            });
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"notificationReloadData" object:nil];
         }
     
         // Update NavigationBar
@@ -1185,9 +1183,7 @@
         else
             [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/avatar.png", app.directoryUser] error:nil];
         
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [[NSNotificationCenter defaultCenter] postNotificationName:@"changeUserProfile" object:nil];
-        });
+        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"changeUserProfile" object:nil];
     });
 }
 
@@ -2752,12 +2748,9 @@
             
             if (!findTask) {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    [app.listChangeTask setObject:@"reloadDownload" forKey:fileID];
-                    NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
-                    [[NSNotificationCenter defaultCenter] postNotificationName:k_networkingSessionNotification object:object];
-                });
+                [app.listChangeTask setObject:@"reloadDownload" forKey:fileID];
+                NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
+                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_networkingSessionNotification object:object];
             }
         }];
     }
@@ -2776,12 +2769,9 @@
             
             if (!findTask) {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    [app.listChangeTask setObject:@"reloadUpload" forKey:fileID];
-                    NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
-                    [[NSNotificationCenter defaultCenter] postNotificationName:k_networkingSessionNotification object:object];
-                });
+                [app.listChangeTask setObject:@"reloadUpload" forKey:fileID];
+                NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
+                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_networkingSessionNotification object:object];
             }
         }];
     }
@@ -2825,12 +2815,9 @@
             
             if (!findTask) {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    [app.listChangeTask setObject:@"cancelDownload" forKey:fileID];
-                    NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
-                    [[NSNotificationCenter defaultCenter] postNotificationName:k_networkingSessionNotification object:object];
-                });
+                [app.listChangeTask setObject:@"cancelDownload" forKey:fileID];
+                NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
+                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_networkingSessionNotification object:object];
             }
         }];
     }
@@ -2849,12 +2836,9 @@
             
             if (!findTask) {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    [app.listChangeTask setObject:@"cancelUpload" forKey:fileID];
-                    NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
-                    [[NSNotificationCenter defaultCenter] postNotificationName:k_networkingSessionNotification object:object];
-                });
+                [app.listChangeTask setObject:@"cancelUpload" forKey:fileID];
+                NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
+                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_networkingSessionNotification object:object];
             }
         }];
     }
@@ -2898,12 +2882,9 @@
             
             if (!findTask) {
                 
-                dispatch_async(dispatch_get_main_queue(), ^{
-                    
-                    [app.listChangeTask setObject:@"stopUpload" forKey:fileID];
-                    NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
-                    [[NSNotificationCenter defaultCenter] postNotificationName:k_networkingSessionNotification object:object];
-                });
+                [app.listChangeTask setObject:@"stopUpload" forKey:fileID];
+                NSArray *object = [[NSArray alloc] initWithObjects:session, fileID, findTask, nil];
+                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_networkingSessionNotification object:object];
             }
         }];
     }
@@ -3249,7 +3230,7 @@
     [CCUtility setOrderSettings:order];
     
     // Clear data-read of DataSource
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"clearDateReadDataSource" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"clearDateReadDataSource" object:nil];
 }
 
 - (void)ascendingTable:(BOOL)ascending
@@ -3257,7 +3238,7 @@
     [CCUtility setAscendingSettings:ascending];
     
     // Clear data-read of DataSource
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"clearDateReadDataSource" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"clearDateReadDataSource" object:nil];
 }
 
 - (void)directoryOnTop:(BOOL)directoryOnTop
@@ -3265,7 +3246,7 @@
     [CCUtility setDirectoryOnTop:directoryOnTop];
     
     // Clear data-read of DataSource
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"clearDateReadDataSource" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"clearDateReadDataSource" object:nil];
 }
 
 - (void)tableGroupBy:(NSString *)groupBy
@@ -3273,7 +3254,7 @@
     [CCUtility setGroupBySettings:groupBy];
     
     // Clear data-read of DataSource
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"clearDateReadDataSource" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"clearDateReadDataSource" object:nil];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -3365,7 +3346,7 @@
             [app settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activePassword:tableAccount.password];
     
         // go to home sweet home
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
+        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
         
         [_ImageTitleHomeCryptoCloud setUserInteractionEnabled:YES];
     });

+ 2 - 2
iOSClient/Main/CCSplit.m

@@ -93,7 +93,7 @@
     self.version = [CCUtility setVersionCryptoCloud];
     
     // init home
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -135,7 +135,7 @@
 
 - (void)loginSuccess:(NSInteger)loginType
 {
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
 }
 
 - (void)newAccount

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -333,7 +333,7 @@
             [self recalculateSize];
             
             // Inizialized home
-            [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
             
             [self.hud hideHud];
         });

+ 2 - 2
iOSClient/Settings/CCManageAccount.m

@@ -189,7 +189,7 @@
 - (void)loginSuccess:(NSInteger)loginType
 {
     if (loginType == loginAddForced)
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
+        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -364,7 +364,7 @@
         [app settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activePassword:tableAccount.password];
  
     // Init home
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"initializeMain" object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil];
         
     [self UpdateForm];
 }

+ 2 - 2
iOSClient/Settings/CCManageCameraUpload.m

@@ -240,7 +240,7 @@
         }
         
         // Initialize Camera Upload
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"initStateCameraUpload" object:nil];
+        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initStateCameraUpload" object:nil];
         
         [self reloadForm];
     }
@@ -277,7 +277,7 @@
         
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
             
-            [[NSNotificationCenter defaultCenter] postNotificationName:@"setupCameraUploadFull" object:nil];
+            [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"setupCameraUploadFull" object:nil];
             [[NCManageDatabase sharedInstance] setAccountCameraStateFiled:@"cameraUploadFull" state:YES];
             
         } else {

+ 1 - 1
iOSClient/Utility/CCExifGeo.m

@@ -120,7 +120,7 @@
                 NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:exifDate, fileID, nil];
                 
                 // Notify for CCDetail
-                [[NSNotificationCenter defaultCenter] postNotificationName:@"insertGeocoderLocation" object:nil userInfo:dictionary];
+                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"insertGeocoderLocation" object:nil userInfo:dictionary];
             }
         } else {
             //NSLog(@"[LOG] setGeocoderFileID : %@", error.debugDescription);

+ 1 - 1
iOSClient/Utility/NSNotificationCenter+MainThread.m

@@ -23,7 +23,7 @@
 
 #import "NSNotificationCenter+MainThread.h"
 
-@implementation NSNotificationCenter_MainThread
+@implementation NSNotificationCenter (MainThread)
 
 - (void)postNotificationOnMainThread:(NSNotification *)notification
 {