Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- static NSString *cellIdentifier=@"cellIdentifier";
- TripInfoListCell *cell=nil;
- //[tableView dequeueReusableCellWithIdentifier:nil];
- if (cell==nil) {
- cell = (TripInfoListCell *)[[[[NSBundle mainBundle] loadNibNamed:@"TripInfoListCell" owner:self options:nil] firstObject] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
- }
- totalRow = [tableView numberOfRowsInSection:indexPath.section];//first get total rows in that section by current indexPath.
- cell.PinImageView.image = nil;
- NSString *direction=[dict123 valueForKey:@"direction" ] ;
- NSString *drive_status=[dict123 valueForKey:@"driver_or_rider"];
- // for trip info page //////////////////////////////////////////////////////
- if((indexPath.row==totalRow-1)&&[direction isEqualToString:@"From"])
- {
- __weak TripInfoListCell *weakCell = cell;
- if([drive_status isEqualToString:@"Drive"]) //if its a drivetrip from destination
- {
- cell.PinImageView.image=[UIImage imageNamed:@"pin7@2x.png"];
- cell.userNameLabel.text=loggedUser.profile_name;
- NSLog(@" line no 1151");
- cell.availabiltyInfoLabel.text=@"You"; //added on 2-6-2016 to add You
- cell.riderDriverSlNo.text=@"Driver";
- }
- else if([drive_status isEqualToString:@"Ride"]) //if its a Ridetrip from destination
- {
- cell.riderDriverSlNo.text=@"Driver";
- goersInfo=[tableGoersList objectAtIndex:0];
- cell.userNameLabel.text=goersInfo[@"name"];//to add driver in case of rider from
- NSLog(@" line no 1153");
- cell.PinImageView.image=[UIImage imageNamed:@"pin7@2x.png"];
- if([goersInfo[@"isGuest"] isEqualToString:@"0"])
- {
- cell.availabiltyInfoLabel.text=@"Confirmed";
- NSLog(@" line no 1174");
- }
- else{
- cell.availabiltyInfoLabel.text=@"Unconfirmed";
- NSLog(@" line no 1178");
- }
- }
- goersInfo=[tableGoersList objectAtIndex:0];
- NSLog(@"this above line is to add driver image in the last row of from trip");
- [[NSUserDefaults standardUserDefaults]setObject:[goersInfo valueForKey:@"user_image_url"] forKey:@"user_image"];
- [[NSUserDefaults standardUserDefaults]synchronize];
- NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:goersInfo[@"user_image_url"]]];
- [cell.userImageView setImageWithURLRequest:request placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
- weakCell.userImageView.image=image;
- } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
- NSLog(@"%@",error);
- }];
- }
- else if((indexPath.row==totalRow-1)&&[direction isEqualToString:@"To"]) //2
- {
- cell.PinImageView.image=[UIImage imageNamed:@"pin7@2x.png"];
- cell.userNameLabel.text=[_tripDetails objectForKey:@"park_name"];
- cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"]; // to add destination location to cell
- cell.availabiltyInfoLabel.text=@"";
- cell.riderDriverSlNo.text=@"";
- NSLog(@" line no 1213");
- NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
- [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
- if (image) {
- [cell.userImageView setImage:image];
- }
- }];
- }
- else if ([tableGoersList count] > indexPath.row) //3
- {
- goersInfo=[tableGoersList objectAtIndex:indexPath.row];
- [[NSUserDefaults standardUserDefaults]setObject:[goersInfo valueForKey:@"user_image_url"] forKey:@"user_image"];
- [[NSUserDefaults standardUserDefaults]synchronize];
- __weak TripInfoListCell *weakCell = cell;
- NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:goersInfo[@"user_image_url"]]];
- [cell.userImageView setImageWithURLRequest:request placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
- weakCell.userImageView.image=image;
- } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
- NSLog(@"%@",error);
- }];
- // NSString *direction=[dict123 valueForKey:@"direction" ] ;
- if((indexPath.row==0)&&[direction isEqualToString:@"To"]) {
- NSLog(@"line no 1227");
- if([drive_status isEqualToString:@"Drive"]){
- cell.riderDriverSlNo.text=@"Driver";
- cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"];
- cell.userNameLabel.text=loggedUser.profile_name;
- cell.availabiltyInfoLabel.text=@"You";
- NSLog(@"line no 1236");
- }
- if ([goersInfo[@"isGuest"] isEqualToString:@"0"])
- {
- cell.availabiltyInfoLabel.text=@"Confirmed";
- cell.userNameLabel.text=goersInfo[@"name"];
- NSLog(@"line no 1241");
- }
- else
- cell.availabiltyInfoLabel.text=@"Confirmed";
- cell.userNameLabel.text=goersInfo[@"name"];
- NSLog(@"line no 1242");
- cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"]; //to show pin// rider case
- }
- else if((indexPath.row==0)&&[direction isEqualToString:@"From"]) {
- if([drive_status isEqualToString:@"Drive"])
- {
- cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"];
- cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
- cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"];
- cell.riderDriverSlNo.text=@"";
- cell.availabiltyInfoLabel.text=@"";
- NSLog(@"line no 1259");
- NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
- [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
- if (image) {
- [cell.userImageView setImage:image];
- NSLog(@" line no 1304");
- }
- }];
- }
- else if([drive_status isEqualToString:@"Ride"]){
- NSLog(@"rider from");
- cell.riderDriverSlNo.text=@"";
- NSLog(@"line no 1275");
- cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"];
- cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
- cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"];
- cell.riderDriverSlNo.text=@"";
- cell.availabiltyInfoLabel.text=@"";
- NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
- [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
- if (image) {
- [cell.userImageView setImage:image];
- }
- }];
- }
- }
- else{
- cell.riderDriverSlNo.text=[NSString stringWithFormat:@"Rider %ld",(long)indexPath.row];
- NSLog(@"line no 1326");
- 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];
- NSString* nameStr=[goersInfo valueForKey:@"name"];
- NSArray * nameStrArray = [nameStr componentsSeparatedByString: @"'s"];
- nameStr=[nameStrArray objectAtIndex:0];
- index = [TripInfoVC ifNameExists:_arrName Name:nameStr];
- NSLog(@"CELL -------- array=%@, nameStr=%@, index=%d, row=%ld",_arrName, nameStr, index, (long)indexPath.row);
- if(index == 0)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:0]];
- // [_arrName addObject:nameStr];
- }
- if(index == 1)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:1]];
- }
- if(index == 2)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:2]];
- }
- if(index == 3)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:3]];
- }
- if(index == 4)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:4]];
- }
- if(index == 5)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:5]];
- }
- if(index == 6)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:0]];
- }
- if(index == 7)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:1]];
- }
- if(index == 8)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:2]];
- }
- if(index == 9)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:3]];
- }
- if(index == 10)
- {
- cell.PinImageView.image=[UIImage imageNamed:[imageNameArray objectAtIndex:4]];
- }
- }
- // for trip info main page
- if ([goersInfo[@"status_trip"] isEqualToString:@"1"]) {
- if ([goersInfo[@"email"] isEqualToString:loggedUser.email]) {
- if ([goersInfo[@"isGuest"] isEqualToString:@"0"]) { //isGuest 0 means the own user
- if ((indexPath.row==0)&&[direction isEqualToString:@"From"])
- {
- cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
- cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"];
- cell.availabiltyInfoLabel.text=@"";
- NSLog(@"line no 1364");
- NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
- [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
- if (image) {
- [cell.userImageView setImage:image];
- }
- }];
- }
- else{
- if([drive_status isEqualToString:@"Drive"])
- {
- cell.userNameLabel.text=loggedUser.profile_name;
- cell.availabiltyInfoLabel.text=@"You";
- }
- else{
- cell.userNameLabel.text=goersInfo[@"name"];
- cell.availabiltyInfoLabel.text=@"You";
- NSLog(@" line no 1415");
- }
- }
- }
- else{ // it shud come here if guest=1 means not a driver
- // cell.userNameLabel.text=[NSString stringWithFormat:@"%@'s Guest",loggedUser.profile_name];
- cell.userNameLabel.text=[NSString stringWithFormat:@"%@'s Guest",goersInfo[@"name"]]; /* changed this to show rider's guest
- information as the riders' Guest*/
- cell.availabiltyInfoLabel.text=@"Confirmed";
- NSLog(@"line no 1687");
- //cell.PinImageView.image=[UIImage imageNamed:@"pin5@2x.png"]; //just to check
- }
- }
- else{ //
- // cell.userNameLabel.text=goersInfo[@"name"];
- if([drive_status isEqualToString:@"Drive"])
- {
- cell.userNameLabel.text=goersInfo[@"name"];
- cell.availabiltyInfoLabel.text=@"Confirmed";
- NSLog(@"line no 1698");
- }
- else
- if([direction isEqualToString:@"From"])
- {
- if(indexPath.row==0)
- {
- cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
- NSLog(@"line no 1705 %@",cell.userNameLabel.text);
- }
- else{
- cell.userNameLabel.text=goersInfo[@"name"];
- NSLog(@"line no 1709 %@",cell.userNameLabel.text);
- cell.availabiltyInfoLabel.text=@"Confirmed";
- }
- }
- }
- }
- else if ((indexPath.row==0)&&[direction isEqualToString:@"To"]) {
- if([drive_status isEqualToString:@"Ride"])
- {
- cell.availabiltyInfoLabel.text=@"Unconfirmed";
- cell.userNameLabel.text=@"driver";
- cell.riderDriverSlNo.text=@"Driver";
- cell.PinImageView.hidden=NO; //to remove the green pin from the
- // unconfirmed driver
- cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"];
- NSLog(@"line no 1426");
- }
- else{
- cell.availabiltyInfoLabel.text=@"You";
- cell.userNameLabel.text=loggedUser.profile_name;
- }
- }
- else if ((indexPath.row==0)&&[direction isEqualToString:@"From"]){
- cell.userNameLabel.text=[dict123 objectForKey:@"park_name"];
- cell.DestinationLoc.text=[dict123 objectForKey:@"park_address"]; // to add destination location to cell
- cell.availabiltyInfoLabel.text=@"";
- cell.PinImageView.image=[UIImage imageNamed:@"pin1@2x.png"]; //to show green pin in case of from ride and Ride case
- NSLog(@"line no 1449");
- NSString *image=[NSString stringWithFormat:@"%@",[dict123 objectForKey:@"parkBannerImageUrl"]];
- [[ImageHandler sharedInstance] getImageFromURL:image withCompletion:^(UIImage *image) {
- if (image) {
- [cell.userImageView setImage:image];
- }
- }];
- }
- else
- {
- cell.userNameLabel.text=@"Rider";
- cell.PinImageView.hidden=YES;
- cell.availabiltyInfoLabel.text=@"Unconfirmed";
- }
- }
- else
- {
- NSLog(@"index beyond limits");
- }
- return cell;
- }
Add Comment
Please, Sign In to add comment