浏览代码

improvements loadThumbnails in Main

Marino Faggiana 6 年之前
父节点
当前提交
738a9b1939
共有 2 个文件被更改,包括 18 次插入27 次删除
  1. 10 19
      iOSClient/Main/CCMain.m
  2. 8 8
      iOSClient/Photos/CCPhotos.m

+ 10 - 19
iOSClient/Main/CCMain.m

@@ -37,7 +37,7 @@
 #import "NCNetworkingEndToEnd.h"
 #import "PKDownloadButton.h"
 
-@interface CCMain () <CCActionsDeleteDelegate, CCActionsRenameDelegate, CCActionsSearchDelegate, CCActionsDownloadThumbnailDelegate, CCActionsSettingFavoriteDelegate, UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, CCLoginDelegate, CCLoginDelegateWeb>
+@interface CCMain () <CCActionsDeleteDelegate, CCActionsRenameDelegate, CCActionsSearchDelegate, CCActionsSettingFavoriteDelegate, UITextViewDelegate, createFormUploadAssetsDelegate, MGSwipeTableCellDelegate, CCLoginDelegate, CCLoginDelegateWeb>
 {
     AppDelegate *appDelegate;
     
@@ -1070,26 +1070,17 @@
 #pragma mark ==== Download Thumbnail Delegate ====
 #pragma --------------------------------------------------------------------------------------------
 
-- (void)downloadThumbnailSuccessFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
+- (void)downloadThumbnail:(tableMetadata *)metadata serverUrl:(NSString *)serverUrl indexPath:(NSIndexPath *)indexPath
 {
-    // Check Active Account
-    if (![metadataNet.account isEqualToString:appDelegate.activeAccount])
-        return;
+    OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:appDelegate.activeUser withUserID:appDelegate.activeUserID withPassword:appDelegate.activePassword withUrl:appDelegate.activeUrl];
     
-    if (errorCode == 0) {
-        
-        NSIndexPath *indexPath = [_sectionDataSource.fileIDIndexPath objectForKey:metadataNet.fileID];
+    [ocNetworking downloadThumbnailWithDimOfThumbnail:@"m" fileID:metadata.fileID fileNamePath:[CCUtility returnFileNamePathFromFileName:metadata.fileName serverUrl:serverUrl activeUrl:appDelegate.activeUrl] fileNameView:metadata.fileNameView success:^{
         
-        if ([self indexPathIsValid:indexPath]) {
-        
-            if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadataNet.fileID fileNameView:metadataNet.fileNameView]])
-                [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
-        }
-        
-    } else {
-        
-        NSLog(@"[LOG] Download Thumbnail Failure error %d, %@", (int)errorCode, message);
-    }
+        if ([[NSFileManager defaultManager] fileExistsAtPath:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]])
+            [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
+
+    } failure:^(NSString *message, NSInteger errorCode) {
+    }];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -4524,7 +4515,7 @@
             
             // Download thumbnail
             if (metadata.thumbnailExists && !iconFileExists && !_metadataFolder.e2eEncrypted) {
-                [[CCActions sharedInstance] downloadTumbnail:metadata delegate:self];
+                [self downloadThumbnail:metadata serverUrl:serverUrl indexPath:indexPath];
             }
             
             // Status Image

+ 8 - 8
iOSClient/Photos/CCPhotos.m

@@ -27,7 +27,7 @@
 #import "TOScrollBar.h"
 #import "NCBridgeSwift.h"
 
-@interface CCPhotos () <CCActionsDownloadThumbnailDelegate>
+@interface CCPhotos ()
 {
     AppDelegate *appDelegate;
 
@@ -352,6 +352,12 @@
 #pragma mark ===== Download =====
 #pragma--------------------------------------------------------------------------------------------
 
+- (void)triggerProgressTask:(NSNotification *)notification
+{
+    //NSDictionary *dict = notification.userInfo;
+    //float progress = [[dict valueForKey:@"progress"] floatValue];
+}
+
 - (void)downloadFileSuccessFailure:(NSString *)fileName fileID:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector errorMessage:(NSString *)errorMessage errorCode:(NSInteger)errorCode
 {
     if (errorCode == 0) {
@@ -453,7 +459,7 @@
 }
 
 #pragma --------------------------------------------------------------------------------------------
-#pragma mark ==== Download Thumbnail Delegate ====
+#pragma mark ==== Download Thumbnail ====
 #pragma --------------------------------------------------------------------------------------------
 
 - (void)downloadThumbnail:(tableMetadata *)metadata serverUrl:(NSString *)serverUrl indexPath:(NSIndexPath *)indexPath
@@ -469,12 +475,6 @@
     }];
 }
 
-- (void)triggerProgressTask:(NSNotification *)notification
-{
-    //NSDictionary *dict = notification.userInfo;
-    //float progress = [[dict valueForKey:@"progress"] floatValue];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ==== Change Start directory ====
 #pragma --------------------------------------------------------------------------------------------