|
@@ -777,27 +777,33 @@
|
|
|
if (self.maintenanceMode)
|
|
|
return;
|
|
|
|
|
|
- NSInteger counterDownload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (status = %d OR status == %d OR status == %d)", self.activeAccount, k_metadataStatusWaitDownload, k_metadataStatusInDownload, k_metadataStatusDownloading] sorted:@"fileName" ascending:true] count];
|
|
|
- NSInteger counterUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (status == %d OR status == %d OR status == %d)", self.activeAccount, k_metadataStatusWaitUpload, k_metadataStatusInUpload, k_metadataStatusUploading] sorted:@"fileName" ascending:true] count];
|
|
|
-
|
|
|
- NSInteger total = counterDownload + counterUpload;
|
|
|
-
|
|
|
- [UIApplication sharedApplication].applicationIconBadgeNumber = total;
|
|
|
-
|
|
|
- UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
|
|
|
-
|
|
|
- if ([[splitViewController.viewControllers firstObject] isKindOfClass:[UITabBarController class]]) {
|
|
|
-
|
|
|
- UITabBarController *tbc = [splitViewController.viewControllers firstObject];
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
|
- UITabBarItem *tbItem = [tbc.tabBar.items objectAtIndex:0];
|
|
|
+ NSInteger counterDownload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (status = %d OR status == %d OR status == %d)", self.activeAccount, k_metadataStatusWaitDownload, k_metadataStatusInDownload, k_metadataStatusDownloading] sorted:@"fileName" ascending:true] count];
|
|
|
+ NSInteger counterUpload = [[[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND (status == %d OR status == %d OR status == %d)", self.activeAccount, k_metadataStatusWaitUpload, k_metadataStatusInUpload, k_metadataStatusUploading] sorted:@"fileName" ascending:true] count];
|
|
|
+
|
|
|
+ NSInteger total = counterDownload + counterUpload;
|
|
|
|
|
|
- if (total > 0) {
|
|
|
- [tbItem setBadgeValue:[NSString stringWithFormat:@"%li", (unsigned long)total]];
|
|
|
- } else {
|
|
|
- [tbItem setBadgeValue:nil];
|
|
|
- }
|
|
|
- }
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+
|
|
|
+ [UIApplication sharedApplication].applicationIconBadgeNumber = total;
|
|
|
+
|
|
|
+ UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
|
|
|
+
|
|
|
+ if ([[splitViewController.viewControllers firstObject] isKindOfClass:[UITabBarController class]]) {
|
|
|
+
|
|
|
+ UITabBarController *tbc = [splitViewController.viewControllers firstObject];
|
|
|
+
|
|
|
+ UITabBarItem *tbItem = [tbc.tabBar.items objectAtIndex:0];
|
|
|
+
|
|
|
+ if (total > 0) {
|
|
|
+ [tbItem setBadgeValue:[NSString stringWithFormat:@"%li", (unsigned long)total]];
|
|
|
+ } else {
|
|
|
+ [tbItem setBadgeValue:nil];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
#pragma --------------------------------------------------------------------------------------------
|