Browse Source

improvements & fix

marinofaggiana 3 years ago
parent
commit
3cf45776dc

+ 1 - 1
Share/ShareViewController.m

@@ -256,7 +256,7 @@
 {
     if ([self.filesName count] > 0) {
     
-        [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0];
+        [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0 style: UIActivityIndicatorViewStyleWhiteLarge];
         
         NSString *fileName = [self.filesName objectAtIndex:0];
         NSString *fileNameLocal = [NSTemporaryDirectory() stringByAppendingString:fileName];

+ 15 - 14
iOSClient/Media/NCMedia.swift

@@ -550,7 +550,7 @@ extension NCMedia {
         }
         
         let height = self.tabBarController?.tabBar.frame.size.height ?? 0
-        NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: height + 50)
+        NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: height + 50, style: .gray)
 
         NCCommunication.shared.searchMedia(path: mediaPath, lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/", limit: limit, showHiddenFiles: CCUtility.getShowHiddenFiles(), timeout: 120) { (account, files, errorCode, errorDescription) in
             
@@ -617,23 +617,24 @@ extension NCMedia {
         var limit: Int = 1000
         guard var lessDate = Calendar.current.date(byAdding: .second, value: 1, to: Date()) else { return }
         guard var greaterDate = Calendar.current.date(byAdding: .day, value: -30, to: Date()) else { return }
-        
-        reloadDataThenPerform {
-            if let visibleCells = self.collectionView?.indexPathsForVisibleItems.sorted(by: { $0.row < $1.row }).compactMap({ self.collectionView?.cellForItem(at: $0) }) {
-                if let cell = visibleCells.first as? NCGridMediaCell {
-                    if cell.date != nil {
-                        if cell.date != self.metadatas.first?.date as Date? {
-                            lessDate = Calendar.current.date(byAdding: .second, value: 1, to: cell.date!)!
-                            limit = 0
-                        }
+
+        if let visibleCells = self.collectionView?.indexPathsForVisibleItems.sorted(by: { $0.row < $1.row }).compactMap({ self.collectionView?.cellForItem(at: $0) }) {
+            if let cell = visibleCells.first as? NCGridMediaCell {
+                if cell.date != nil {
+                    if cell.date != self.metadatas.first?.date as Date? {
+                        lessDate = Calendar.current.date(byAdding: .second, value: 1, to: cell.date!)!
+                        limit = 0
                     }
                 }
-                if let cell = visibleCells.last as? NCGridMediaCell {
-                    if cell.date != nil {
-                        greaterDate = Calendar.current.date(byAdding: .second, value: -1, to: cell.date!)!
-                    }
+            }
+            if let cell = visibleCells.last as? NCGridMediaCell {
+                if cell.date != nil {
+                    greaterDate = Calendar.current.date(byAdding: .second, value: -1, to: cell.date!)!
                 }
             }
+        }
+        
+        reloadDataThenPerform {
 
             NCCommunication.shared.searchMedia(path: self.mediaPath, lessDate: lessDate, greaterDate: greaterDate, elementDate: "d:getlastmodified/", limit: limit, showHiddenFiles: CCUtility.getShowHiddenFiles(), timeout: 120) { (account, files, errorCode, errorDescription) in
                 

+ 1 - 1
iOSClient/Media/NCMediaCommandView.xib

@@ -134,7 +134,7 @@
                     </constraints>
                     <blurEffect style="regular"/>
                 </visualEffectView>
-                <activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="medium" translatesAutoresizingMaskIntoConstraints="NO" id="XVj-jD-9KA">
+                <activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="white" translatesAutoresizingMaskIntoConstraints="NO" id="XVj-jD-9KA">
                     <rect key="frame" x="150" y="-9" width="20" height="20"/>
                     <color key="color" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                 </activityIndicatorView>

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -412,7 +412,7 @@
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"_want_delete_cache_", nil) preferredStyle:UIAlertControllerStyleActionSheet];
     
     [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_yes_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-        [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0];
+        [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0 style: UIActivityIndicatorViewStyleWhiteLarge];
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
             [self clearCache];
         });

+ 20 - 12
iOSClient/Utility/NCUtility.swift

@@ -34,7 +34,7 @@ class NCUtility: NSObject {
         return instance
     }()
     
-    private let activityIndicator = UIActivityIndicatorView(style: .whiteLarge)
+    private var activityIndicator: UIActivityIndicatorView? // = UIActivityIndicatorView(style: .whiteLarge)
     private var viewActivityIndicator: UIView?
     private var viewBackgroundActivityIndicator: UIView?
 
@@ -470,17 +470,24 @@ class NCUtility: NSObject {
     
     // MARK: -
 
-    @objc func startActivityIndicator(backgroundView: UIView?, blurEffect: Bool, bottom: CGFloat = 0) {
+    @objc func startActivityIndicator(backgroundView: UIView?, blurEffect: Bool, bottom: CGFloat = 0, style: UIActivityIndicatorView.Style = .whiteLarge) {
+        
+        if self.activityIndicator != nil {
+            stopActivityIndicator()
+        }
+        
+        self.activityIndicator = UIActivityIndicatorView(style: style)
+        guard let activityIndicator = self.activityIndicator else { return }
         
         DispatchQueue.main.async {
             
             if self.viewBackgroundActivityIndicator != nil { return }
             
-            self.activityIndicator.color = NCBrandColor.shared.textView
-            self.activityIndicator.hidesWhenStopped = true
-            self.activityIndicator.translatesAutoresizingMaskIntoConstraints = false
+            activityIndicator.color = NCBrandColor.shared.textView
+            activityIndicator.hidesWhenStopped = true
+            activityIndicator.translatesAutoresizingMaskIntoConstraints = false
 
-            let sizeActivityIndicator = self.activityIndicator.frame.height + 50
+            let sizeActivityIndicator = activityIndicator.frame.height + 50
             
             self.viewActivityIndicator = UIView.init(frame: CGRect(x: 0, y: 0, width: sizeActivityIndicator, height: sizeActivityIndicator))
             self.viewActivityIndicator?.translatesAutoresizingMaskIntoConstraints = false
@@ -503,7 +510,7 @@ class NCUtility: NSObject {
             // VIEW ACTIVITY INDICATOR
             
             guard let viewActivityIndicator = self.viewActivityIndicator else { return }
-            viewActivityIndicator.addSubview(self.activityIndicator)
+            viewActivityIndicator.addSubview(activityIndicator)
             
             if blurEffect {
                 let blurEffect = UIBlurEffect(style: .regular)
@@ -515,8 +522,8 @@ class NCUtility: NSObject {
             NSLayoutConstraint.activate([
                 viewActivityIndicator.widthAnchor.constraint(equalToConstant: sizeActivityIndicator),
                 viewActivityIndicator.heightAnchor.constraint(equalToConstant: sizeActivityIndicator),
-                self.activityIndicator.centerXAnchor.constraint(equalTo: viewActivityIndicator.centerXAnchor),
-                self.activityIndicator.centerYAnchor.constraint(equalTo: viewActivityIndicator.centerYAnchor)
+                activityIndicator.centerXAnchor.constraint(equalTo: viewActivityIndicator.centerXAnchor),
+                activityIndicator.centerYAnchor.constraint(equalTo: viewActivityIndicator.centerYAnchor)
             ])
             
             // BACKGROUD VIEW ACTIVITY INDICATOR
@@ -534,7 +541,7 @@ class NCUtility: NSObject {
                 viewActivityIndicator.centerYAnchor.constraint(equalTo: viewBackgroundActivityIndicator.centerYAnchor, constant: verticalConstant)
             ])
             
-            self.activityIndicator.startAnimating()
+            activityIndicator.startAnimating()
         }
     }
     
@@ -542,8 +549,9 @@ class NCUtility: NSObject {
                     
         DispatchQueue.main.async {
             
-            self.activityIndicator.stopAnimating()
-            self.activityIndicator.removeFromSuperview()
+            self.activityIndicator?.stopAnimating()
+            self.activityIndicator?.removeFromSuperview()
+            self.activityIndicator = nil
             
             self.viewActivityIndicator?.removeFromSuperview()
             self.viewActivityIndicator = nil