Skip to content
This repository was archived by the owner on Dec 30, 2021. It is now read-only.

Commit 82ad820

Browse files
author
chixm
committed
Notifications throttle
1 parent b9aae09 commit 82ad820

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CARExtractor/CARExtractor/main.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@
1212
#import "CarUtilities.h"
1313

1414
static NSString *kProccessingNotificationName = nil;
15+
static CFTimeInterval s_lastPostNotificationTime = 0;
1516

1617
void postProccessingNotification(NSDictionary *userInfo) {
18+
CFTimeInterval currentMediaTime = CACurrentMediaTime();
19+
if (currentMediaTime - s_lastPostNotificationTime < 0.05f) {
20+
return;
21+
}
22+
s_lastPostNotificationTime = currentMediaTime;
1723
if (kProccessingNotificationName && userInfo.count > 0) {
1824
CFNotificationCenterRef distributedCenter =
1925
CFNotificationCenterGetDistributedCenter();

iOSImagesExtractor/iOSImagesExtractor/Classes/Main/Controllers/MainViewController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static void distributedNotificationCallback(CFNotificationCenterRef center,
102102
{
103103
NSDictionary *userInfoObject = (__bridge NSDictionary *)(userInfo);
104104
NSString *pname = [userInfoObject objectForKey:@"name"];
105-
[(__bridge MainViewController *)observer setStatusString:[NSString stringWithFormat:@"Extracting %@", pname]];
105+
[(__bridge MainViewController *)observer setStatusString:[NSString stringWithFormat:@"Extracting Assets.car %@", pname]];
106106
}
107107

108108
- (void)setupNotification {
@@ -270,7 +270,7 @@ - (IBAction)clickButton:(NSButton*)sender {
270270
XMFileItem *fileItem = carArray[i];
271271

272272
NSString *outputPath = [existCarPath stringByAppendingPathComponent:[NSString stringWithFormat:@"car_images_%@", [MainViewController getRandomStringWithCount:5]]];
273-
[self setStatusString:[NSString stringWithFormat:@"Processing %@ ...", fileItem.fileName]];
273+
// [self setStatusString:[NSString stringWithFormat:@"Processing %@ ...", fileItem.fileName]];
274274
[self exportCarFileAtPath:fileItem.filePath outputPath:outputPath tag:nil];
275275
}
276276
}
@@ -564,7 +564,7 @@ - (void)doZipFilesWithPath:(NSString*)path outputPath:(NSString*)outputPath
564564

565565
for (int i = 0; i < carArrayM.count; ++i) {// 处理car文件
566566
XMFileItem *fileItem = carArrayM[i];
567-
[self setStatusString:[NSString stringWithFormat:@"Processing %@ ...", fileItem.fileName]];
567+
// [self setStatusString:[NSString stringWithFormat:@"Processing %@ ...", fileItem.fileName]];
568568
NSString *tag = nil;
569569
// ipa安装包不只1个car文件时,放在不同的文件夹
570570
if (carArrayM.count > 1) {

0 commit comments

Comments
 (0)