Guest User

Untitled

a guest
Jul 2nd, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.87 KB | None | 0 0
  1. -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  2.  
  3. static NSString *cellIdentifier=@"cellIdentifier";
  4.  
  5. TripInfoListCell *cell=nil;
  6. //[tableView dequeueReusableCellWithIdentifier:nil];
  7.  
  8. if (cell==nil) {
  9.  
  10. cell = (TripInfoListCell *)[[[[NSBundle mainBundle] loadNibNamed:@"TripInfoListCell" owner:self options:nil] firstObject] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
  11.  
  12. }
  13.  
  14. totalRow = [tableView numberOfRowsInSection:indexPath.section];//first get total rows in that section by current indexPath.
  15. cell.PinImageView.image = nil;
  16.  
  17. NSString *direction=[dict123 valueForKey:@"direction" ] ;
  18. NSString *drive_status=[dict123 valueForKey:@"driver_or_rider"];
  19.  
  20. // for trip info page //////////////////////////////////////////////////////
  21. if((indexPath.row==totalRow-1)&&[direction isEqualToString:@"From"])
  22. {
  23.  
  24. __weak TripInfoListCell *weakCell = cell;
  25. if([drive_status isEqualToString:@"Drive"]) //if its a drivetrip from destination
  26. {
  27. cell.PinImageView.image=[UIImage imageNamed:@"pin7@2x.png"];
  28. cell.userNameLabel.text=loggedUser.profile_name;
  29. NSLog(@" line no 1151");
  30. cell.availabiltyInfoLabel.text=@"You"; //added on 2-6-2016 to add You
  31. cell.riderDriverSlNo.text=@"Driver";
  32. }
  33.  
  34. else if([drive_status isEqualToString:@"Ride"]) //if its a Ridetrip from destination
  35. {
  36. cell.riderDriverSlNo.text=@"Driver";
  37. goersInfo=[tableGoersList objectAtIndex:0];
  38. cell.userNameLabel.text=goersInfo[@"name"];//to add driver in case of rider from
  39. NSLog(@" line no 1153");
  40. cell.PinImageView.image=[UIImage imageNamed:@"pin7@2x.png"];
  41. if([goersInfo[@"isGuest"] isEqualToString:@"0"])
  42.  
  43. {
  44. cell.availabiltyInfoLabel.text=@"Confirmed";
  45. NSLog(@" line no 1174");
  46. }
  47. else{
  48. cell.availabiltyInfoLabel.text=@"Unconfirmed";
  49. NSLog(@" line no 1178");
  50. }
  51.  
  52. }
  53.  
  54. goersInfo=[tableGoersList objectAtIndex:0];
  55. NSLog(@"this above line is to add driver image in the last row of from trip");
  56.  
  57. [[NSUserDefaults standardUserDefaults]setObject:[goersInfo valueForKey:@"user_image_url"] forKey:@"user_image"];
  58. [[NSUserDefaults standardUserDefaults]synchronize];
  59.  
  60. NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:goersInfo[@"user_image_url"]]];
  61.  
  62. [cell.userImageView setImageWithURLRequest:request placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
  63.  
  64. weakCell.userImageView.image=image;
  65.  
  66. } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
  67.  
  68. NSLog(@"%@",error);
  69. }];
  70.  
  71. }
  72. else if((indexPath.row==totalRow-1)&&[direction isEqualToString:@"To"]) //2
  73.  
  74. {
  75. cell.PinImageView.image=[UIImage imageNamed:@"pin7@2x.png"];
  76. cell.userNameLabel.text=[_tripDetails objectForKey:@"park_name"];
  77.  
  78. cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"]; // to add destination location to cell
  79. cell.availabiltyInfoLabel.text=@"";
  80. cell.riderDriverSlNo.text=@"";
  81. NSLog(@" line no 1213");
  82.  
  83.  
  84. NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
  85.  
  86. [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
  87.  
  88. if (image) {
  89.  
  90. [cell.userImageView setImage:image];
  91. }
  92. }];
  93.  
  94. }
  95. else if ([tableGoersList count] > indexPath.row) //3
  96. {
  97. goersInfo=[tableGoersList objectAtIndex:indexPath.row];
  98.  
  99. [[NSUserDefaults standardUserDefaults]setObject:[goersInfo valueForKey:@"user_image_url"] forKey:@"user_image"];
  100. [[NSUserDefaults standardUserDefaults]synchronize];
  101.  
  102. __weak TripInfoListCell *weakCell = cell;
  103.  
  104. NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:goersInfo[@"user_image_url"]]];
  105.  
  106. [cell.userImageView setImageWithURLRequest:request placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
  107.  
  108. weakCell.userImageView.image=image;
  109.  
  110. } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
  111.  
  112. NSLog(@"%@",error);
  113. }];
  114.  
  115. // NSString *direction=[dict123 valueForKey:@"direction" ] ;
  116.  
  117. if((indexPath.row==0)&&[direction isEqualToString:@"To"]) {
  118.  
  119. NSLog(@"line no 1227");
  120.  
  121. if([drive_status isEqualToString:@"Drive"]){
  122.  
  123. cell.riderDriverSlNo.text=@"Driver";
  124.  
  125. cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"];
  126. cell.userNameLabel.text=loggedUser.profile_name;
  127. cell.availabiltyInfoLabel.text=@"You";
  128. NSLog(@"line no 1236");
  129.  
  130.  
  131. }
  132. if ([goersInfo[@"isGuest"] isEqualToString:@"0"])
  133. {
  134. cell.availabiltyInfoLabel.text=@"Confirmed";
  135. cell.userNameLabel.text=goersInfo[@"name"];
  136. NSLog(@"line no 1241");
  137. }
  138. else
  139. cell.availabiltyInfoLabel.text=@"Confirmed";
  140. cell.userNameLabel.text=goersInfo[@"name"];
  141. NSLog(@"line no 1242");
  142.  
  143. cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"]; //to show pin// rider case
  144.  
  145.  
  146.  
  147. }
  148. else if((indexPath.row==0)&&[direction isEqualToString:@"From"]) {
  149.  
  150. if([drive_status isEqualToString:@"Drive"])
  151. {
  152.  
  153. cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"];
  154. cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
  155. cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"];
  156. cell.riderDriverSlNo.text=@"";
  157. cell.availabiltyInfoLabel.text=@"";
  158. NSLog(@"line no 1259");
  159.  
  160.  
  161. NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
  162.  
  163. [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
  164.  
  165. if (image) {
  166.  
  167. [cell.userImageView setImage:image];
  168. NSLog(@" line no 1304");
  169. }
  170. }];
  171. }
  172. else if([drive_status isEqualToString:@"Ride"]){
  173. NSLog(@"rider from");
  174. cell.riderDriverSlNo.text=@"";
  175. NSLog(@"line no 1275");
  176.  
  177.  
  178.  
  179. cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"];
  180. cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
  181. cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"];
  182. cell.riderDriverSlNo.text=@"";
  183. cell.availabiltyInfoLabel.text=@"";
  184.  
  185. NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
  186.  
  187. [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
  188.  
  189. if (image) {
  190.  
  191. [cell.userImageView setImage:image];
  192. }
  193. }];
  194. }
  195. }
  196. else{
  197. cell.riderDriverSlNo.text=[NSString stringWithFormat:@"Rider %ld",(long)indexPath.row];
  198.  
  199. NSLog(@"line no 1326");
  200. imageNameArray = [[NSArray alloc] initWithObjects:@"pin2@2x.png", @"pin3@2x.png", @"pin5@2x.png", @"pin6@2x.png",@"pin8@2x.png",@"pin9@2x.png",@"pin2@2x.png", nil];
  201. NSString* nameStr=[goersInfo valueForKey:@"name"];
  202.  
  203. NSArray * nameStrArray = [nameStr componentsSeparatedByString: @"'s"];
  204. nameStr=[nameStrArray objectAtIndex:0];
  205.  
  206. index = [TripInfoVC ifNameExists:_arrName Name:nameStr];
  207.  
  208.  
  209. NSLog(@"CELL -------- array=%@, nameStr=%@, index=%d, row=%ld",_arrName, nameStr, index, (long)indexPath.row);
  210.  
  211.  
  212. if(index == 0)
  213. {
  214. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:0]];
  215. // [_arrName addObject:nameStr];
  216.  
  217. }
  218. if(index == 1)
  219. {
  220. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:1]];
  221. }
  222. if(index == 2)
  223. {
  224. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:2]];
  225. }
  226.  
  227. if(index == 3)
  228. {
  229. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:3]];
  230. }
  231.  
  232.  
  233. if(index == 4)
  234. {
  235. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:4]];
  236. }
  237.  
  238. if(index == 5)
  239. {
  240. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:5]];
  241. }
  242.  
  243. if(index == 6)
  244. {
  245. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:0]];
  246. }
  247.  
  248. if(index == 7)
  249. {
  250. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:1]];
  251. }
  252.  
  253. if(index == 8)
  254. {
  255. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:2]];
  256. }
  257.  
  258. if(index == 9)
  259. {
  260. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:3]];
  261. }
  262. if(index == 10)
  263. {
  264. cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:4]];
  265. }
  266. }
  267.  
  268. // for trip info main page
  269.  
  270. if ([goersInfo[@"status_trip"] isEqualToString:@"1"]) {
  271.  
  272. if ([goersInfo[@"email"] isEqualToString:loggedUser.email]) {
  273.  
  274. if ([goersInfo[@"isGuest"] isEqualToString:@"0"]) { //isGuest 0 means the own user
  275.  
  276.  
  277.  
  278. if ((indexPath.row==0)&&[direction isEqualToString:@"From"])
  279. {
  280. cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
  281. cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"];
  282. cell.availabiltyInfoLabel.text=@"";
  283. NSLog(@"line no 1364");
  284.  
  285.  
  286. NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
  287.  
  288. [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
  289.  
  290. if (image) {
  291.  
  292. [cell.userImageView setImage:image];
  293. }
  294. }];
  295.  
  296. }
  297. else{
  298.  
  299. if([drive_status isEqualToString:@"Drive"])
  300. {
  301. cell.userNameLabel.text=loggedUser.profile_name;
  302.  
  303. cell.availabiltyInfoLabel.text=@"You";
  304. }
  305.  
  306. else{
  307.  
  308.  
  309. cell.userNameLabel.text=goersInfo[@"name"];
  310. cell.availabiltyInfoLabel.text=@"You";
  311. NSLog(@" line no 1415");
  312.  
  313. }
  314. }
  315. }
  316. else{ // it shud come here if guest=1 means not a driver
  317.  
  318. // cell.userNameLabel.text=[NSString stringWithFormat:@"%@'s Guest",loggedUser.profile_name];
  319.  
  320. cell.userNameLabel.text=[NSString stringWithFormat:@"%@'s Guest",goersInfo[@"name"]]; /* changed this to show rider's guest
  321. information as the riders' Guest*/
  322.  
  323. cell.availabiltyInfoLabel.text=@"Confirmed";
  324. NSLog(@"line no 1687");
  325.  
  326. //cell.PinImageView.image=[UIImage imageNamed:@"pin5@2x.png"]; //just to check
  327. }
  328. }
  329. else{ //
  330.  
  331. // cell.userNameLabel.text=goersInfo[@"name"];
  332. if([drive_status isEqualToString:@"Drive"])
  333. {
  334. cell.userNameLabel.text=goersInfo[@"name"];
  335. cell.availabiltyInfoLabel.text=@"Confirmed";
  336. NSLog(@"line no 1698");
  337.  
  338. }
  339. else
  340.  
  341. if([direction isEqualToString:@"From"])
  342. {
  343. if(indexPath.row==0)
  344. {
  345. cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
  346. NSLog(@"line no 1705 %@",cell.userNameLabel.text);
  347. }
  348. else{
  349.  
  350. cell.userNameLabel.text=goersInfo[@"name"];
  351. NSLog(@"line no 1709 %@",cell.userNameLabel.text);
  352. cell.availabiltyInfoLabel.text=@"Confirmed";
  353.  
  354. }
  355. }
  356.  
  357. }
  358. }
  359.  
  360.  
  361.  
  362. else if ((indexPath.row==0)&&[direction isEqualToString:@"To"]) {
  363.  
  364. if([drive_status isEqualToString:@"Ride"])
  365. {
  366. cell.availabiltyInfoLabel.text=@"Unconfirmed";
  367. cell.userNameLabel.text=@"driver";
  368. cell.riderDriverSlNo.text=@"Driver";
  369. cell.PinImageView.hidden=NO; //to remove the green pin from the
  370. // unconfirmed driver
  371. cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"];
  372. NSLog(@"line no 1426");
  373.  
  374. }
  375. else{
  376. cell.availabiltyInfoLabel.text=@"You";
  377. cell.userNameLabel.text=loggedUser.profile_name;
  378. }
  379. }
  380.  
  381.  
  382.  
  383. else if ((indexPath.row==0)&&[direction isEqualToString:@"From"]){
  384.  
  385. cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
  386. cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"]; // to add destination location to cell
  387. cell.availabiltyInfoLabel.text=@"";
  388. cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"]; //to show green pin in case of from ride and Ride case
  389. NSLog(@"line no 1449");
  390.  
  391.  
  392. NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
  393.  
  394. [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
  395.  
  396. if (image) {
  397.  
  398. [cell.userImageView setImage:image];
  399. }
  400. }];
  401.  
  402. }
  403.  
  404. else
  405. {
  406. cell.userNameLabel.text=@"Rider";
  407. cell.PinImageView.hidden=YES;
  408. cell.availabiltyInfoLabel.text=@"Unconfirmed";
  409. }
  410.  
  411.  
  412. }
  413. else
  414. {
  415. NSLog(@"index beyond limits");
  416. }
  417.  
  418. return cell;
  419. }
Add Comment
Please, Sign In to add comment