Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
hide camera window after scanning invalid QR code
Browse files Browse the repository at this point in the history
  • Loading branch information
mackuba committed May 21, 2014
1 parent 205732f commit e252173
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Hive/Controllers/HICameraWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ - (void)processImage:(CIImage *)image {
if (!self.scanning && [[NSDate new] timeIntervalSinceDate:self.lastScanDate] > SCAN_INTERVAL) {
self.lastScanDate = [NSDate new];
self.scanning = YES;

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *scannedQRCode = [self scanQRCodeInImage:image];

dispatch_async(dispatch_get_main_queue(), ^{
if (scannedQRCode) {
[self finishScanningWithCode:scannedQRCode];
}

self.scanning = NO;
});
});
Expand All @@ -141,16 +144,15 @@ - (NSString *)scanQRCodeInImage:(CIImage *)image {
}

- (void)finishScanningWithCode:(NSString *)scannedQRCode {
BOOL success;
id<HICameraWindowControllerDelegate> delegate = self.delegate;

[self.captureSession stopRunning];
[self.window performClose:nil];

if (delegate) {
success = [delegate cameraWindowController:self didScanQRCodeURI:scannedQRCode];
[delegate cameraWindowController:self didScanQRCodeURI:scannedQRCode];
} else {
success = [[HIBitcoinURIService sharedService] handleBitcoinURIString:scannedQRCode];
}
if (success) {
[self.captureSession stopRunning];
[self.window performClose:nil];
[[HIBitcoinURIService sharedService] handleBitcoinURIString:scannedQRCode];
}
}

Expand Down

0 comments on commit e252173

Please sign in to comment.