Skip to content

Commit d4b39de

Browse files
committed
Fix example coding style, add property control setup UIActivityIndicatorViewStyle
1 parent 7bcfcaf commit d4b39de

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

Example/MessageDisplayKitLeanchatExample/MessageDisplayKitLeanchatExample/Sections/Pages/IM/LeanChatMessageTableViewController.m

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ - (void)viewDidLoad
5555
[super viewDidLoad];
5656
// Do any additional setup after loading the view.
5757
if (CURRENT_SYS_VERSION >= 7.0) {
58-
self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan=NO;
58+
self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan = NO;
5959
}
6060
self.title = NSLocalizedStringFromTable(@"Chat", @"MessageDisplayKitString", @"聊天");
6161

6262
// Custom UI
63+
// self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
6364
// [self setBackgroundColor:[UIColor clearColor]];
6465
// [self setBackgroundImage:[UIImage imageNamed:@"TableViewBackgroundImage"]];
6566

@@ -107,7 +108,7 @@ - (void)viewDidLoad
107108
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
108109
NSMutableArray *typedMessages = [self filterTypedMessage:queryMessages];
109110
NSMutableArray *messages = [NSMutableArray array];
110-
for(AVIMTypedMessage *typedMessage in typedMessages){
111+
for (AVIMTypedMessage *typedMessage in typedMessages) {
111112
XHMessage *message = [weakSelf displayMessageByAVIMTypedMessage:typedMessage];
112113
if (message) {
113114
[messages addObject:message];
@@ -118,8 +119,8 @@ - (void)viewDidLoad
118119
[weakSelf.messageTableView reloadData];
119120
[weakSelf scrollToBottomAnimated:NO];
120121
//延迟,以避免上面的滚动触发上拉加载消息
121-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
122-
weakSelf.loadingMoreMessage=NO;
122+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
123+
weakSelf.loadingMoreMessage = NO;
123124
});
124125
});
125126
});
@@ -160,7 +161,6 @@ - (void)dealloc {
160161
[[LeanChatManager manager] setupDidReceiveTypedMessageCompletion:nil];
161162
}
162163

163-
164164
#pragma mark - LearnChat Message Handle Method
165165

166166
- (NSMutableArray *)filterTypedMessage:(NSArray *)messages {
@@ -375,7 +375,7 @@ - (void)loadMoreMessagesScrollTotop {
375375
WEAKSELF
376376
[self.conversation queryMessagesBeforeId:nil timestamp:[message.timestamp timeIntervalSince1970]*1000 limit:kOnePageSize callback:^(NSArray *queryMessages, NSError *error) {
377377
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
378-
NSMutableArray *messages=[NSMutableArray array];
378+
NSMutableArray *messages = [NSMutableArray array];
379379
NSMutableArray *typedMessages = [self filterTypedMessage:queryMessages];
380380
for(AVIMTypedMessage *typedMessage in typedMessages){
381381
if (weakSelf) {
@@ -406,7 +406,7 @@ - (void)didSendText:(NSString *)text fromSender:(NSString *)sender onDate:(NSDat
406406
AVIMTextMessage *sendTextMessage = [AVIMTextMessage messageWithText:text attributes:nil];
407407
WEAKSELF
408408
[self.conversation sendMessage:sendTextMessage callback:^(BOOL succeeded, NSError *error) {
409-
if([weakSelf filterError:error]){
409+
if ([weakSelf filterError:error]) {
410410
[weakSelf insertAVIMTypedMessage:sendTextMessage];
411411
[weakSelf finishSendMessageWithBubbleMessageType:XHBubbleMessageMediaTypeText];
412412
}
@@ -442,10 +442,10 @@ - (void)didSendPhoto:(UIImage *)photo fromSender:(NSString *)sender onDate:(NSDa
442442
* @param date 发送时间
443443
*/
444444
- (void)didSendVideoConverPhoto:(UIImage *)videoConverPhoto videoPath:(NSString *)videoPath fromSender:(NSString *)sender onDate:(NSDate *)date {
445-
AVIMVideoMessage* sendVideoMessage = [AVIMVideoMessage messageWithText:nil attachedFilePath:videoPath attributes:nil];
445+
AVIMVideoMessage *sendVideoMessage = [AVIMVideoMessage messageWithText:nil attachedFilePath:videoPath attributes:nil];
446446
WEAKSELF
447447
[self.conversation sendMessage:sendVideoMessage callback:^(BOOL succeeded, NSError *error) {
448-
if([weakSelf filterError:error]){
448+
if ([weakSelf filterError:error]) {
449449
[weakSelf insertAVIMTypedMessage:sendVideoMessage];
450450
[weakSelf finishSendMessageWithBubbleMessageType:XHBubbleMessageMediaTypeVideo];
451451
}
@@ -481,13 +481,13 @@ - (void)didSendVoice:(NSString *)voicePath voiceDuration:(NSString *)voiceDurati
481481
*/
482482
- (void)didSendEmotion:(NSString *)emotionPath fromSender:(NSString *)sender onDate:(NSDate *)date {
483483
WEAKSELF
484-
AVFile* file=[AVFile fileWithName:@"emotion" contentsAtPath:emotionPath];
484+
AVFile *file = [AVFile fileWithName:@"emotion" contentsAtPath:emotionPath];
485485
[file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
486-
if([weakSelf filterError:error]){
487-
AVIMEmotionMessage* sendEmotionMessage=[AVIMEmotionMessage messageWithText:file.url attributes:nil];
486+
if ([weakSelf filterError:error]) {
487+
AVIMEmotionMessage *sendEmotionMessage=[AVIMEmotionMessage messageWithText:file.url attributes:nil];
488488
[weakSelf.conversation sendMessage:sendEmotionMessage callback:^(BOOL succeeded, NSError *error) {
489489
DLog(@"succeed: %d, error:%@ ",succeeded,error);
490-
if([weakSelf filterError:error]){
490+
if ([weakSelf filterError:error]) {
491491
[weakSelf insertAVIMTypedMessage:sendEmotionMessage];
492492
[weakSelf finishSendMessageWithBubbleMessageType:XHBubbleMessageMediaTypeEmotion];
493493
}
@@ -515,7 +515,7 @@ - (void)didSendGeoLocationsPhoto:(UIImage *)geoLocationsPhoto geolocations:(NSSt
515515
*/
516516

517517
- (BOOL)shouldDisplayTimestampForRowAtIndexPath:(NSIndexPath *)indexPath {
518-
if(indexPath.row == 0 || indexPath.row >= self.messages.count) {
518+
if (indexPath.row == 0 || indexPath.row >= self.messages.count) {
519519
return YES;
520520
} else {
521521
XHMessage *message = [self.messages objectAtIndex:indexPath.row];

MessageDisplayKit/Classes/Controllers/XHMessageTableViewController/XHMessageTableViewController.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ - (void)setLoadingMoreMessage:(BOOL)loadingMoreMessage {
329329
[self.loadMoreActivityIndicatorView stopAnimating];
330330
}
331331
}
332+
- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle {
333+
self.loadMoreActivityIndicatorView.activityIndicatorViewStyle = activityIndicatorViewStyle;
334+
}
332335

333336
- (XHShareMenuView *)shareMenuView {
334337
if (!_shareMenuView) {

0 commit comments

Comments
 (0)