From b60aec3598a12a5bf07ad490fa87723e308cd58b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 10 Nov 2013 15:56:03 +0400 Subject: Images --- Juick/MessagesViewController.m | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) (limited to 'Juick/MessagesViewController.m') diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m index 2e27d43..372345a 100644 --- a/Juick/MessagesViewController.m +++ b/Juick/MessagesViewController.m @@ -18,7 +18,7 @@ #import "NSURL+PathParameters.h" -#import "UIImage+Helpers.h" +#import static NSString *CellIdentifier = @"MessageCell"; @@ -158,23 +158,7 @@ static NSString *CellIdentifier = @"MessageCell"; MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; [cell updateFonts]; Message *msg = [_messages objectAtIndex:indexPath.row]; - [UIImage loadFromURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://i.juick.com/as/%@.png", msg.userID]] callback:^(UIImage *image) { - [cell.avatar setImage:image]; - }]; - cell.titleLabel.text = msg.user; - cell.titleLabel.textColor = [ColorsAndButtons linkColor]; - cell.timestampLabel.text = msg.timestamp; - if (msg.repliesCount > 0) { - cell.summaryLabel.text = [NSString stringWithFormat:@"%@ replies by %@", msg.repliesCount, msg.repliesBy]; - } else { - cell.summaryLabel.text = nil; - } - cell.bodyLabel.text = [msg.text stringByDecodingHTMLEntities]; - if ([msg.tags count] > 0) { - cell.bodyLabel.text = [[NSString alloc] initWithFormat:@"%@\n%@", [msg.tags componentsJoinedByString:@", "], - [msg.text stringByDecodingHTMLEntities]]; - } - [cell setBackgroundColor:[UIColor whiteColor]]; + [cell bind:msg]; [cell setNeedsUpdateConstraints]; return cell; } @@ -188,22 +172,9 @@ static NSString *CellIdentifier = @"MessageCell"; [cell updateFonts]; Message *msg = [_messages objectAtIndex:indexPath.row]; - [UIImage loadFromURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://i.juick.com/as/%@.png", msg.userID]] callback:^(UIImage *image) { - [cell.avatar setImage:image]; - }]; - cell.titleLabel.text = msg.user; - cell.timestampLabel.text = msg.timestamp; - if (msg.repliesCount > 0) { - cell.summaryLabel.text = [NSString stringWithFormat:@"%@ replies by %@", msg.repliesCount, msg.repliesBy]; - } else { - cell.summaryLabel.text = nil; - } - cell.bodyLabel.text = [msg.text stringByDecodingHTMLEntities]; - if ([msg.tags count] > 0) { - cell.bodyLabel.text = [[NSString alloc] initWithFormat:@"%@\n%@", [msg.tags componentsJoinedByString:@", "], - [msg.text stringByDecodingHTMLEntities]]; - } + [cell bind:msg]; + cell.bodyLabel.preferredMaxLayoutWidth = tableView.bounds.size.width - (kLabelHorizontalInsets * 2.0f); [cell setNeedsUpdateConstraints]; -- cgit v1.2.3