فهرست منبع

improvement blink

marinofaggiana 5 سال پیش
والد
کامیت
49aea9cf99
4فایلهای تغییر یافته به همراه32 افزوده شده و 31 حذف شده
  1. 5 5
      iOSClient/AppDelegate.m
  2. 2 2
      iOSClient/Main/CCMain.h
  3. 14 15
      iOSClient/Main/CCMain.m
  4. 11 9
      iOSClient/Utility/NCUtility.swift

+ 5 - 5
iOSClient/AppDelegate.m

@@ -1605,15 +1605,15 @@ PKPushRegistry *pushRegistry;
                                 tbc = splitViewController.viewControllers.firstObject;
                             }
                             
-                            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                                 
                                 [tbc setSelectedIndex: k_tabBarApplicationIndexFile];
                                 
-                                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                                     
                                     [self.activeMain.navigationController popToRootViewControllerAnimated:NO];
                                     
-                                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                                         
                                         NSString *fileNamePath = [NSString stringWithFormat:@"%@%@/%@", matchedAccount.url, k_webDAV, path];
                                         
@@ -1624,14 +1624,14 @@ PKPushRegistry *pushRegistry;
                                             NSString *serverUrl = [CCUtility deletingLastPathComponentFromServerUrl:[NSString stringWithFormat:@"%@%@/%@", matchedAccount.url, k_webDAV, [path stringByDeletingLastPathComponent]]];
                                             tableMetadata *metadata = [CCUtility createMetadataWithAccount:matchedAccount.account date:[NSDate date] directory:NO fileID:[[NSUUID UUID] UUIDString] serverUrl:serverUrl fileName:directoryName etag:@"" size:0 status:k_metadataStatusNormal url:@""];
                                             
-                                            [self.activeMain performSegueDirectoryWithControlPasscode:true metadata:metadata scrollToFileNamePath:fileNamePath];
+                                            [self.activeMain performSegueDirectoryWithControlPasscode:true metadata:metadata blinkFileNamePath:fileNamePath];
                                             
                                         } else {
                                             
                                             // Reload folder
                                             NSString *serverUrl = [NSString stringWithFormat:@"%@%@", matchedAccount.url, k_webDAV];
                                             
-                                            self.activeMain.scrollToFileNamePath = fileNamePath;
+                                            self.activeMain.blinkFileNamePath = fileNamePath;
                                             [self.activeMain readFolder:serverUrl];
                                         }
                                     });

+ 2 - 2
iOSClient/Main/CCMain.h

@@ -59,12 +59,12 @@
 @property (nonatomic, strong) UISearchController *searchController;
 @property (nonatomic, strong) UIView *reMenuBackgroundView;
 @property (nonatomic, strong) UITapGestureRecognizer *singleFingerTap;
-@property (nonatomic, strong) NSString *scrollToFileNamePath;
+@property (nonatomic, strong) NSString *blinkFileNamePath;
 
 @property BOOL isSelectedMode;
 
 - (void)shouldPerformSegue:(tableMetadata *)metadata;
-- (void)performSegueDirectoryWithControlPasscode:(BOOL)controlPasscode metadata:(tableMetadata *)metadata scrollToFileNamePath:(NSString *)scrollToFileNamePath;
+- (void)performSegueDirectoryWithControlPasscode:(BOOL)controlPasscode metadata:(tableMetadata *)metadata blinkFileNamePath:(NSString *)blinkFileNamePath;
 
 - (void)saveToPhotoAlbum:(tableMetadata *)metadata;
 

+ 14 - 15
iOSClient/Main/CCMain.m

@@ -1129,8 +1129,8 @@
         
             tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", account, metadata.serverUrl]];
             
-            // Change etag, read folder
-            if ([metadata.etag isEqualToString:directory.etag] == NO) {
+            // Change etag, read folder or BLINK 
+            if ([metadata.etag isEqualToString:directory.etag] == NO || self.blinkFileNamePath != nil) {
                 [self readFolder:metadata.serverUrl];
             }
             
@@ -2927,7 +2927,7 @@
             if (aViewController.fromType == CCBKPasscodeFromLockDirectory) {
                 
                 // possiamo procedere alla prossima directory
-                [self performSegueDirectoryWithControlPasscode:false metadata:self.metadata scrollToFileNamePath:self.scrollToFileNamePath];
+                [self performSegueDirectoryWithControlPasscode:false metadata:self.metadata blinkFileNamePath:self.blinkFileNamePath];
                 
                 // avviamo la sessione Passcode Lock con now
                 appDelegate.sessionePasscodeLock = [NSDate date];
@@ -3715,28 +3715,27 @@
     //
     [self.tableView reloadEmptyDataSet];
     
-    // scrollToFileNamePath
-    if (self.scrollToFileNamePath != nil) {
+    // blinkFileNamePath
+    if (self.blinkFileNamePath != nil) {
         for (NSString *key in sectionDataSource.allRecordsDataSource) {
             tableMetadata *metadata = [sectionDataSource.allRecordsDataSource objectForKey:key];
             NSString *metadataFileNamePath = [NSString stringWithFormat:@"%@/%@", metadata.serverUrl, metadata.fileName];
-            if ([metadataFileNamePath isEqualToString:self.scrollToFileNamePath]) {
+            if ([metadataFileNamePath isEqualToString:self.blinkFileNamePath]) {
                 for (NSString *key in sectionDataSource.fileIDIndexPath) {
                     if ([key isEqualToString:metadata.fileID]) {
                         NSIndexPath *indexPath = [sectionDataSource.fileIDIndexPath objectForKey:key];
-                        [UIView animateWithDuration:0.5 animations:^{
+                        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                             [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
-                        } completion:^(BOOL finished) {
                             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                                 CCCellMain *cell = [self.tableView cellForRowAtIndexPath:indexPath];
-                                if (cell) {
+                                if (cell && [self.tableView.visibleCells containsObject:cell]) {
+                                    self.blinkFileNamePath = nil;
                                     [[NCUtility sharedInstance] blinkWithCell:cell];
                                 }
                             });
-                        }];
+                        });
                     }
                 }
-                self.scrollToFileNamePath = nil;
             }
         }
     }
@@ -4107,7 +4106,7 @@
     
     if (self.metadata.directory) {
         
-        [self performSegueDirectoryWithControlPasscode:true metadata:self.metadata scrollToFileNamePath:self.scrollToFileNamePath];
+        [self performSegueDirectoryWithControlPasscode:true metadata:self.metadata blinkFileNamePath:self.blinkFileNamePath];
     }
 }
 
@@ -4217,7 +4216,7 @@
 }
 
 // can i go to next viewcontroller
-- (void)performSegueDirectoryWithControlPasscode:(BOOL)controlPasscode metadata:(tableMetadata *)metadata scrollToFileNamePath:(NSString *)scrollToFileNamePath
+- (void)performSegueDirectoryWithControlPasscode:(BOOL)controlPasscode metadata:(tableMetadata *)metadata blinkFileNamePath:(NSString *)blinkFileNamePath
 {
     NSString *nomeDir;
     
@@ -4280,7 +4279,7 @@
             
             viewController.serverUrl = serverUrlPush;
             viewController.titleMain = metadata.fileName;
-            viewController.scrollToFileNamePath = scrollToFileNamePath;
+            viewController.blinkFileNamePath = blinkFileNamePath;
             
             // save self
             [appDelegate.listMainVC setObject:viewController forKey:serverUrlPush];
@@ -4292,7 +4291,7 @@
             if (viewController.isViewLoaded) {
                 
                 viewController.titleMain = metadata.fileName;
-                viewController.scrollToFileNamePath = scrollToFileNamePath;
+                viewController.blinkFileNamePath = blinkFileNamePath;
                 
                 // Fix : Application tried to present modally an active controller
                 if ([self.navigationController isBeingPresented]) {

+ 11 - 9
iOSClient/Utility/NCUtility.swift

@@ -311,15 +311,17 @@ class NCUtility: NSObject {
     }
     
     @objc func blink(cell: AnyObject?) {
-        if let cell = cell as? UITableViewCell {
-            cell.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
-            UIView.animate(withDuration: 2) {
-                cell.backgroundColor = .clear
-            }
-        } else if let cell = cell as? UICollectionViewCell {
-            cell.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
-            UIView.animate(withDuration: 2) {
-                cell.backgroundColor = .clear
+        DispatchQueue.main.async {
+            if let cell = cell as? UITableViewCell {
+                cell.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+                UIView.animate(withDuration: 2) {
+                    cell.backgroundColor = .clear
+                }
+            } else if let cell = cell as? UICollectionViewCell {
+                cell.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+                UIView.animate(withDuration: 2) {
+                    cell.backgroundColor = .clear
+                }
             }
         }
     }