房间公屏气泡

This commit is contained in:
chenguilong
2022-03-21 15:52:33 +08:00
committed by fengshuo
parent aae2031360
commit cb20184a00
5 changed files with 38 additions and 1 deletions

View File

@@ -50,6 +50,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
@property (nonatomic,strong) NSMutableArray<NSAttributedString *> *datasource;
///
@property (nonatomic,strong) NSMutableArray<NIMMessage *> *incomingMessages;
///
@property (nonatomic, strong) NSMutableArray *messageBubbles;
///messageView TODO:
@property (nonatomic,strong) XPRoomMessageParser *messageParser;
///
@@ -158,12 +160,14 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
[self.datasource removeObjectsInArray:needRemoveMsgArray];
[self.messageBubbles removeObjectsInArray:needRemoveMsgArray];
}
//
NSMutableArray *indexPaths = [NSMutableArray array];
for (NIMMessage *item in self.incomingMessages) {
[self.datasource addObject:[self.messageParser parseMessageAttribute:item]];
[self.messageBubbles addObject:[self.messageParser parseMessageBubble:item]];
[indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
}
[self.incomingMessages removeAllObjects];
@@ -338,6 +342,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
[self.datasource removeAllObjects];
[self.incomingMessages removeAllObjects];
[self.messageBubbles removeAllObjects];
[[XPRoomMiniManager shareManager] resetLocalMessage];
[self addRoomMessage:message];
return;
@@ -506,6 +511,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
cell = [[XPRoomMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
}
NSAttributedString* attr = [self.datasource objectAtIndex:indexPath.row];
NSString *bubbleStr = [self.messageBubbles objectAtIndex:indexPath.row];
cell.bubbleImageUrl = bubbleStr;
cell.attributedString = attr;
return cell;
}
@@ -613,6 +620,13 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
return _incomingMessages;
}
- (NSMutableArray *)messageBubbles {
if (!_messageBubbles) {
_messageBubbles = [NSMutableArray array];
}
return _messageBubbles;
}
- (XPRoomMessageParser *)messageParser {
if (!_messageParser) {
_messageParser = [[XPRoomMessageParser alloc] init];