summaryrefslogtreecommitdiff
path: root/Juick/MessagesViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/MessagesViewController.m')
-rw-r--r--Juick/MessagesViewController.m37
1 files changed, 4 insertions, 33 deletions
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 <SDWebImage/UIImageView+WebCache.h>
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];