浏览代码

Improved download preview image

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 年之前
父节点
当前提交
01698b6855
共有 1 个文件被更改,包括 28 次插入11 次删除
  1. 28 11
      iOSClient/Viewer/NCViewerMedia/NCViewerMediaZoom.swift

+ 28 - 11
iOSClient/Viewer/NCViewerMedia/NCViewerMediaZoom.swift

@@ -118,6 +118,9 @@ class NCViewerMediaZoom: UIViewController {
         
         detailViewTopConstraint.constant = 0
         detailView.hide()
+        
+        // DOWNLOAD
+        downloadFile()
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -170,14 +173,18 @@ class NCViewerMediaZoom: UIViewController {
                 self.viewerMedia?.updateCommandCenter(ncplayer: ncplayer, metadata: self.metadata)
             }
             
-        } else {
+        } else if metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue {
+            
+            if let image = image {
+                let imageNoPreview = UIImage.init(named: "noPreview")!.image(color: .gray, size: view.frame.width)
+                if imageNoPreview.isEqualToImage(image: image) {
+                    self.reload(image: nil, metadata: metadata)
+                }
+            }
             
             viewerMedia?.clearCommandCenter()
         }
         
-        // DOWNLOAD
-        downloadFile()
-        
         NotificationCenter.default.addObserver(self, selector: #selector(openDetail(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterOpenMediaDetail), object: nil)
     }
     
@@ -200,14 +207,25 @@ class NCViewerMediaZoom: UIViewController {
         }) { (_) in }
     }
     
-    func reload(image: UIImage, metadata: tableMetadata) {
+    func reload(image: UIImage?, metadata: tableMetadata) {
         
-        self.image = image
+        if image == nil {
+            
+            if let image = viewerMedia?.getImageMetadata(metadata) {
+                
+                self.image = image
 
-        imageVideoContainer.image = image
-        imageVideoContainer.sourceImage = image
-        
-        self.metadata = metadata
+                imageVideoContainer.image = image
+                imageVideoContainer.sourceImage = image
+            }
+            
+        } else {
+            
+            self.image = image
+
+            imageVideoContainer.image = image
+            imageVideoContainer.sourceImage = image
+        }
     }
         
     //MARK: - Gesture
@@ -388,7 +406,6 @@ extension NCViewerMediaZoom {
         
         // DOWNLOAD preview for image
         if !CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) && metadata.hasPreview && metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue {
-            
             NCOperationQueue.shared.downloadThumbnail(metadata: metadata, placeholder: false, cell: nil, view: nil)
         }
     }