瀏覽代碼

clear code

Marino Faggiana 7 年之前
父節點
當前提交
6205357c6e

+ 0 - 1
iOSClient/Library/MWPhotoBrowser/MWPhotoBrowser.h

@@ -29,7 +29,6 @@
 
 @optional
 
-- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser thumbPhotoAtIndex:(NSUInteger)index;
 - (MWCaptionView *)photoBrowser:(MWPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index;
 - (NSString *)photoBrowser:(MWPhotoBrowser *)photoBrowser titleForPhotoAtIndex:(NSUInteger)index;
 - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index;

+ 0 - 15
iOSClient/Library/MWPhotoBrowser/MWPhotoBrowser.m

@@ -602,21 +602,6 @@ static void * MWVideoPlayerObservation = &MWVideoPlayerObservation;
     return photo;
 }
 
-- (id<MWPhoto>)thumbPhotoAtIndex:(NSUInteger)index {
-    id <MWPhoto> photo = nil;
-    if (index < _thumbPhotos.count) {
-        if ([_thumbPhotos objectAtIndex:index] == [NSNull null]) {
-            if ([_delegate respondsToSelector:@selector(photoBrowser:thumbPhotoAtIndex:)]) {
-                photo = [_delegate photoBrowser:self thumbPhotoAtIndex:index];
-            }
-            if (photo) [_thumbPhotos replaceObjectAtIndex:index withObject:photo];
-        } else {
-            photo = [_thumbPhotos objectAtIndex:index];
-        }
-    }
-    return photo;
-}
-
 - (MWCaptionView *)captionViewForPhotoAtIndex:(NSUInteger)index {
     MWCaptionView *captionView = nil;
     if ([_delegate respondsToSelector:@selector(photoBrowser:captionViewForPhotoAtIndex:)]) {

+ 0 - 1
iOSClient/Library/MWPhotoBrowser/MWPhotoBrowserPrivate.h

@@ -107,7 +107,6 @@
 // Data
 - (NSUInteger)numberOfPhotos;
 - (id<MWPhoto>)photoAtIndex:(NSUInteger)index;
-- (id<MWPhoto>)thumbPhotoAtIndex:(NSUInteger)index;
 - (UIImage *)imageForPhoto:(id<MWPhoto>)photo;
 - (BOOL)photoIsSelectedAtIndex:(NSUInteger)index;
 - (void)setPhotoSelected:(BOOL)selected atIndex:(NSUInteger)index;

+ 1 - 2
iOSClient/Main/CCDetail.h

@@ -61,8 +61,7 @@
 
 - (void)changeToDisplayMode;
 
-- (void)downloadPhotoBrowserFailure:(NSInteger)errorCode;
-- (void)downloadPhotoBrowserSuccess:(tableMetadata *)metadataVar selector:(NSString *)selector;
+- (void)downloadPhotoBrowserSuccessFailure:(tableMetadata *)metadata selector:(NSString *)selector errorCode:(NSInteger)errorCode;
 
 @end
 

+ 31 - 61
iOSClient/Main/CCDetail.m

@@ -45,7 +45,7 @@
     NSInteger _indexNowVisible;
     NSString *_fileIDNowVisible;
 
-    BOOL _reload;
+    BOOL _forceReload;
     
     NSMutableOrderedSet *_dataSourceDirectoryID;
     NSString *_fileNameExtension;
@@ -338,7 +338,7 @@
 - (void)viewImageVideoAudio
 {
     self.photoBrowser = [[MWPhotoBrowser alloc] initWithDelegate:self];
-    _reload = NO;
+    _forceReload = NO;
     _indexNowVisible = -1;
     _fileIDNowVisible = nil;
     
@@ -426,10 +426,10 @@
     if (metadata)
         self.title = metadata.fileNameView;
     
-    if (_reload) {
+    if (_forceReload) {
         
         [self.photoBrowser performSelector:@selector(reloadData) withObject:nil];
-        _reload = NO;
+        _forceReload = NO;
     }
 }
 
@@ -564,30 +564,6 @@
     return nil;
 }
 
-- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser thumbPhotoAtIndex:(NSUInteger)index
-{
-    tableMetadata *metadata = [self.dataSourceImagesVideos objectAtIndex:index];
-    
-    if (index < self.thumbs.count) {
-        
-        if (metadata.fileID) {
-            
-            NSString *fileImage = [NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID];
-            UIImage *image = [UIImage animatedImageWithAnimatedGIFURL:[NSURL fileURLWithPath:fileImage]];
-            
-            if (image) {
-                
-                MWPhoto *thumb = [MWPhoto photoWithImage:image];
-                if ([metadata.typeFile isEqualToString: k_metadataTypeFile_video]) thumb.isVideo = YES;
-                [self.thumbs replaceObjectAtIndex:index withObject:thumb];
-            }
-        }
-        return [self.thumbs objectAtIndex:index];
-    }
-    
-    return nil;
-}
-
 - (void)photoBrowser:(MWPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index
 {
     tableMetadata *metadata = [self.dataSourceImagesVideos objectAtIndex:index];
@@ -649,52 +625,46 @@
 
 - (void)triggerProgressTask:(NSNotification *)notification
 {
-    //NSDictionary *dict = notification.userInfo;
-    //float progress = [[dict valueForKey:@"progress"] floatValue];
-}
-
-- (void)downloadPhotoBrowserFailure:(NSInteger)errorCode
-{
-    [app messageNotification:@"_download_selected_files_" description:@"_error_download_photobrowser_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
-
-    [self.photoBrowser reloadData];
+    NSDictionary *dict = notification.userInfo;
+    NSString *fileID = [dict valueForKey:@"fileID"];
+    NSString *serverUrl = [dict valueForKey:@"serverUrl"];
+    float progress = [[dict valueForKey:@"progress"] floatValue];
 }
 
-- (void)downloadPhotoBrowserSuccess:(tableMetadata *)metadataVar selector:(NSString *)selector
+- (void)downloadPhotoBrowserSuccessFailure:(tableMetadata *)metadata selector:(NSString *)selector errorCode:(NSInteger)errorCode
 {
-    NSUInteger index = 0;
-    
     // if a message for a directory of these
-    if (![_dataSourceDirectoryID containsObject:metadataVar.directoryID])
+    if (![_dataSourceDirectoryID containsObject:metadata.directoryID])
         return;
     
-    for (NSUInteger i=0; i < [self.dataSourceImagesVideos count]; i++ ) {
-        
-        tableMetadata *metadata = [self.dataSourceImagesVideos objectAtIndex:i];
+    if (errorCode == 0) {
+        // verifico se esiste l'icona e se la posso creare
+        if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadata.fileID]] == NO)
+            [CCGraphics createNewImageFrom:metadata.fileID directoryUser:app.directoryUser fileNameTo:metadata.fileID extension:[metadata.fileNameView pathExtension] size:@"m" imageForUpload:NO typeFile:metadata.typeFile writePreview:YES optimizedFileName:[CCUtility getOptimizedPhoto]];
+    } else {
         
-        // search index
-        if ([metadataVar.fileID isEqualToString:metadata.fileID]) {
+        NSUInteger index = 0;
 
-            index = i;
-            break;
+        for (NSUInteger i=0; i < [self.dataSourceImagesVideos count]; i++ ) {
+            
+            tableMetadata *metadataDataSource = [self.dataSourceImagesVideos objectAtIndex:i];
+            
+            // search index
+            if ([metadataDataSource.fileID isEqualToString:metadata.fileID]) {
+                
+                index = i;
+                break;
+            }
         }
+
+        [app messageNotification:@"_download_selected_files_" description:@"_error_download_photobrowser_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
     }
     
-    if ([metadataVar.fileID isEqualToString:_fileIDNowVisible]) {
-        
+    if ([metadata.fileID isEqualToString:_fileIDNowVisible]) {
         [self.photoBrowser reloadData];
-        
-        _reload = NO;
-            
+        _forceReload = NO;
     } else {
-        
-        _reload = YES;
-    }
-    
-    // verifico se esiste l'icona e se la posso creare
-    if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, metadataVar.fileID]] == NO) {
-        
-        [CCGraphics createNewImageFrom:metadataVar.fileID directoryUser:app.directoryUser fileNameTo:metadataVar.fileID extension:[metadataVar.fileNameView pathExtension] size:@"m" imageForUpload:NO typeFile:metadataVar.typeFile writePreview:YES optimizedFileName:[CCUtility getOptimizedPhoto]];
+        _forceReload = YES;
     }
 }
 

+ 2 - 2
iOSClient/Main/CCMain.m

@@ -1368,7 +1368,7 @@
             
             // Detail
             if (app.activeDetail)
-                [app.activeDetail downloadPhotoBrowserSuccess:metadata selector:selector];
+                [app.activeDetail downloadPhotoBrowserSuccessFailure:metadata selector:selector errorCode:0];
             
             // Photos
             if (app.activePhotos)
@@ -1418,7 +1418,7 @@
                 
                 // Updating Detail
                 if (app.activeDetail)
-                    [app.activeDetail downloadPhotoBrowserFailure:errorCode];
+                    [app.activeDetail downloadPhotoBrowserSuccessFailure:metadata selector:selector errorCode:errorCode];
                 
                 // Updating Photos
                 if (app.activePhotos)