diff options
author | Siqi LIU <me@siqi.fr> | 2013-09-08 12:42:17 +0200 |
---|---|---|
committer | Siqi LIU <me@siqi.fr> | 2013-09-08 12:42:28 +0200 |
commit | c755f71b8b5b009573a673f3f757609ca0ef5ffd (patch) | |
tree | 30c2121c607af7f22f3a53e8033365e6374d1521 /ios | |
parent | 01f7ab201c4819ada35c6c29ec79810c91906545 (diff) |
various bug fixes related to countdown timer
Change-Id: Ie1feb26c1b4d72b37d8767c30644f2411dbd2121
Diffstat (limited to 'ios')
8 files changed, 22 insertions, 9 deletions
diff --git a/ios/iosremote/iosremote/SWRevealViewController/SWRevealViewController.h b/ios/iosremote/iosremote/SWRevealViewController/SWRevealViewController.h index dc7e144382d9..1610fef5d497 100755 --- a/ios/iosremote/iosremote/SWRevealViewController/SWRevealViewController.h +++ b/ios/iosremote/iosremote/SWRevealViewController/SWRevealViewController.h @@ -60,6 +60,8 @@ typedef enum @interface SWRevealViewController : UIViewController <StopWatchDelegate, TimerDelegate> +- (void)startTimePickerwithTimer:(Timer *) timer; + // Object instance init and rear view setting - (id)initWithRearViewController:(UIViewController *)rearViewController frontViewController:(UIViewController *)frontViewController; @@ -173,8 +175,6 @@ typedef enum @property (strong) void(^performBlock)( SWRevealViewControllerSegue* segue, UIViewController* svc, UIViewController* dvc ); -- (void)startTimePickerwithTimer:(Timer *) timer; - @end diff --git a/ios/iosremote/iosremote/SWRevealViewController/SWRevealViewController.m b/ios/iosremote/iosremote/SWRevealViewController/SWRevealViewController.m index 922f83c2272d..3414114d24cc 100755 --- a/ios/iosremote/iosremote/SWRevealViewController/SWRevealViewController.m +++ b/ios/iosremote/iosremote/SWRevealViewController/SWRevealViewController.m @@ -436,7 +436,6 @@ const int FrontViewPositionNone = 0xff; - (void)startTimePickerwithTimer:(Timer *) timer { - NSLog(@"Fired by : %@", [timer class]); [self callDP:self]; } diff --git a/ios/iosremote/iosremote/Timer.m b/ios/iosremote/iosremote/Timer.m index 57c5f7a1c162..6e866d422f95 100644 --- a/ios/iosremote/iosremote/Timer.m +++ b/ios/iosremote/iosremote/Timer.m @@ -34,7 +34,7 @@ int initSecondsLeft; self = [super init]; self.state = TIMER_STATE_CLEARED; self.set = NO; - secondsLeft = 30; + secondsLeft = 0; return self; } @@ -70,10 +70,19 @@ int initSecondsLeft; [self.startButton addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside]; [self.clearButton addTarget:self action:@selector(clear) forControlEvents:UIControlEventTouchUpInside]; // Sending the sender as well, so that we get a handle on the Timer itself ---> allow us to update seconds left - [self.setTimeButton addTarget:self.delegate action:@selector(startTimePickerwithTimer:) forControlEvents:UIControlEventTouchUpInside]; + [self.setTimeButton addTarget:self action:@selector(startTimePickerwithTimer) forControlEvents:UIControlEventTouchUpInside]; self.set = YES; } +- (void)startTimePickerwithTimer +{ + if (self.state == TIMER_STATE_RUNNING) { + // If running, we switch it to pause before setting a new duration + [self start]; + } + [self.delegate startTimePickerwithTimer:self]; +} + - (void)updateTimer { // Create date from the elapsed time @@ -106,6 +115,10 @@ int initSecondsLeft; case TIMER_STATE_RUNNING: self.state = TIMER_STATE_PAUSED; [self.timerTimer invalidate]; + if (secondsLeft == 0) { + [self.timeLabel setText:@"00:00:00"]; + } + [self.delegate setTitle:@"" sender:self]; break; case TIMER_STATE_PAUSED: self.state = TIMER_STATE_RUNNING; @@ -121,6 +134,8 @@ int initSecondsLeft; secondsLeft++; [self updateTimer]; // Create the stop watch timer that fires every 100 ms + [self.timerTimer invalidate]; + self.timerTimer = nil; self.timerTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimer) @@ -173,7 +188,7 @@ int initSecondsLeft; - (void) setSecondsLeft:(NSTimeInterval)duration { secondsLeft = (int) duration; - + initSecondsLeft = secondsLeft; hours = secondsLeft / 3600; minutes = (secondsLeft % 3600) / 60; seconds = (secondsLeft %3600) % 60; diff --git a/ios/iosremote/iosremote/UIViewController+LibOStyling.h b/ios/iosremote/iosremote/UIViewController+LibOStyling.h index 24b5babcb91e..57ed9bc86cfd 100644 --- a/ios/iosremote/iosremote/UIViewController+LibOStyling.h +++ b/ios/iosremote/iosremote/UIViewController+LibOStyling.h @@ -24,6 +24,5 @@ TitleLabelOwner owner; - (void)setTitle:(NSString *)title; - (void)setOwner:(TitleLabelOwner) aOwner; -- (void)startTimePickerwithTimer:(Timer *) timer; @end diff --git a/ios/iosremote/iosremote/UIViewController+LibOStyling.m b/ios/iosremote/iosremote/UIViewController+LibOStyling.m index 193f912e0631..b9cd7ef51077 100644 --- a/ios/iosremote/iosremote/UIViewController+LibOStyling.m +++ b/ios/iosremote/iosremote/UIViewController+LibOStyling.m @@ -9,7 +9,6 @@ #import "UIViewController+LibOStyling.h" #import "ControlVariables.h" #import "Timer.h" -#import "TimerCountdownTimePicker.h" #import "stopWatch.h" @implementation UIViewController (LibOStyling) diff --git a/ios/iosremote/iosremote/slideShowSwipeInList_iphone.m b/ios/iosremote/iosremote/slideShowSwipeInList_iphone.m index 2424e101978d..01fbb9ccb113 100644 --- a/ios/iosremote/iosremote/slideShowSwipeInList_iphone.m +++ b/ios/iosremote/iosremote/slideShowSwipeInList_iphone.m @@ -52,6 +52,7 @@ dispatch_queue_t backgroundQueue; self.clearsSelectionOnViewWillAppear = NO; // set stopwatch as default, users may swipe for a timer self.currentPage = 0; + [self.revealViewController setOwner:STOPWATCH]; self.stopWatch = [[stopWatch alloc] init]; if ([[NSUserDefaults standardUserDefaults] boolForKey:KEY_TIMER]) { diff --git a/ios/iosremote/iosremote/slideShow_vc_iphone.m b/ios/iosremote/iosremote/slideShow_vc_iphone.m index 29882527654d..1d8f2db7724a 100644 --- a/ios/iosremote/iosremote/slideShow_vc_iphone.m +++ b/ios/iosremote/iosremote/slideShow_vc_iphone.m @@ -306,7 +306,6 @@ target:self.revealViewController action:@selector( revealToggle: )]; self.revealViewController.navigationItem.leftBarButtonItem = self.revealButtonItem; - [self.navigationController.navigationBar addGestureRecognizer: self.revealViewController.panGestureRecognizer]; self.pointerCalibrationOn = NO; self.movingPointer.layer.cornerRadius = 3; diff --git a/ios/iosremote/iosremote/stopWatch.m b/ios/iosremote/iosremote/stopWatch.m index c5c942ec95c6..716508b6aa28 100644 --- a/ios/iosremote/iosremote/stopWatch.m +++ b/ios/iosremote/iosremote/stopWatch.m @@ -90,6 +90,7 @@ case TIMER_STATE_RUNNING: self.state = TIMER_STATE_PAUSED; [self.stopWatchTimer invalidate]; + [self.delegate setTitle:@"" sender:self]; self.lastInterval += [[NSDate date] timeIntervalSinceDate:self.startDate]; break; case TIMER_STATE_PAUSED: |