Эх сурвалжийг харах

New function synchronizationAnimationWithViewController

Marino Faggiana 8 жил өмнө
parent
commit
a72c4095ef

+ 7 - 26
iOSClient/AppDelegate.m

@@ -399,31 +399,12 @@
 
 - (void)verifyProcess
 {
-    // BACKGROND & FOREGROUND
+// BACKGROND & FOREGROUND
     
-    /* Disactive Graphics Animation Synchronization Folders */
-    
-    NSMutableOrderedSet *serversUrlDownload = [[NSMutableOrderedSet alloc] init];
-    NSMutableArray *metadatasNet = [self verifyExistsInQueuesDownloadSelector:selectorDownloadSynchronized];
-    for (CCMetadataNet *metadataNet in metadatasNet)
-        [serversUrlDownload addObject:metadataNet.serverUrl];
-    
-    NSMutableOrderedSet *synchronizationServerUrlInProgressTemp = [[NSMutableOrderedSet alloc] initWithOrderedSet:[CCSynchronization sharedSynchronization].synchronizationServerUrlInProgress copyItems:YES];
-    for (NSString *serverUrl in synchronizationServerUrlInProgressTemp) {
-        
-        if ([serversUrlDownload containsObject:serverUrl] == NO) {
-            
-            NSString *serverUrlSynchronized = [CCUtility deletingLastPathComponentFromServerUrl:serverUrl];
-            CCMain *viewController = [app.listMainVC objectForKey:serverUrlSynchronized];
-            if (viewController)
-                [viewController synchronizedFolderGraphicsCell:nil serverUrl:serverUrl animation:NO];
-            
-            // remove
-            [[CCSynchronization sharedSynchronization].synchronizationServerUrlInProgress removeObject:serversUrlDownload];
-        }
-    }
-    
-    // ONLY BACKGROUND
+    /* Active/Disactive Graphics Animation Synchronization Folders */
+    [[CCSynchronization sharedSynchronization] synchronizationAnimationWithViewController:YES];
+
+// ONLY BACKGROUND
     
     if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
     
@@ -432,8 +413,8 @@
         NSLog(@"5 sec. %lu", (unsigned long)[metadatasNet count]);
 
     } else {
-        
-    // ONLY FOREFROUND
+
+// ONLY FOREFROUND
     
     }
 }

+ 1 - 2
iOSClient/Main/CCMain.h

@@ -86,7 +86,6 @@
 
 @property (nonatomic, weak) CCLoginNCOC *loginVC;
 
-
 - (void)createFolderCameraUpload;
 - (void)createFolder:(NSString *)fileNameFolder folderCameraUpload:(BOOL)folderCameraUpload;
 - (void)readFolderWithForced:(BOOL)forced;
@@ -105,7 +104,7 @@
 - (void)requestSharedByServer;
 - (void)requestServerInformation;
 
-- (void)synchronizedFolderGraphicsCell:(CCCellMainTransfer *)cell serverUrl:(NSString *)serverUrl animation:(BOOL)animation;
+- (void)synchronizedFolderGraphicsServerUrl:(NSString *)serverUrl animation:(BOOL)animation;
 
 - (void)clearDateReadDataSource:(NSNotification *)notification;
 

+ 34 - 11
iOSClient/Main/CCMain.m

@@ -5010,6 +5010,29 @@
         
         lunghezzaFile = @" ";
         
+        // ----------------------------------------------------------------------------------------------------------
+        // Synchronize
+        // ----------------------------------------------------------------------------------------------------------
+        
+        NSString *synchronizedServerUrl = [CCUtility stringAppendServerUrl:_localServerUrl addServerUrl:metadata.fileNameData];
+        if ([CCCoreData isSynchronizedDirectory:synchronizedServerUrl activeAccount:app.activeAccount]) {
+            
+            if ([[CCSynchronization sharedSynchronization] synchronizationAnimationWithViewController:NO]) {
+                
+                NSURL *myURL;
+                
+                if (metadata.cryptated) myURL = [[NSBundle mainBundle] URLForResource: @"synchronizedcrypto" withExtension:@"gif"];
+                else myURL = [[NSBundle mainBundle] URLForResource: @"synchronized" withExtension:@"gif"];
+                
+                cell.synchronizedImageView.image = [UIImage animatedImageWithAnimatedGIFURL:myURL];
+                
+            } else {
+                
+                if (metadata.cryptated) cell.synchronizedImageView.image = [UIImage imageNamed:image_synchronizedcrypto];
+                else cell.synchronizedImageView.image = [UIImage imageNamed:image_synchronized];
+            }
+        }
+
     } else {
     
         // è un file
@@ -5456,25 +5479,25 @@
 #pragma mark ===== Synchronize Cell =====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)synchronizedFolderGraphicsCell:(CCCellMainTransfer *)cell serverUrl:(NSString *)serverUrl animation:(BOOL)animation
+- (void)synchronizedFolderGraphicsServerUrl:(NSString *)serverUrl animation:(BOOL)animation
 {
     BOOL cryptated = NO;
+    CCCellMain *cell;
     
-    if (!cell)
-        for (NSString* fileID in _sectionDataSource.allRecordsDataSource) {
+    for (NSString* fileID in _sectionDataSource.allRecordsDataSource) {
         
-            CCMetadata *recordMetadata = [_sectionDataSource.allRecordsDataSource objectForKey:fileID];
+        CCMetadata *recordMetadata = [_sectionDataSource.allRecordsDataSource objectForKey:fileID];
         
-            if (recordMetadata.directory == NO) continue;
-            if ([[CCUtility stringAppendServerUrl:_localServerUrl addServerUrl:recordMetadata.fileNameData] isEqualToString:serverUrl]) {
+        if (recordMetadata.directory == NO) continue;
+        if ([[CCUtility stringAppendServerUrl:_localServerUrl addServerUrl:recordMetadata.fileNameData] isEqualToString:serverUrl]) {
             
-                NSIndexPath *indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:recordMetadata.fileID];
-                cell = (CCCellMainTransfer *)[self.tableView cellForRowAtIndexPath:indexPath];
-                cryptated = recordMetadata.cryptated;
+            NSIndexPath *indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:recordMetadata.fileID];
+            cell = (CCCellMain *)[self.tableView cellForRowAtIndexPath:indexPath];
+            cryptated = recordMetadata.cryptated;
                 
-                break;
-            }
+            break;
         }
+    }
 
     if (!cell)
         return;

+ 3 - 1
iOSClient/Synchronization/CCSynchronization.h

@@ -25,11 +25,11 @@
 
 #import "CCMetadata.h"
 #import "CCHud.h"
+#import "CCCellMain.h"
 
 @interface CCSynchronization : NSObject
 
 @property (nonatomic, strong) CCHud *hud;
-@property (nonatomic, strong) NSMutableOrderedSet *synchronizationServerUrlInProgress;
 
 + (CCSynchronization *)sharedSynchronization;
 
@@ -38,4 +38,6 @@
 
 - (void)verifyChangeMedatas:(NSArray *)allRecordMetadatas serverUrl:(NSString *)serverUrl directoryID:(NSString *)directoryID account:(NSString *)account synchronization:(BOOL)synchronization;
 
+- (BOOL)synchronizationAnimationWithViewController:(BOOL)callViewController;
+
 @end

+ 27 - 14
iOSClient/Synchronization/CCSynchronization.m

@@ -42,7 +42,6 @@
         if (!sharedSynchronization) {
             
             sharedSynchronization = [[CCSynchronization alloc] init];
-            sharedSynchronization.synchronizationServerUrlInProgress = [[NSMutableOrderedSet alloc] init];
         }
         return sharedSynchronization;
     }
@@ -333,20 +332,9 @@
                 [app addNetworkingOperationQueue:app.netQueueDownloadWWan delegate:app.activeMain metadataNet:metadataNet oneByOne:YES];
             else
                 [app addNetworkingOperationQueue:app.netQueueDownload delegate:app.activeMain metadataNet:metadataNet oneByOne:YES];
-            
-            // Insert serverUrl for check animation
-            [[CCSynchronization sharedSynchronization].synchronizationServerUrlInProgress addObject:serverUrl];
         }
     
-        /* Active Graphics Animation Synchronization Folders */
-        
-        for(NSString *serverUrl in [CCSynchronization sharedSynchronization].synchronizationServerUrlInProgress) {
-            
-            NSString *serverUrlSynchronized = [CCUtility deletingLastPathComponentFromServerUrl:serverUrl];
-            CCMain *viewController = [app.listMainVC objectForKey:serverUrlSynchronized];
-            if (viewController)
-                [viewController synchronizedFolderGraphicsCell:nil serverUrl:serverUrl animation:YES];
-        }
+        [[CCSynchronization sharedSynchronization] synchronizationAnimationWithViewController:nil];
          
         [app.activeMain getDataSourceWithReloadTableView:directoryID fileID:nil selector:nil];
         
@@ -354,9 +342,34 @@
     });
 }
 
-- (void)cellAnimation
+/* Graphics Animation Synchronization Folders */
+
+- (BOOL)synchronizationAnimationWithViewController:(BOOL)callViewController
 {
+    NSMutableOrderedSet *serversUrlInDownload = [[NSMutableOrderedSet alloc] init];
+    
+    NSMutableArray *metadatasNet = [app verifyExistsInQueuesDownloadSelector:selectorDownloadSynchronized];
+    
+    for (CCMetadataNet *metadataNet in metadatasNet)
+        [serversUrlInDownload addObject:metadataNet.serverUrl];
+    
+    /* Animation ON/OFF */
+    NSArray *synchronizedDirectory = [CCCoreData getSynchronizedDirectoryActiveAccount:app.activeAccount];
+    for (TableDirectory *record in synchronizedDirectory) {
+        
+        NSString *serverUrl = record.serverUrl;
+        BOOL animation = [serversUrlInDownload containsObject:serverUrl];
+        
+        if (callViewController) {
+            NSString *serverUrlSynchronized = [CCUtility deletingLastPathComponentFromServerUrl:serverUrl];
+            CCMain *viewController = [app.listMainVC objectForKey:serverUrlSynchronized];
+            if (viewController)
+                [viewController synchronizedFolderGraphicsServerUrl:serverUrl animation:animation];
+        } else
+            return animation;
+    }
     
+    return NO;
 }
 
 @end