summaryrefslogtreecommitdiff
path: root/Juick/MessageCell.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/MessageCell.m')
-rw-r--r--Juick/MessageCell.m28
1 files changed, 18 insertions, 10 deletions
diff --git a/Juick/MessageCell.m b/Juick/MessageCell.m
index 3f06436..0dea69a 100644
--- a/Juick/MessageCell.m
+++ b/Juick/MessageCell.m
@@ -7,9 +7,8 @@
//
#import "MessageCell.h"
-#import "ColorsAndButtons.h"
-#import "Masonry.h"
-#import "JMImageCache.h"
+#import "ColorScheme.h"
+#import <SDWebImage/UIImageView+WebCache.h>
@interface MessageCell ()
@@ -23,7 +22,7 @@
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
- [self setBackgroundColor:[UIColor whiteColor]];
+ [self.contentView setBackgroundColor:[UIColor whiteColor]];
self.avatar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
[self.avatar setBackgroundColor:[UIColor clearColor]];
@@ -31,7 +30,7 @@
[self.titleLabel setLineBreakMode:NSLineBreakByTruncatingTail];
[self.titleLabel setNumberOfLines:1];
[self.titleLabel setTextAlignment:NSTextAlignmentLeft];
- [self.titleLabel setTextColor:[ColorsAndButtons linkColor]];
+ [self.titleLabel setTextColor:[ColorScheme linkColor]];
[self.titleLabel setBackgroundColor:[UIColor clearColor]];
self.timestampLabel = [[UILabel alloc] initWithFrame:CGRectZero];
@@ -105,19 +104,16 @@
make.left.equalTo(self.avatar.right).with.offset(padding.left);
make.top.equalTo(self.titleLabel.bottom).with.offset(padding.top /2);
make.right.equalTo(self.contentView.right).with.offset(-padding.right);
- make.bottom.equalTo(self.bodyLabel.top).with.offset(-padding.bottom);
}];
[self.bodyLabel makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).with.offset(padding.left);
make.top.equalTo(self.timestampLabel.bottom).with.offset(padding.top);
make.right.equalTo(self.contentView.right).with.offset(-padding.right);
- make.bottom.equalTo(self.attach.top).with.offset(-padding.bottom);
}];
[self.attach makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).with.offset(padding.left);
- make.bottom.equalTo(self.summaryLabel.top).with.offset(-padding.bottom);
make.right.equalTo(self.contentView.right).with.offset(-padding.right);
make.top.equalTo(self.bodyLabel.bottom).with.offset(padding.top);
}];
@@ -147,7 +143,7 @@
- (void) bind:(Message *)msg {
[self.avatar setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://i.juick.com/as/%d.png", [msg.userID intValue]]]];
-
+ __weak MessageCell *weakSelf = self;
self.titleLabel.text = msg.user;
self.timestampLabel.text = msg.timestamp;
if (msg.repliesCount > 0) {
@@ -165,10 +161,22 @@
[msg.text stringByDecodingHTMLEntities]];
}
if ([msg.attach length] > 0) {
- [self.attach setImageWithURL:[NSURL URLWithString:msg.attach] key:[NSString stringWithFormat:@"%d", [msg.MID intValue]] placeholder:[UIImage imageNamed:@"AttachPlaceholder.png"]];
+ [self.attach setImageWithURL:[NSURL URLWithString:msg.attach] placeholderImage:[UIImage imageNamed:@"AttachPlaceholder.png"] options:SDWebImageContinueInBackground
+ progress:^(NSUInteger receivedSize, long long expectedSize) {
+ // <#code#>
+ } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
+ [weakSelf setNeedsUpdateConstraints];
+ [weakSelf updateConstraintsIfNeeded];
+ [weakSelf.contentView setNeedsLayout];
+ [weakSelf.contentView layoutIfNeeded];
+ }];
} else {
self.attach.image = nil;
}
+ [weakSelf setNeedsUpdateConstraints];
+ [weakSelf updateConstraintsIfNeeded];
+ [weakSelf.contentView setNeedsLayout];
+ [weakSelf.contentView layoutIfNeeded];
}
- (void) attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url {