Browse Source

change image loading

Marino Faggiana 6 years ago
parent
commit
e8d0adde84
4 changed files with 22 additions and 14 deletions
  1. 4 4
      Nextcloud.xcodeproj/project.pbxproj
  2. 18 10
      iOSClient/Main/CCDetail.m
  3. BIN
      iOSClient/loading.gif
  4. BIN
      iOSClient/loading@2x.gif

+ 4 - 4
Nextcloud.xcodeproj/project.pbxproj

@@ -369,7 +369,7 @@
 		F77B0F7D1D118A16002130FE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7F67BB81A24D27800EE80DA /* Images.xcassets */; };
 		F77B0F8A1D118A16002130FE /* CCCellMain.xib in Resources */ = {isa = PBXBuildFile; fileRef = F70211F61BAC56E9003FC03E /* CCCellMain.xib */; };
 		F77B0F8C1D118A16002130FE /* CCCellMainTransfer.xib in Resources */ = {isa = PBXBuildFile; fileRef = F70211F91BAC56E9003FC03E /* CCCellMainTransfer.xib */; };
-		F77D49A91DC238E500CDC568 /* loading@2x.gif in Resources */ = {isa = PBXBuildFile; fileRef = F77D49A71DC238E500CDC568 /* loading@2x.gif */; };
+		F77D49A91DC238E500CDC568 /* loading.gif in Resources */ = {isa = PBXBuildFile; fileRef = F77D49A71DC238E500CDC568 /* loading.gif */; };
 		F77EB6281EC08036003F814F /* CCExifGeo.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A54C351C6267B500E2C8BF /* CCExifGeo.m */; };
 		F77EB62A1EC0B50A003F814F /* CCCertificate.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F801011D98205A007537BC /* CCCertificate.m */; };
 		F78071091EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m in Sources */ = {isa = PBXBuildFile; fileRef = F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */; };
@@ -1249,7 +1249,7 @@
 		F774DF0E1FCC26BE002AF9FC /* iTunesArtwork@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "iTunesArtwork@3x.png"; sourceTree = "<group>"; };
 		F777F0301C29717F00CE81CB /* PHAsset+Utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PHAsset+Utility.h"; sourceTree = "<group>"; };
 		F777F0311C29717F00CE81CB /* PHAsset+Utility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PHAsset+Utility.m"; sourceTree = "<group>"; };
-		F77D49A71DC238E500CDC568 /* loading@2x.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = "loading@2x.gif"; sourceTree = "<group>"; };
+		F77D49A71DC238E500CDC568 /* loading.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = loading.gif; sourceTree = "<group>"; };
 		F78071071EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNotificationCenter+MainThread.h"; sourceTree = "<group>"; };
 		F78071081EDAB65800EAFFF6 /* NSNotificationCenter+MainThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNotificationCenter+MainThread.m"; sourceTree = "<group>"; };
 		F780711F1EDB135100EAFFF6 /* CCPhotos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhotos.h; sourceTree = "<group>"; };
@@ -3173,7 +3173,7 @@
 				F774DF0E1FCC26BE002AF9FC /* iTunesArtwork@3x.png */,
 				F7229B491DF71BB300E8C4E7 /* AUTHORS */,
 				F7F0617A1BAACDD300846525 /* CryptoCloud.pch */,
-				F77D49A71DC238E500CDC568 /* loading@2x.gif */,
+				F77D49A71DC238E500CDC568 /* loading.gif */,
 				F7F67BAD1A24D27800EE80DA /* main.m */,
 				F7D154271E2392A300202FD9 /* Nextcloud-Bridging-Header.h */,
 				F76344751BF259A800188725 /* synchronized.gif */,
@@ -3473,7 +3473,7 @@
 				F7F54CF41E5B14C700E19C62 /* PlayButtonOverlayLarge.png in Resources */,
 				F7F54D041E5B14C800E19C62 /* VideoOverlay@2x.png in Resources */,
 				F7F54CF51E5B14C700E19C62 /* PlayButtonOverlayLarge@2x.png in Resources */,
-				F77D49A91DC238E500CDC568 /* loading@2x.gif in Resources */,
+				F77D49A91DC238E500CDC568 /* loading.gif in Resources */,
 				F7F54CF91E5B14C700E19C62 /* PlayButtonOverlayLargeTap@3x.png in Resources */,
 				F7D4233D1F0596AC009C9782 /* Reader-Button-N@3x.png in Resources */,
 				F73B4EF21F470D9100BBEE4B /* EUCTWFreq.tab in Resources */,

+ 18 - 10
iOSClient/Main/CCDetail.m

@@ -47,8 +47,6 @@
     
     NSMutableOrderedSet *_dataSourceDirectoryID;
     NSString *_fileNameExtension;
-    
-    CCHud *_hud;
 }
 @end
 
@@ -72,7 +70,6 @@
         self.photos = [[NSMutableArray alloc] init];
         self.dataSourceImagesVideos = [[NSMutableArray alloc] init];
         _dataSourceDirectoryID = [[NSMutableOrderedSet alloc] init];
-        _hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
         _indexNowVisible = -1;
         _fileIDNowVisible = nil;
 
@@ -452,13 +449,16 @@
 - (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index
 {
     UIImage *image;
-    
+//    UIImage *loadingGIF = [UIImage animatedImageWithAnimatedGIFURL:[[NSBundle mainBundle] URLForResource:@"loading" withExtension:@"gif"]];
+
     tableMetadata *metadata = [self.dataSourceImagesVideos objectAtIndex:index];
     
     if (index < self.photos.count) {
         
         if (metadata.fileID) {
             
+            UIImage *imagePreview = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconFileID:metadata.fileID fileNameView:metadata.fileNameView]];
+            
             if ([metadata.typeFile isEqualToString: k_metadataTypeFile_image]) {
                 
                 NSString *fileImage = [CCUtility getDirectoryProviderStorageFileID:metadata.fileID fileName:metadata.fileNameView];
@@ -481,6 +481,10 @@
                     if (metadata.status == k_metadataStatusDownloadError) {
                         
                         [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
+                        
+                    } else {
+                        
+                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
                     }
                 }
             }
@@ -501,6 +505,10 @@
                     if (metadata.status == k_metadataStatusDownloadError) {
                         
                         [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
+                        
+                    } else {
+                        
+                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
                     }
                 }
             }
@@ -529,6 +537,10 @@
                     if (metadata.status == k_metadataStatusDownloadError) {
                         
                         [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"filePreviewError"]]];
+                        
+                    } else {
+                        
+                        [self.photos replaceObjectAtIndex:index withObject:[MWPhoto photoWithImage:imagePreview]];
                     }
                 }
             }
@@ -625,8 +637,8 @@
     //long long totalBytes = [[dict valueForKey:@"totalBytes"] longLongValue];
     //long long totalBytesExpected = [[dict valueForKey:@"totalBytesExpected"] longLongValue];
     
-    if ([fileID isEqualToString:_fileIDNowVisible])
-        [_hud progress:progress];
+//    if ([fileID isEqualToString:_fileIDNowVisible])
+//        [_hud progress:progress];
 }
 
 - (void)downloadPhotoBrowserSuccessFailure:(tableMetadata *)metadata selector:(NSString *)selector errorCode:(NSInteger)errorCode
@@ -634,8 +646,6 @@
     // if a message for a directory of these
     if (![metadata.fileID isEqualToString:_fileIDNowVisible])
         return;
- 
-    [_hud hideHud];
     
     if (errorCode == 0) {
         // verifico se esiste l'icona e se la posso creare
@@ -657,8 +667,6 @@
     
     if (serverUrl) {
         
-        [_hud visibleHudTitle:@"" mode:MBProgressHUDModeDeterminate color:[NCBrandColor sharedInstance].brandElement];
-        
         metadata.session = k_download_session;
         metadata.sessionError = @"";
         metadata.sessionSelector = selectorLoadViewImage;

BIN
iOSClient/loading.gif


BIN
iOSClient/loading@2x.gif