forked from mirrors/linphone-iphone
update the size of chat cell once app's version has been modified
This commit is contained in:
parent
cbfdb96de7
commit
e631c6b81e
3 changed files with 10 additions and 2 deletions
|
|
@ -39,6 +39,7 @@
|
|||
@private
|
||||
NSMutableArray *eventList;
|
||||
NSMutableArray *totalEventList;
|
||||
BOOL preLoad;
|
||||
}
|
||||
|
||||
@property(nonatomic) LinphoneChatRoom *chatRoom;
|
||||
|
|
|
|||
|
|
@ -105,7 +105,9 @@
|
|||
|
||||
- (void)reloadData {
|
||||
[self updateData];
|
||||
preLoad = TRUE;
|
||||
[self.tableView reloadData];
|
||||
preLoad = FALSE;
|
||||
[self scrollToLastUnread:false];
|
||||
}
|
||||
|
||||
|
|
@ -295,6 +297,9 @@ static const int BASIC_EVENT_LIST=20;
|
|||
static const CGFloat MESSAGE_SPACING_PERCENTAGE = 1.f;
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
// pre-download data
|
||||
if (preLoad)
|
||||
return 0;
|
||||
LinphoneEventLog *event = [[eventList objectAtIndex:indexPath.row] pointerValue];
|
||||
if (linphone_event_log_get_type(event) == LinphoneEventLogTypeConferenceChatMessage) {
|
||||
LinphoneChatMessage *chat = linphone_event_log_get_chat_message(event);
|
||||
|
|
|
|||
|
|
@ -421,9 +421,10 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
|
|||
|
||||
+ (CGSize)ViewHeightForMessageText:(LinphoneChatMessage *)chat withWidth:(int)width textForImdn:(NSString *)imdnText{
|
||||
|
||||
// avoid calculating the size each time
|
||||
// Avoid calculating the size each time, it takes too much time. Update the size of the chat cell once the version of the application has been modified.
|
||||
NSString *chatSize = [LinphoneManager getMessageAppDataForKey:@"newChatSize" inMessage:chat];
|
||||
if (chatSize && !imdnText)
|
||||
NSString *version = [NSString stringWithFormat:@"%@-%@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"],[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
|
||||
if (chatSize && !imdnText && [version isEqualToString:[LinphoneManager getMessageAppDataForKey:@"appVersion" inMessage:chat]])
|
||||
return CGSizeFromString(chatSize);
|
||||
|
||||
NSString *messageText = [UIChatBubbleTextCell TextMessageForChat:chat];
|
||||
|
|
@ -510,6 +511,7 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
|
|||
size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN, CELL_MIN_HEIGHT);
|
||||
|
||||
[LinphoneManager setValueInMessageAppData:NSStringFromCGSize(size) forKey:@"newChatSize" inMessage:chat];
|
||||
[LinphoneManager setValueInMessageAppData:version forKey:@"appVersion" inMessage:chat];
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue