房间公屏气泡
This commit is contained in:
@@ -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];
|
||||
|
Reference in New Issue
Block a user