浏览代码

activity view

Marino Faggiana 6 年之前
父节点
当前提交
b384750b9f
共有 1 个文件被更改,包括 42 次插入11 次删除
  1. 42 11
      iOSClient/Activity/NCActivity.swift

+ 42 - 11
iOSClient/Activity/NCActivity.swift

@@ -306,18 +306,33 @@ class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollec
                         cell.imageView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
                         cell.imageView.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
                         
                         
                     } else {
                     } else {
+                        
                         if CCUtility.fileProviderStorageIconExists(fileID, fileNameView: activitySubjectRich.name) {
                         if CCUtility.fileProviderStorageIconExists(fileID, fileNameView: activitySubjectRich.name) {
+                            
                             if let image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(fileID, fileNameView: fileName)) {
                             if let image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(fileID, fileNameView: fileName)) {
                                 cell.imageView.image = image
                                 cell.imageView.image = image
                             }
                             }
+                            
                         } else {
                         } else {
-                            OCNetworking.sharedManager().downloadPreviewTrash(withAccount: appDelegate.activeAccount, fileID: fileID, fileName: fileName, completion: { (account, message, errorCode) in
-                                if errorCode == 0 && account == self.appDelegate.activeAccount && CCUtility.fileProviderStorageIconExists(fileID, fileNameView: fileName) {
-                                    if let image = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(fileID, fileNameView: fileName)) {
-                                        cell.imageView.image = image
-                                    }
+                            
+                            let fileNamePath = CCUtility.getDirectoryProviderStorageIconFileID(fileID, fileNameView: fileName)!
+                            
+                            if FileManager.default.fileExists(atPath: fileNamePath) {
+                                
+                                if let image = UIImage(contentsOfFile: fileNamePath) {
+                                    cell.imageView.image = image
                                 }
                                 }
-                            })
+                                
+                            } else {
+                            
+                                OCNetworking.sharedManager().downloadPreviewTrash(withAccount: appDelegate.activeAccount, fileID: fileID, fileName: fileName, completion: { (account, message, errorCode) in
+                                    if errorCode == 0 && account == self.appDelegate.activeAccount && CCUtility.fileProviderStorageIconExists(fileID, fileNameView: fileName) {
+                                        if let image = UIImage(contentsOfFile: fileNamePath) {
+                                            cell.imageView.image = image
+                                        }
+                                    }
+                                })
+                            }
                         }
                         }
                     }
                     }
                 }
                 }
@@ -334,14 +349,30 @@ class activityTableViewCell: UITableViewCell, UICollectionViewDelegate, UICollec
                             }
                             }
                         }
                         }
                     }
                     }
+                    
                 } else {
                 } else {
-                    /*
-                    OCNetworking.sharedManager()?.downloadPreview(withAccount: appDelegate.activeAccount, metadata: nil, withWidth: 0, andHeight: 0, path: activityPreview.source, completion: { (account, message, errorCode) in
-                        if errorCode == 0 {
+                    
+                    if let activitySubjectRich = NCManageDatabase.sharedInstance.getActivitySubjectRich(account: account, idActivity: idActivity, id: fileID) {
+                    
+                        let fileNamePath = CCUtility.getDirectoryUserData() + "/" + activitySubjectRich.name
+                        
+                        if FileManager.default.fileExists(atPath: fileNamePath) {
                             
                             
+                            if let image = UIImage(contentsOfFile: fileNamePath) {
+                                cell.imageView.image = image
+                            }
+                            
+                        } else {
+                            
+                            OCNetworking.sharedManager()?.downloadPreview(withAccount: appDelegate.activeAccount, serverPath: activityPreview.source, fileNamePath: fileNamePath, completion: { (account, message, errorCode) in
+                                if errorCode == 0 {
+                                    if let image = UIImage(contentsOfFile: fileNamePath) {
+                                        cell.imageView.image = image
+                                    }
+                                }
+                            })
                         }
                         }
-                    })
-                    */
+                    }
                 }
                 }
             }
             }