Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sending bundleId along with ZincBundleCloneCompleteEvent notification

  • Loading branch information...
commit eb444d9b6aa03cf0a2976e33a712d35b4d32b222 1 parent c0bd78c
@NachoSoto NachoSoto authored
View
2  Zinc/ZincArchiveDownloadTask.m
@@ -85,7 +85,7 @@ - (void) main
continue;
}
- [self addEvent:[ZincAchiveExtractCompleteEvent archiveExtractCompleteEventForResource:self.resource]];
+ [self addEvent:[ZincAchiveExtractCompleteEvent archiveExtractCompleteEventForResource:self.resource context:self.bundleId]];
self.finishedSuccessfully = YES;
}
View
2  Zinc/ZincBundleCloneTask.m
@@ -192,7 +192,7 @@ - (void) main
[self.repo registerBundle:self.resource status:ZincBundleStateAvailable];
- [self addEvent:[ZincBundleCloneCompleteEvent bundleCloneCompleteEventForBundleResource:self.resource]];
+ [self addEvent:[ZincBundleCloneCompleteEvent bundleCloneCompleteEventForBundleResource:self.resource context:self.bundleId]];
self.finishedSuccessfully = YES;
}
View
7 Zinc/ZincEvent.h
@@ -111,8 +111,9 @@ extern NSString *const kZincEventArchiveExtractCompleteNotification;
@interface ZincBundleCloneCompleteEvent : ZincEvent
-+ (id) bundleCloneCompleteEventForBundleResource:(NSURL*)bundleResource;
++ (id) bundleCloneCompleteEventForBundleResource:(NSURL*)bundleResource context:(id)context;
@property (readonly) NSURL* bundleResource;
+@property (readonly) id context;
@end
@@ -127,7 +128,7 @@ extern NSString *const kZincEventArchiveExtractCompleteNotification;
@interface ZincAchiveExtractCompleteEvent : ZincEvent
-+ (id) archiveExtractCompleteEventForResource:(NSURL*)archiveResource;
++ (id) archiveExtractCompleteEventForResource:(NSURL*)archiveResource context:(id)context;
@property (readonly) NSURL* archiveResource;
-
+@property (readonly) id context;
@end
View
20 Zinc/ZincEvent.m
@@ -294,10 +294,11 @@ - (NSURL*) bundleResource
@implementation ZincBundleCloneCompleteEvent
-+ (id) bundleCloneCompleteEventForBundleResource:(NSURL*)bundleResource
++ (id) bundleCloneCompleteEventForBundleResource:(NSURL*)bundleResource context:(id)context
{
NSDictionary* attr = [NSDictionary dictionaryWithObjectsAndKeys:
- bundleResource, kZincEventAttributesBundleResourceKey, nil];
+ bundleResource, kZincEventAttributesBundleResourceKey,
+ context ?: [NSNull null], kZincEventAttributesContextKey, nil];
return [[[self alloc] initWithType:ZincEventTypeBundleCloneComplete source:nil attributes:attr] autorelease];
}
@@ -317,6 +318,11 @@ - (NSURL*) bundleResource
return [self.attributes objectForKey:kZincEventAttributesBundleResourceKey];
}
+- (id)context
+{
+ return [self.attributes objectForKey:kZincEventAttributesContextKey];
+}
+
@end
@implementation ZincAchiveExtractBeginEvent
@@ -348,10 +354,11 @@ - (NSURL*) archiveResource
@implementation ZincAchiveExtractCompleteEvent
-+ (id) archiveExtractCompleteEventForResource:(NSURL*)archiveResource
++ (id) archiveExtractCompleteEventForResource:(NSURL*)archiveResource context:(id)context
{
NSDictionary* attr = [NSDictionary dictionaryWithObjectsAndKeys:
- archiveResource, kZincEventAttributesArchiveResourceKey, nil];
+ archiveResource, kZincEventAttributesArchiveResourceKey,
+ context ?: [NSNull null], kZincEventAttributesContextKey, nil];
return [[[self alloc] initWithType:ZincEventTypeArchiveExtractComplete source:nil attributes:attr] autorelease];
}
@@ -371,4 +378,9 @@ - (NSURL*) archiveResource
return [self.attributes objectForKey:kZincEventAttributesArchiveResourceKey];
}
+- (id)context
+{
+ return [self.attributes objectForKey:kZincEventAttributesContextKey];
+}
+
@end
View
4 Zinc/ZincRepo.m
@@ -939,8 +939,8 @@ - (void) logEvent:(ZincEvent*)event
{
__block typeof(self) blockself = self;
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
- if ([blockself.delegate respondsToSelector:@selector(zincRepo:didReceiveEvent:)]) {
- [blockself.delegate zincRepo:blockself didReceiveEvent:event]; }
+ if ([blockself.delegate respondsToSelector:@selector(zincRepo:didReceiveEvent:)])
+ [blockself.delegate zincRepo:blockself didReceiveEvent:event];
[[NSNotificationCenter defaultCenter] postNotificationName:[[event class] notificationName] object:self userInfo:event.attributes];
}];
View
38 ZincDemo/BundleListViewController.m
@@ -35,14 +35,17 @@ - (id) initWithRepo:(ZincRepo *)repo
name:ZincRepoBundleDidBeginTrackingNotification
object:_repo];
[[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(bundleStatusChangeNotification:)
- name:ZincRepoBundleStatusChangeNotification
- object:_repo];
- [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(bundleWillDeleteNotification:)
name:ZincRepoBundleWillDeleteNotification
object:_repo];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(bundleDownloadProgressNotification:) name:kZincEventDownloadProgressNotification object:_repo];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(bundleDownloadProgressNotification:)
+ name:kZincEventDownloadProgressNotification
+ object:_repo];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(bundleCloneCompleteNotification:)
+ name:kZincEventBundleCloneCompleteNotification
+ object:_repo];
}
return self;
}
@@ -61,12 +64,18 @@ - (void)bundleDownloadProgressNotification:(NSNotification *)note
[self.bundleProgress setValue:[NSNumber numberWithFloat:progress] forKey:bundleId];
- [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:[self.bundleIds indexOfObject:bundleId] inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
+ [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:[self.bundleIds indexOfObject:bundleId]
+ inSection:0]]
+ withRowAnimation:UITableViewRowAnimationNone];
}
-- (void) bundleStatusChangeNotification:(NSNotification *)note
+- (void)bundleCloneCompleteNotification:(NSNotification *)note
{
- [self.tableView reloadData];
+ NSString *bundleId = [note.userInfo valueForKey:kZincEventAttributesContextKey];
+
+ [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:[self.bundleIds indexOfObject:bundleId]
+ inSection:0]]
+ withRowAnimation:UITableViewRowAnimationNone];
}
- (void) bundleWillDeleteNotification:(NSNotification *)note
@@ -121,7 +130,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
- //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
NSString* bundleId = [self.bundleIds objectAtIndex:[indexPath row]];
@@ -133,14 +141,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
if (state == ZincBundleStateCloning)
{
- NSNumber *downloadProgress = [self.bundleProgress valueForKey:bundleId];
- if (downloadProgress)
+ double downloadProgress = [[self.bundleProgress valueForKey:bundleId] doubleValue];
+
+ if (downloadProgress == 1)
+ {
+ cellDetailText = @"Unpacking";
+ }
+ else
{
- cellDetailText = [cellDetailText stringByAppendingFormat:@" (%d%%)", (int)([downloadProgress floatValue] * 100)];
+ cellDetailText = [cellDetailText stringByAppendingFormat:@" (%d%%)", (int)(downloadProgress * 100)];
}
}
-// cell.textLabel.text = [NSString stringWithFormat:@"%@ - %@", bundleName, ZincBundleStateName[state]];
cell.textLabel.text = bundleName;
cell.detailTextLabel.text = cellDetailText;

0 comments on commit eb444d9

Please sign in to comment.
Something went wrong with that request. Please try again.