call widget delegate after 1 sec delay. this gives ui time to show points and user...
authordkavanagh <dkavanagh@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 13 May 2010 16:05:02 +0000 (16:05 +0000)
committerdkavanagh <dkavanagh@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 13 May 2010 16:05:02 +0000 (16:05 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1360 59b500cc-1b3d-0410-9834-0bbf25fbcc57

iphone/ZXingWidget/ZXingWidgetController.m

index 754c6e7..d3560af 100755 (executable)
@@ -54,6 +54,12 @@ CGImageRef UIGetScreenImage();
        return self;
 }
 
+- (void)dealloc {
+       AudioServicesDisposeSystemSoundID(beepSound);
+       [overlayView dealloc];
+       [super dealloc];
+}
+
 - (void)cancelled {
        NSLog(@"cancelled called in ZXingWidgetController");
        wasCancelled = true;
@@ -79,6 +85,15 @@ CGImageRef UIGetScreenImage();
        return false;
 }
 
+- (void)viewDidLoad {
+       [super viewDidLoad];
+       NSBundle *mainBundle = [NSBundle mainBundle];
+       OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"caf"] isDirectory:NO], &beepSound);
+       if (error != kAudioServicesNoError) {
+               NSLog(@"Problem loading nearSound.caf");
+       }       
+}
+
 - (void)viewDidAppear:(BOOL)animated {
     [super viewDidAppear:animated];
        [overlayView setPoints:nil];
@@ -119,7 +134,6 @@ CGImageRef UIGetScreenImage();
        NSLog(@"in presentResultForString()");
        self.result = [ResultParser parsedResultForString:resultString];
        AudioServicesPlaySystemSound(beepSound);
-       //      self.actions = self.result.actions;
 #ifdef DEBUG
        NSLog(@"result string = %@", resultString);
        NSLog(@"result has %d actions", actions ? 0 : actions.count);
@@ -140,7 +154,7 @@ CGImageRef UIGetScreenImage();
        NSLog(@"decoded image!!");
        [self presentResultPoints:[twoDResult points] forImage:image usingSubset:subset];
        // now, in a selector, call the delegate to give this overlay time to show the points
-       [self performSelectorOnMainThread:@selector(alertDelegate:) withObject:[[twoDResult text] copy] waitUntilDone:false];
+       [self performSelector:@selector(alertDelegate:) withObject:[[twoDResult text] copy] afterDelay:1.0];
        decoder.delegate = nil;
        [decoder release];
 }