marinofaggiana 6 жил өмнө
parent
commit
603d97907c

+ 1 - 1
iOSClient/Main/Cell/NCGridMediaCell.xib

@@ -19,7 +19,7 @@
                 <rect key="frame" x="0.0" y="0.0" width="220" height="220"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5Ci-V1-hf5" userLabel="imageItem">
+                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5Ci-V1-hf5" userLabel="imageItem">
                         <rect key="frame" x="0.0" y="0.0" width="220" height="220"/>
                     </imageView>
                     <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="DHy-Up-3Bh" userLabel="imageSelect">

+ 2 - 0
iOSClient/Main/NCMainCommon.swift

@@ -1295,6 +1295,8 @@ class NCNetworkingMain: NSObject, CCNetworkingDelegate {
                                     (cell as! NCListCell).imageItem.image = image
                                 } else if cell is NCGridCell {
                                     (cell as! NCGridCell).imageItem.image = image
+                                } else if cell is NCGridMediaCell {
+                                    (cell as! NCGridMediaCell).imageItem.image = image
                                 }
                             }
                         }

+ 15 - 12
iOSClient/Media/NCMedia.swift

@@ -52,7 +52,7 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     
     private var addWidth: CGFloat = 10
     
-    private var readLastdays = 30
+    private var readRetry = 0
 
     private let refreshControl = UIRefreshControl()
     
@@ -90,7 +90,7 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
         // Configure Refresh Control
         refreshControl.tintColor = NCBrandColor.sharedInstance.brandText
         refreshControl.backgroundColor = NCBrandColor.sharedInstance.brand
-        refreshControl.addTarget(self, action: #selector(loadDatasource), for: .valueChanged)
+        //refreshControl.addTarget(self, action: #selector(loadDatasource), for: .valueChanged)
         
         // empty Data Source
         self.collectionView.emptyDataSetDelegate = self;
@@ -311,7 +311,7 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
         actionSheet?.present(in: self, from: sender as! UIButton)
     }
     
-    func search(_ lteDate: Date, gteDate: Date) {
+    func search(_ lteDate: Date, gteDate: Date, reiteration: Bool) {
         
         if appDelegate.activeAccount.count == 0 {
             return
@@ -323,8 +323,14 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
             
             if errorCode == 0 && account == self.appDelegate.activeAccount {
                
-                NCManageDatabase.sharedInstance.createTablePhotos(metadatas as! [tableMetadata], lteDate: lteDate, gteDate: gteDate, account: account!)
-                self.loadDatasource()
+                if metadatas != nil && metadatas!.count > 0 {
+                    NCManageDatabase.sharedInstance.createTablePhotos(metadatas as! [tableMetadata], lteDate: lteDate, gteDate: gteDate, account: account!)
+                    self.loadDatasource()
+                } else if reiteration {
+                    let newGteDate = Calendar.current.date(byAdding: .day, value: -60, to: gteDate)!
+                    self.readRetry += 1
+                    self.search(lteDate, gteDate: newGteDate, reiteration: reiteration)
+                }
             }
             
             self.refreshControl.endRefreshing()
@@ -344,9 +350,8 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
                 self.sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: "date", filterFileID: nil, filterTypeFileImage: self.filterTypeFileImage, filterTypeFileVideo: self.filterTypeFileVideo, activeAccount: self.appDelegate.activeAccount)
             } else {
                 self.sectionDatasource = CCSectionDataSourceMetadata()
-                
-                let gteDate = Calendar.current.date(byAdding: .day, value: -self.readLastdays, to: Date())!
-                self.search(Date(), gteDate: gteDate)
+                let gteDate = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
+                self.search(Date(), gteDate: gteDate, reiteration: true)
             }
         
             DispatchQueue.main.async {
@@ -453,14 +458,12 @@ class NCMedia: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     }
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        
-        let cell: UICollectionViewCell
-        
+                
         guard let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(indexPath, sectionDataSource: sectionDatasource) else {
             return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridMediaCell
         }
         
-        cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridMediaCell
+        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridMediaCell
       
         NCMainCommon.sharedInstance.collectionViewCellForItemAt(indexPath, collectionView: collectionView, cell: cell, metadata: metadata, metadataFolder: nil, serverUrl: metadata.serverUrl, isEditMode: isEditMode, selectFileID: selectFileID, autoUploadFileName: autoUploadFileName, autoUploadDirectory: autoUploadDirectory, hideButtonMore: true, source: self)