summaryrefslogtreecommitdiff
path: root/Juick/MessagesViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/MessagesViewController.m')
-rw-r--r--Juick/MessagesViewController.m46
1 files changed, 5 insertions, 41 deletions
diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m
index ff7e556..2cf4267 100644
--- a/Juick/MessagesViewController.m
+++ b/Juick/MessagesViewController.m
@@ -21,9 +21,6 @@
static NSString *CellIdentifier = @"MessageCell";
-static NSMutableDictionary *heightsCache;
-
-
@interface MessagesViewController ();
@@ -84,8 +81,9 @@ static NSMutableDictionary *heightsCache;
self.navigationController.navigationBar.tintColor = [ColorScheme navbarBackground];
}
- [self.tableView registerClass:[MessageCell class] forCellReuseIdentifier:CellIdentifier];
- heightsCache = [[NSMutableDictionary alloc] init];
+ [self.tableView registerNib:[UINib nibWithNibName:@"MessageCell" bundle:nil] forCellReuseIdentifier:CellIdentifier];
+ self.tableView.rowHeight = UITableViewAutomaticDimension;
+ self.tableView.estimatedRowHeight = 500.0f;
}
- (void) composePressed {
@@ -119,12 +117,6 @@ static NSMutableDictionary *heightsCache;
}
}
-- (void)didReceiveMemoryWarning
-{
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
-}
-
- (void)contentSizeCategoryChanged:(NSNotification *)notification
{
[self.tableView reloadData];
@@ -139,8 +131,7 @@ static NSMutableDictionary *heightsCache;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- [cell updateFonts];
+ MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Message *msg = [_messages objectAtIndex:indexPath.row];
[cell setMessage:msg];
if ([msg.attach length] > 0) {
@@ -148,12 +139,7 @@ static NSMutableDictionary *heightsCache;
[manager downloadWithURL:[NSURL URLWithString:msg.attach] options:SDWebImageContinueInBackground progress:^(NSInteger receivedSize, NSInteger expectedSize) {
// <#code#>
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
- [cell.attach setImage:[UIImage imageWithImage:image convertToWidth:300.0f]];
- [heightsCache setObject:[NSNumber numberWithFloat:[cell heightForCell]] forKey:[NSString stringWithFormat:@"%@#%@", msg.MID, msg.RID]];
- [tableView beginUpdates];
- [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
- [tableView endUpdates];
-
+ [cell.attach setImage:[UIImage imageWithImage:image convertToWidth:300.0f]];
}];
} else {
cell.attach.image = nil;
@@ -162,28 +148,6 @@ static NSMutableDictionary *heightsCache;
return cell;
}
-- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
-{
- Message *msg = [_messages objectAtIndex:indexPath.row];
- float height = [[heightsCache objectForKey:[NSString stringWithFormat:@"%@#%@", msg.MID, msg.RID]] floatValue];
- if (height > 0) {
- return height;
- } else {
- MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- [cell updateFonts];
- [cell setMessage:msg];
- return [cell heightForCell];
- }
-}
-
-- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
-{
- /* if (self.dataLoading) {
- return [self tableView:tableView heightForRowAtIndexPath:indexPath];
- }*/
- return 500.0f;
-}
-
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.path isEqualToString:[Message threadUrl]])
return;