marinofaggiana 4 年之前
父節點
當前提交
e3370b3ea7
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      iOSClient/AppDelegate.m

+ 6 - 3
iOSClient/AppDelegate.m

@@ -813,11 +813,14 @@
     
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
+        NSInteger counterDownload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"status = %d OR status == %d OR status == %d", k_metadataStatusWaitDownload, k_metadataStatusInDownload, k_metadataStatusDownloading] sorted:@"fileName" ascending:true] count];
         NSInteger counterUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"status == %d OR status == %d OR status == %d", k_metadataStatusWaitUpload, k_metadataStatusInUpload, k_metadataStatusUploading] sorted:@"fileName" ascending:true] count];
+
+        NSInteger total = counterDownload + counterUpload;
         
         dispatch_async(dispatch_get_main_queue(), ^{
             
-            [UIApplication sharedApplication].applicationIconBadgeNumber = counterUpload;
+            [UIApplication sharedApplication].applicationIconBadgeNumber = total;
             
             UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
             if ([splitViewController isKindOfClass:[UISplitViewController class]]) {
@@ -827,8 +830,8 @@
                     if ([tabBarController isKindOfClass:[UITabBarController class]]) {
                         UITabBarItem *tabBarItem = [tabBarController.tabBar.items objectAtIndex:0];
                             
-                        if (counterUpload > 0) {
-                            [tabBarItem setBadgeValue:[NSString stringWithFormat:@"%li", (unsigned long)counterUpload]];
+                        if (total > 0) {
+                            [tabBarItem setBadgeValue:[NSString stringWithFormat:@"%li", (unsigned long)total]];
                         } else {
                             [tabBarItem setBadgeValue:nil];
                         }