Compare commits

...

2 Commits

4 changed files with 87 additions and 92 deletions

View File

@@ -2651,9 +2651,6 @@ BannerSchedulerDelegate
- (XPRoomAnimationHitView *)bannerContainer { - (XPRoomAnimationHitView *)bannerContainer {
if (!_bannerContainer) { if (!_bannerContainer) {
_bannerContainer = [[XPRoomAnimationHitView alloc] init]; _bannerContainer = [[XPRoomAnimationHitView alloc] init];
#if DEBUG
_bannerContainer.backgroundColor = [UIColor colorWithWhite:0.8 alpha:0.4];
#endif
} }
return _bannerContainer; return _bannerContainer;
} }
@@ -3649,14 +3646,6 @@ BannerSchedulerDelegate
self.savedTapPoint = CGPointZero; self.savedTapPoint = CGPointZero;
} }
- (void)debugBannerSchedulerStatus {
NSLog(@"🔍 BannerScheduler 调试信息:");
NSLog(@"%@", [self.bannerScheduler debugStatus]);
NSLog(@"🔍 RoomAnimationView 状态:");
NSLog(@" - isRoomBannerV2Displaying: %@", self.isRoomBannerV2Displaying ? @"YES" : @"NO");
NSLog(@" - bannerContainer.subviews.count: %ld", (long)self.bannerContainer.subviews.count);
}
- (CGRect)calculateInteractiveBoundsForView:(UIView *)view { - (CGRect)calculateInteractiveBoundsForView:(UIView *)view {
// //
// Banner // Banner
@@ -3674,44 +3663,6 @@ BannerSchedulerDelegate
return bounds; return bounds;
} }
- (void)testBannerScheduler {
NSLog(@"🧪 开始测试 BannerScheduler");
// Banner
AttachmentModel *testBanner = [[AttachmentModel alloc] init];
testBanner.second = Custom_Message_Sub_Super_Gift_Banner;
testBanner.data = @{@"test": @"data"};
[self.bannerScheduler enqueueBanner:testBanner];
NSLog(@"🧪 测试完成");
}
- (void)debugTouchAreaCache {
NSLog(@"🎯 触摸区域缓存调试信息:");
TouchAreaCacheManager *cacheManager = [TouchAreaCacheManager sharedManager];
[cacheManager debugPrintCache];
}
- (void)debugGestureOptimizer {
NSLog(@"🎯 手势优化器调试信息:");
GestureOptimizer *optimizer = [GestureOptimizer sharedOptimizer];
//
CGFloat containerWidth = self.bannerContainer.bounds.size.width;
CGPoint leftPoint = CGPointMake(containerWidth * 0.1, 40); //
CGPoint centerPoint = CGPointMake(containerWidth * 0.5, 40); //
CGPoint rightPoint = CGPointMake(containerWidth * 0.9, 40); //
NSLog(@"🎯 测试左侧区域点:");
[optimizer debugGestureAreaForPoint:leftPoint containerWidth:containerWidth];
NSLog(@"🎯 测试中央区域点:");
[optimizer debugGestureAreaForPoint:centerPoint containerWidth:containerWidth];
NSLog(@"🎯 测试右侧区域点:");
[optimizer debugGestureAreaForPoint:rightPoint containerWidth:containerWidth];
}
#pragma mark - Cleanup Methods #pragma mark - Cleanup Methods

View File

@@ -108,27 +108,16 @@
// //
- (void)rebuildNormalConstraints { - (void)rebuildNormalConstraints {
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) { [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.contentView); make.top.mas_equalTo(self.contentView);
make.leading.mas_equalTo(self.contentView).offset(12); make.leading.mas_equalTo(self.contentView).offset(12);
make.bottom.mas_equalTo(self.contentView).offset(-20); make.bottom.mas_equalTo(self.contentView).offset(-20);
make.width.mas_equalTo(kRoomMessageMaxWidth); make.width.mas_equalTo(kRoomMessageMaxWidth);
}]; }];
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) { [self.bubbleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.contentLabel).insets(UIEdgeInsetsMake(0, -10, 0, -10)); make.edges.mas_equalTo(self.contentLabel).insets(UIEdgeInsetsMake(0, -10, 0, -10));
}]; }];
// [self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
// make.leading.mas_equalTo(8);
// make.top.bottom.mas_equalTo(0);
// make.trailing.mas_equalTo(-8);
// }];
//
// [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
// make.edges.mas_equalTo(UIEdgeInsetsMake(4, 12, 4, 12));
// }];
} }
#pragma mark - tool #pragma mark - tool
@@ -164,20 +153,28 @@
#pragma mark - Getters And Setters #pragma mark - Getters And Setters
- (void)setMessageInfo:(XPMessageInfoModel *)messageInfo { - (void)setMessageInfo:(XPMessageInfoModel *)messageInfo {
if ([messageInfo.content isEqualToAttributedString:_messageInfo.content]) { //
if (_messageInfo &&
[messageInfo.content isEqualToAttributedString:_messageInfo.content] &&
[messageInfo.bubbleImageUrl isEqualToString:_messageInfo.bubbleImageUrl] &&
[messageInfo.boomImageUrl isEqualToString:_messageInfo.boomImageUrl]) {
return; return;
} }
_messageInfo = messageInfo; _messageInfo = messageInfo;
if (messageInfo) { if (messageInfo) {
// attributedTexthasBubble // attributedTexthasBubble
self.contentLabel.hasBubble = ![NSString isEmpty:messageInfo.bubbleImageUrl]; BOOL hasBubble = ![NSString isEmpty:messageInfo.bubbleImageUrl];
if (self.contentLabel.hasBubble != hasBubble) {
self.contentLabel.hasBubble = hasBubble;
}
self.contentLabel.attributedText = messageInfo.content; self.contentLabel.attributedText = messageInfo.content;
if (self.isLeftBigImage) { if (self.isLeftBigImage && messageInfo.boomImageUrl) {
self.leftBigImageView.imageUrl = messageInfo.boomImageUrl; self.leftBigImageView.imageUrl = messageInfo.boomImageUrl;
} }
} }
} }
- (void)updateLayoutWithoutBubble:(BOOL)hasBubble layoutSize:(CGSize)size { - (void)updateLayoutWithoutBubble:(BOOL)hasBubble layoutSize:(CGSize)size {
@@ -216,12 +213,12 @@
UIImage *cutImage = [image1 cropRightAndBottomPixels:2]; UIImage *cutImage = [image1 cropRightAndBottomPixels:2];
self.bubbleImageView.image = [self resizableImage:cutImage]; self.bubbleImageView.image = [self resizableImage:cutImage];
}]; }];
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) { [self.bubbleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.contentLabel).insets(UIEdgeInsetsMake(-10, -10, -10, -10)); make.edges.mas_equalTo(self.contentLabel).insets(UIEdgeInsetsMake(-10, -10, -10, -10));
}]; }];
} else { } else {
self.bubbleImageView.image = [UIImage imageWithColor:[DJDKMIMOMColor messageBubbleColor]]; self.bubbleImageView.image = [UIImage imageWithColor:[DJDKMIMOMColor messageBubbleColor]];
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) { [self.bubbleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.contentLabel).insets(UIEdgeInsetsMake(0, -10, 0, -10)); make.edges.mas_equalTo(self.contentLabel).insets(UIEdgeInsetsMake(0, -10, 0, -10));
}]; }];
} }

View File

@@ -210,9 +210,11 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
} }
// 4. // 4.
BOOL needReloadData = NO;
if (self.datasource.count > kRoomMessageMaxLength) { if (self.datasource.count > kRoomMessageMaxLength) {
NSInteger removedCount = kRoomMessageMaxLength / 2; NSInteger removedCount = kRoomMessageMaxLength / 2;
[self safelyRemoveMessages:removedCount]; [self safelyRemoveMessages:removedCount];
needReloadData = YES; //
} }
// 5. // 5.
@@ -230,7 +232,13 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
} }
[self updateAllDataSource:tempNewDatas]; [self updateAllDataSource:tempNewDatas];
[self.incomingMessages removeAllObjects]; [self.incomingMessages removeAllObjects];
[self.messageTableView reloadData];
// 使 reloadData使
if (needReloadData) {
[self.messageTableView reloadData];
} else if (indexPaths.count > 0) {
[self.messageTableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
}
// 6. // 6.
[self scrollToFirstLocationOrBottom]; [self scrollToFirstLocationOrBottom];
@@ -463,13 +471,16 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
return; return;
} }
BOOL needReloadData = NO;
if (self.datasource.count > kRoomMessageMaxLength) { if (self.datasource.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)]; NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set]; NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
[self.datasource removeObjectsInArray:needRemoveMsgArray]; [self.datasource removeObjectsInArray:needRemoveMsgArray];
needReloadData = YES; //
} }
NSMutableArray *tempArray = @[].mutableCopy; NSMutableArray *tempArray = @[].mutableCopy;
NSMutableArray *indexPaths = @[].mutableCopy;
@kWeakify(self); @kWeakify(self);
[self.incomingMessages enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { [self.incomingMessages enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
@kStrongify(self); @kStrongify(self);
@@ -482,13 +493,20 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
if (model) { if (model) {
[tempArray addObject:model]; [tempArray addObject:model];
[self.datasource addObject:model]; [self.datasource addObject:model];
[indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
} }
}]; }];
[self.incomingMessages removeAllObjects]; [self.incomingMessages removeAllObjects];
[self updateAllDataSource:tempArray]; [self updateAllDataSource:tempArray];
[self.messageTableView reloadData];
// 使 reloadData使
if (needReloadData) {
[self.messageTableView reloadData];
} else if (indexPaths.count > 0) {
[self.messageTableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
}
// //
[self scrollToBottom:NO]; [self scrollToBottom:NO];
@@ -514,7 +532,17 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
} }
if(source.count > 0){ if(source.count > 0){
NSIndexPath *ip = [NSIndexPath indexPathForRow:source.count-1 inSection:0]; // NSIndexPath *ip = [NSIndexPath indexPathForRow:source.count-1 inSection:0]; //
[self.messageTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:animated]; //
//
if (animated) {
// 使 dispatch_async
dispatch_async(dispatch_get_main_queue(), ^{
[self.messageTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:YES];
});
} else {
[self.messageTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:NO];
}
self.atCount = 0; self.atCount = 0;
self.atTipBtn.hidden = YES; self.atTipBtn.hidden = YES;
[self.locationArray removeAllObjects]; [self.locationArray removeAllObjects];
@@ -1282,14 +1310,33 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row]; XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row];
// model 使 model // 使 UITableViewAutomaticDimension
if (model.rowHeight > 0) { if (model.rowHeight <= 0) {
return model.rowHeight + 20; [self calculateRowHeightForModel:model];
} }
// 使 return model.rowHeight + 20;
// return 100; }
return UITableViewAutomaticDimension;
//
- (void)calculateRowHeightForModel:(XPMessageInfoModel *)model {
if (!model || !model.content) {
model.rowHeight = 44; //
return;
}
// 使 YYTextLayout
YYTextContainer *container = [YYTextContainer new];
container.size = CGSizeMake(kRoomMessageMaxWidth - 24, MAXFLOAT);
container.maximumNumberOfRows = 0;
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:model.content];
model.rowHeight = layout.textBoundingSize.height;
//
if (model.rowHeight < 44) {
model.rowHeight = 44;
}
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
@@ -1492,8 +1539,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
_messageTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; _messageTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_messageTableView.delegate = self; _messageTableView.delegate = self;
_messageTableView.dataSource = self; _messageTableView.dataSource = self;
_messageTableView.rowHeight = UITableViewAutomaticDimension; // UITableViewAutomaticDimension使
// _messageTableView.estimatedRowHeight = 44; // _messageTableView.rowHeight = 64; //
_messageTableView.tableFooterView = [UIView new]; _messageTableView.tableFooterView = [UIView new];
_messageTableView.separatorStyle = UITableViewCellSeparatorStyleNone; _messageTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_messageTableView.backgroundColor = [UIColor clearColor]; _messageTableView.backgroundColor = [UIColor clearColor];

View File

@@ -1928,19 +1928,19 @@ XPCandyTreeInsufficientBalanceViewDelegate>
[self handleNIMNotificationTypeMessage:message]; [self handleNIMNotificationTypeMessage:message];
} else if (message.messageType == NIMMessageTypeCustom) { } else if (message.messageType == NIMMessageTypeCustom) {
// first/second/size3 // first/second/size3
#if DEBUG //#if DEBUG
if ([message.messageObject isKindOfClass:[NIMCustomObject class]]) { // if ([message.messageObject isKindOfClass:[NIMCustomObject class]]) {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; // NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if ([obj.attachment isKindOfClass:[AttachmentModel class]]) { // if ([obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *att = (AttachmentModel *)obj.attachment; // AttachmentModel *att = (AttachmentModel *)obj.attachment;
NSData *payloadJSON = nil; // NSData *payloadJSON = nil;
@try { payloadJSON = [NSJSONSerialization dataWithJSONObject:att.data ?: @{} options:0 error:nil]; } @catch (__unused NSException *e) {} // @try { payloadJSON = [NSJSONSerialization dataWithJSONObject:att.data ?: @{} options:0 error:nil]; } @catch (__unused NSException *e) {}
NSLog(@"[Recv] 🎯 自定义消息 | first=%ld second=%ld | payload=%lub | sid=%@ | ts=%.3f", // NSLog(@"[Recv] 🎯 自定义消息 | first=%ld second=%ld | payload=%lub | sid=%@ | ts=%.3f",
(long)att.first, (long)att.second, (unsigned long)payloadJSON.length, // (long)att.first, (long)att.second, (unsigned long)payloadJSON.length,
message.session.sessionId, [[NSDate date] timeIntervalSince1970]); // message.session.sessionId, [[NSDate date] timeIntervalSince1970]);
} // }
} // }
#endif //#endif
[self handleNimCustomTypeMessage:message]; [self handleNimCustomTypeMessage:message];
} else if(message.messageType == NIMMessageTypeText) { } else if(message.messageType == NIMMessageTypeText) {
[self.messageContainerView handleNIMTextMessage:message]; [self.messageContainerView handleNIMTextMessage:message];