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

Commit

Permalink
Notifications throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
chixm committed Jun 2, 2020
1 parent b9aae09 commit 82ad820
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CARExtractor/CARExtractor/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
#import "CarUtilities.h"

static NSString *kProccessingNotificationName = nil;
static CFTimeInterval s_lastPostNotificationTime = 0;

void postProccessingNotification(NSDictionary *userInfo) {
CFTimeInterval currentMediaTime = CACurrentMediaTime();
if (currentMediaTime - s_lastPostNotificationTime < 0.05f) {
return;
}
s_lastPostNotificationTime = currentMediaTime;
if (kProccessingNotificationName && userInfo.count > 0) {
CFNotificationCenterRef distributedCenter =
CFNotificationCenterGetDistributedCenter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static void distributedNotificationCallback(CFNotificationCenterRef center,
{
NSDictionary *userInfoObject = (__bridge NSDictionary *)(userInfo);
NSString *pname = [userInfoObject objectForKey:@"name"];
[(__bridge MainViewController *)observer setStatusString:[NSString stringWithFormat:@"Extracting %@", pname]];
[(__bridge MainViewController *)observer setStatusString:[NSString stringWithFormat:@"Extracting Assets.car %@", pname]];
}

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

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

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

0 comments on commit 82ad820

Please sign in to comment.