Эх сурвалжийг харах

Improveds view image

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 жил өмнө
parent
commit
b0c1404067

+ 10 - 4
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.swift

@@ -115,8 +115,6 @@ class NCViewerMedia: UIViewController {
         
         detailViewTopConstraint.constant = 0
         detailView.hide()
-        
-        downloadPreview()
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -150,7 +148,7 @@ class NCViewerMedia: UIViewController {
             viewerMediaPage?.progressView.isHidden = false
         }
         
-        downloadFile()
+        downloadPreview()
     }
     
     override func viewDidAppear(_ animated: Bool) {
@@ -359,7 +357,10 @@ extension NCViewerMedia {
     
     func downloadPreview() {
         
-        if metadata.hasPreview == false || CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) { return }
+        if metadata.hasPreview == false || CCUtility.fileProviderStoragePreviewIconExists(metadata.ocId, etag: metadata.etag) {
+            downloadFile()
+            return
+        }
         
         var etagResource: String?
         let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, account: metadata.account)!
@@ -368,6 +369,8 @@ extension NCViewerMedia {
         if FileManager.default.fileExists(atPath: fileNameIconLocalPath) && FileManager.default.fileExists(atPath: fileNamePreviewLocalPath) {
             etagResource = metadata.etagResource
         }
+        
+        NCUtility.shared.startActivityIndicator(backgroundView: nil, blurEffect: true)
             
         NCCommunication.shared.downloadPreview(fileNamePathOrFileId: fileNamePath, fileNamePreviewLocalPath: fileNamePreviewLocalPath , widthPreview: NCGlobal.shared.sizePreview, heightPreview: NCGlobal.shared.sizePreview, fileNameIconLocalPath: fileNameIconLocalPath, sizeIcon: NCGlobal.shared.sizeIcon, etag: etagResource, queue: NCCommunicationCommon.shared.backgroundQueue) { (account, imagePreview, imageIcon, imageOriginal, etag, errorCode, errorDescription) in
             
@@ -375,6 +378,9 @@ extension NCViewerMedia {
                 DispatchQueue.main.async {
                     self.image = image
                     self.imageVideoContainer.image = image
+                    
+                    NCUtility.shared.stopActivityIndicator()
+                    self.downloadFile()
                 }
             }
         }

+ 0 - 29
iOSClient/Viewer/NCViewerMedia/NCViewerMediaPage.swift

@@ -100,9 +100,6 @@ class NCViewerMediaPage: UIViewController {
         NotificationCenter.default.addObserver(self, selector: #selector(renameFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterRenameFile), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(moveFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMoveFile), object: nil)
 
-        NotificationCenter.default.addObserver(self, selector: #selector(downloadedFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDownloadedFile), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(triggerProgressTask(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterProgressTask), object:nil)
-        
         NotificationCenter.default.addObserver(self, selector: #selector(hidePlayerToolBar(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterHidePlayerToolBar), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(showPlayerToolBar(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterShowPlayerToolBar), object: nil)
         
@@ -128,9 +125,6 @@ class NCViewerMediaPage: UIViewController {
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterRenameFile), object: nil)
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterMoveFile), object: nil)
 
-        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterDownloadedFile), object: nil)
-        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterProgressTask), object: nil)
-        
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterHidePlayerToolBar), object: nil)
         NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterShowPlayerToolBar), object: nil)
         
@@ -177,7 +171,6 @@ class NCViewerMediaPage: UIViewController {
         if mode == .normal {
             
             navigationController?.setNavigationBarHidden(false, animated: true)
-            progressView.isHidden = false
 
             if !currentViewController.detailView.isShow() {
                 currentViewController.playerToolBar.show(enableTimerAutoHide: enableTimerAutoHide)
@@ -190,7 +183,6 @@ class NCViewerMediaPage: UIViewController {
         } else {
             
             navigationController?.setNavigationBarHidden(true, animated: true)
-            progressView.isHidden = true
             
             currentViewController.playerToolBar.hide()
 
@@ -210,27 +202,6 @@ class NCViewerMediaPage: UIViewController {
     
     //MARK: - NotificationCenter
 
-    @objc func downloadedFile(_ notification: NSNotification) {
-        
-        progressView.progress = 0
-    }
-    
-    @objc func triggerProgressTask(_ notification: NSNotification) {
-        
-        if let userInfo = notification.userInfo as NSDictionary? {
-            if let serverUrl = userInfo["serverUrl"] as? String, let fileName = userInfo["fileName"] as? String, let progressNumber = userInfo["progress"] as? NSNumber {
-                if self.metadatas.first(where: { $0.serverUrl == serverUrl && $0.fileName == fileName}) != nil {
-                    let progress = progressNumber.floatValue
-                    if progress == 1 {
-                        self.progressView.progress = 0
-                    } else {
-                        self.progressView.progress = progress
-                    }
-                }
-            }
-        }
-    }
-    
     @objc func deleteFile(_ notification: NSNotification) {
         
         if let userInfo = notification.userInfo as NSDictionary? {