Nextrek
@ 466
Nextrek / iOS / SafariArte / trunk / SafariArte / Controllers / FinalQuizVC / FinalQuizVC.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
// // FinalQuizVC.m // SafariArte // // Created by Pier Domenico Bonamassa on 08/07/15. // Copyright (c) 2015 Nextrek. All rights reserved. // #import "FinalQuizVC.h" #import <Social/Social.h> #import "Reachability.h" #import "SFAPercorso.h" #import "GenericWebViewVC.h" #import "FinalQuiz1Cell.h" #import "FInalQuiz2Cell.h" #import <FBSDKCoreKit/FBSDKCoreKit.h> #import <FBSDKShareKit/FBSDKShareKit.h> @interface FinalQuizVC ()<FBSDKSharingDelegate> @property (weak, nonatomic) IBOutlet UIImageView *image; @property (weak, nonatomic) IBOutlet UILabel *labelName; @property (weak, nonatomic) IBOutlet UILabel *labelRoute; @property (weak, nonatomic) IBOutlet UIButton *classificaBtn; @property (weak, nonatomic) IBOutlet UIButton *btnShareFB; @property (weak, nonatomic) IBOutlet UIButton *btnHome; @property (weak, nonatomic) IBOutlet UIButton *btnSendResult; @end @implementation FinalQuizVC { Reachability *internetReachable; } - (void)viewDidLoad { [super viewDidLoad]; [self.navigationItem setHidesBackButton:YES]; self.table.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; self.btnSendResult.titleLabel.text = NSLocalizedString(@"SendResult", nil); self.btnHome.titleLabel.text = NSLocalizedString(@"NewRoute", nil); self.btnShareFB.titleLabel.text = NSLocalizedString(@"ShareFb", nil); self.classificaBtn.titleLabel.text = NSLocalizedString(@"Ranking", nil); self.title = NSLocalizedString(@"RouteEnd", nil); self.labelRoute.text=self.routeForDetail.routeLabel; self.labelName.text = DATAMANAGER.user.name; [DATAMANAGER clearPOIforRoute:self.routeForDetail]; [self.table reloadData]; [DATAMANAGER showMessageWithAlert:self message:NSLocalizedString(@"ShareRoute", nil) tag:004]; } #pragma mark - Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 4; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row==3) { return 141.0f; } return 44.0f; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 3) { FInalQuiz2Cell * cell = (FInalQuiz2Cell *)[tableView dequeueReusableCellWithIdentifier:@"FInalQuiz2Cell"]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"FInalQuiz2Cell" owner:self options:nil]; cell = [topLevelObjects objectAtIndex:0]; } cell.labelTitleCell.text = NSLocalizedString(@"ValutationTitle", nil); cell.textViewCell.text = @"Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."; cell.separatorInset=UIEdgeInsetsMake(0.f, self.view.frame.size.width, 0.f, 0.f); return cell; }else { NSArray *images=@[@"timerFinal",@"clip",@"flag"]; NSArray *title=@[ NSLocalizedString(@"TimeElapsed", nil) ,NSLocalizedString(@"CluesFound", nil),NSLocalizedString(@"FinalScore", nil)]; NSArray *values=@[[DATAMANAGER getTimeForRoute:self.routeForDetail],[NSString stringWithFormat:@"%i",[[DATAMANAGER.user.cluesForRoute objectForKey:self.routeForDetail.routeId] intValue]], [NSString stringWithFormat:@"%i", [[DATAMANAGER.user.pointsForRoute objectForKey:self.routeForDetail.routeId] intValue ]]] ; FinalQuiz1Cell *cell = (FinalQuiz1Cell *)[tableView dequeueReusableCellWithIdentifier:@"FinalQuiz1Cell"]; if (cell == nil) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"FinalQuiz1Cell" owner:self options:nil]; cell = [topLevelObjects objectAtIndex:0]; } [cell.imageCell setImage:[UIImage imageNamed:images[indexPath.row]]]; cell.labelCell.text = title[indexPath.row]; cell.valueLabelCell.text = values[indexPath.row]; return cell; } } #pragma mark - Share results on Facebook - (IBAction)doShareResultToFB:(id)sender { // FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init]; // photo.image=[UIImage imageNamed:self.routeForDetail.routeFileImg]; // Create an object NSDictionary *properties = @{ @"og:type": @"article", @"og:title": self.routeForDetail.routeLabel, @"og:description": [NSString stringWithFormat:NSLocalizedString(@"FBSharingMessage", nil),self.routeForDetail] }; FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties]; // Create an action FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init]; action.actionType = @"news.publishes"; [action setObject:object forKey:@"article"]; FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init]; content.action = action; content.previewPropertyName = @"article"; [FBSDKShareDialog showFromViewController:self withContent:content delegate:self]; } - (IBAction)sendScoreToServer:(id)sender { if (![self testInternetConnection]) { [DATAMANAGER showErrorAlert:self message:NSLocalizedString(@"PleaseTryAgain", nil) tag:102]; } else { [ActivityViewFramed showActivityWithSuperView:APPDEL.window]; [NXTNetwork doSetScoreWithSuccess:self.routeForDetail.routeId score:[DATAMANAGER.user.pointsForRoute objectForKey:self.routeForDetail.routeId] duration: [NSNumber numberWithLong:[[DATAMANAGER.user.timeForRoute objectForKey:self.routeForDetail.routeId] intValue] * 1000 ] successBlock:^(NSDictionary *response) { [ActivityViewFramed hideActivityView]; NSLog(@"TOKEN: %@", response[@"response"][@"token"]); if([DATAMANAGER errorInside:response] == nil) { [DATAMANAGER showAlert:self withTitle: @"Safari D'Arte" message:NSLocalizedString(@"Correctly", nil) tag:02]; } else { [DATAMANAGER showErrorAlert:self message:NSLocalizedString(@"ServerNotRespond", nil) tag:103]; } } failure:^(NSError *error) { [ActivityViewFramed hideActivityView]; [DATAMANAGER showErrorAlert:self message:NSLocalizedString(@"ErrorHasJustBeFound", nil) tag:104]; }]; } } #pragma mark - IBAction - (IBAction)goToHome:(id)sender { [self.navigationController popToRootViewControllerAnimated:TRUE]; } - (IBAction) doOpenClassifica { GenericWebViewVC *genericWebViewVC = [[GenericWebViewVC alloc] init]; genericWebViewVC.title = NSLocalizedString(@"classifica", nil); NSString *urlToCall = [NSString stringWithFormat:@"http://svm19842.vps.tagadab.it:8084/SafariDarte/CtrlArea/ranking/?token=%@", DATAMANAGER.user.token]; genericWebViewVC.urlToCall = urlToCall; self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; [self.navigationController pushViewController:genericWebViewVC animated:YES]; } #pragma mark - MemoryWarning - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (BOOL)testInternetConnection { internetReachable = [Reachability reachabilityWithHostname:@"www.google.com"]; if (internetReachable.isReachable) return TRUE; else return FALSE; } - (void)customIOS7dialogButtonTouchUpInside: (CustomIOSAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex { if(alertView.tag == 02) { [alertView close]; [self goToHome:self]; } if (alertView.tag == 004) { if (buttonIndex == 0) { NSDictionary *properties = @{ @"og:type": @"article", @"og:title": self.routeForDetail.routeLabel, @"og:description": [NSString stringWithFormat:NSLocalizedString(@"FBSharingMessage", nil),self.routeForDetail] }; FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties]; // Create an action FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init]; action.actionType = @"news.publishes"; [action setObject:object forKey:@"article"]; FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init]; content.action = action; content.previewPropertyName = @"article"; [FBSDKShareDialog showFromViewController:self withContent:content delegate:self]; }else { [alertView close]; } } } #pragma mark - FBSDKSharingDelegate - (void) sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results { NSLog(@"Facebook sharing completed: %@", results); } - (void) sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error { NSLog(@"Facebook sharing failed: %@", error); } - (void) sharerDidCancel:(id<FBSDKSharing>)sharer { NSLog(@"Facebook sharing cancelled."); } @end |
Commits for Nextrek/iOS/SafariArte/trunk/SafariArte/Controllers/FinalQuizVC/FinalQuizVC.m
Revision | Author | Commited | Message |
---|---|---|---|
466 Diff | PBonamassa | Mon 03 Aug, 2015 13:20:35 +0000 | fixed bug textView |
464 Diff | PBonamassa | Mon 03 Aug, 2015 12:45:47 +0000 | added popup to confirm correct send score |
453 Diff | PBonamassa | Thu 30 Jul, 2015 15:25:09 +0000 | added sound Frocix |
450 Diff | PBonamassa | Thu 30 Jul, 2015 12:29:55 +0000 | fixed bug |
444 Diff | FPompili | Tue 28 Jul, 2015 14:26:36 +0000 | added customAlertView |
398 Diff | FPompili | Mon 20 Jul, 2015 09:49:48 +0000 | set totalTime to milliseconds |
380 Diff | FPompili | Fri 17 Jul, 2015 12:51:10 +0000 | fixed google |
379 Diff | FPompili | Fri 17 Jul, 2015 11:37:10 +0000 | added facebook sharing |
375 Diff | PBonamassa | Fri 17 Jul, 2015 09:14:11 +0000 | modified finalQuizVC |
369 | FPompili | Thu 16 Jul, 2015 16:57:38 +0000 | added cluesdictionary , fixed something |