Mercurial > hg > soniczoomios
comparison TimedSessionController.mm @ 29:fabb3a5cdfc9
Timed session improvements. Desperate pathetic attempts to send a simple HTTP POST.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 22 Feb 2013 17:41:38 +0000 |
parents | |
children | c0a6f7c66719 |
comparison
equal
deleted
inserted
replaced
28:e2c62db1e265 | 29:fabb3a5cdfc9 |
---|---|
1 // | |
2 // TimedSessionController.m | |
3 // sonicZoom | |
4 // | |
5 // Created by Robert Tubb on 18/02/2013. | |
6 // | |
7 // | |
8 #import "testApp.h" | |
9 #import "TimedSessionController.h" | |
10 @interface TimedSessionController() | |
11 // private stuff | |
12 | |
13 @end | |
14 | |
15 @implementation TimedSessionController | |
16 | |
17 int orders[6][3] = {{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}}; | |
18 int theOrder; | |
19 int scount; | |
20 | |
21 NSArray *alertMessages = [NSArray arrayWithObjects: | |
22 @"Thanks, now try the sliders only", | |
23 @"Thanks, now try the sliders and the Zoomer together", | |
24 @"Thanks, now try the zoomer only", | |
25 @"Thanks, now please take the questionnaire",nil]; | |
26 | |
27 // nicer if it was initWithAppRef ? | |
28 - (void)setAppRef:(id)theOFApp{ | |
29 self.theOFAppRef = theOFApp; | |
30 theOrder = arc4random() % 6; | |
31 NSLog(@"the order: %d", theOrder); | |
32 | |
33 scount = 0; | |
34 } | |
35 -(void)startTimer{ | |
36 // SHOW FIRST PROMPT | |
37 NSString *themessage; | |
38 themessage = [alertMessages objectAtIndex:orders[theOrder][0]]; | |
39 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Thanks!" | |
40 message:themessage | |
41 delegate:self | |
42 cancelButtonTitle:@"Continue" | |
43 otherButtonTitles:nil]; | |
44 alert.alertViewStyle = UIAlertViewStyleDefault; | |
45 [alert show]; | |
46 [alert release]; | |
47 | |
48 } | |
49 -(void)resetTime:(int)newTime{ | |
50 | |
51 } | |
52 | |
53 // ALERT | |
54 | |
55 | |
56 -(void)showNextPrompt{ | |
57 NSString *themessage; | |
58 scount++; | |
59 if(scount < 3){ | |
60 themessage = [alertMessages objectAtIndex:orders[theOrder][scount] ]; | |
61 }else{ | |
62 themessage = [alertMessages objectAtIndex:3 ]; | |
63 } | |
64 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Thanks!" | |
65 message:themessage | |
66 delegate:self | |
67 cancelButtonTitle:@"Continue" | |
68 otherButtonTitles:nil]; | |
69 alert.alertViewStyle = UIAlertViewStyleDefault; | |
70 [alert show]; | |
71 [alert release]; | |
72 | |
73 } | |
74 | |
75 -(void)cancelTimers{ | |
76 scount = 0; | |
77 if(self.theCurrentTimer){ | |
78 [self.theCurrentTimer invalidate]; | |
79 self.theCurrentTimer = nil; | |
80 } | |
81 } | |
82 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ | |
83 | |
84 NSLog(@"OK TO NEXT VIEW"); | |
85 | |
86 if(scount < 3){ | |
87 NSInteger next = orders[theOrder][scount]; | |
88 ((testApp *)self.theOFAppRef)->interfaceSelected(next); | |
89 | |
90 self.theCurrentTimer = [NSTimer scheduledTimerWithTimeInterval:SECONDS_PER_INTERFACE target:self selector:@selector(showNextPrompt) userInfo:nil repeats:NO]; | |
91 | |
92 }else{ | |
93 ((testApp *)self.theOFAppRef)->showQuestionnaire(); | |
94 scount = 0; // incase we try again | |
95 self.theCurrentTimer = nil; | |
96 } | |
97 | |
98 } | |
99 | |
100 | |
101 @end |