Skip to content

Commit

Permalink
Fix example coding style, add property control setup UIActivityIndica…
Browse files Browse the repository at this point in the history
…torViewStyle
  • Loading branch information
xhzengAIB committed Sep 24, 2015
1 parent 7bcfcaf commit d4b39de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ - (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view.
if (CURRENT_SYS_VERSION >= 7.0) {
self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan=NO;
self.navigationController.interactivePopGestureRecognizer.delaysTouchesBegan = NO;
}
self.title = NSLocalizedStringFromTable(@"Chat", @"MessageDisplayKitString", @"聊天");

// Custom UI
// self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
// [self setBackgroundColor:[UIColor clearColor]];
// [self setBackgroundImage:[UIImage imageNamed:@"TableViewBackgroundImage"]];

Expand Down Expand Up @@ -107,7 +108,7 @@ - (void)viewDidLoad
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSMutableArray *typedMessages = [self filterTypedMessage:queryMessages];
NSMutableArray *messages = [NSMutableArray array];
for(AVIMTypedMessage *typedMessage in typedMessages){
for (AVIMTypedMessage *typedMessage in typedMessages) {
XHMessage *message = [weakSelf displayMessageByAVIMTypedMessage:typedMessage];
if (message) {
[messages addObject:message];
Expand All @@ -118,8 +119,8 @@ - (void)viewDidLoad
[weakSelf.messageTableView reloadData];
[weakSelf scrollToBottomAnimated:NO];
//延迟,以避免上面的滚动触发上拉加载消息
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5*NSEC_PER_SEC), dispatch_get_main_queue(), ^{
weakSelf.loadingMoreMessage=NO;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
weakSelf.loadingMoreMessage = NO;
});
});
});
Expand Down Expand Up @@ -160,7 +161,6 @@ - (void)dealloc {
[[LeanChatManager manager] setupDidReceiveTypedMessageCompletion:nil];
}


#pragma mark - LearnChat Message Handle Method

- (NSMutableArray *)filterTypedMessage:(NSArray *)messages {
Expand Down Expand Up @@ -375,7 +375,7 @@ - (void)loadMoreMessagesScrollTotop {
WEAKSELF
[self.conversation queryMessagesBeforeId:nil timestamp:[message.timestamp timeIntervalSince1970]*1000 limit:kOnePageSize callback:^(NSArray *queryMessages, NSError *error) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSMutableArray *messages=[NSMutableArray array];
NSMutableArray *messages = [NSMutableArray array];
NSMutableArray *typedMessages = [self filterTypedMessage:queryMessages];
for(AVIMTypedMessage *typedMessage in typedMessages){
if (weakSelf) {
Expand Down Expand Up @@ -406,7 +406,7 @@ - (void)didSendText:(NSString *)text fromSender:(NSString *)sender onDate:(NSDat
AVIMTextMessage *sendTextMessage = [AVIMTextMessage messageWithText:text attributes:nil];
WEAKSELF
[self.conversation sendMessage:sendTextMessage callback:^(BOOL succeeded, NSError *error) {
if([weakSelf filterError:error]){
if ([weakSelf filterError:error]) {
[weakSelf insertAVIMTypedMessage:sendTextMessage];
[weakSelf finishSendMessageWithBubbleMessageType:XHBubbleMessageMediaTypeText];
}
Expand Down Expand Up @@ -442,10 +442,10 @@ - (void)didSendPhoto:(UIImage *)photo fromSender:(NSString *)sender onDate:(NSDa
* @param date 发送时间
*/
- (void)didSendVideoConverPhoto:(UIImage *)videoConverPhoto videoPath:(NSString *)videoPath fromSender:(NSString *)sender onDate:(NSDate *)date {
AVIMVideoMessage* sendVideoMessage = [AVIMVideoMessage messageWithText:nil attachedFilePath:videoPath attributes:nil];
AVIMVideoMessage *sendVideoMessage = [AVIMVideoMessage messageWithText:nil attachedFilePath:videoPath attributes:nil];
WEAKSELF
[self.conversation sendMessage:sendVideoMessage callback:^(BOOL succeeded, NSError *error) {
if([weakSelf filterError:error]){
if ([weakSelf filterError:error]) {
[weakSelf insertAVIMTypedMessage:sendVideoMessage];
[weakSelf finishSendMessageWithBubbleMessageType:XHBubbleMessageMediaTypeVideo];
}
Expand Down Expand Up @@ -481,13 +481,13 @@ - (void)didSendVoice:(NSString *)voicePath voiceDuration:(NSString *)voiceDurati
*/
- (void)didSendEmotion:(NSString *)emotionPath fromSender:(NSString *)sender onDate:(NSDate *)date {
WEAKSELF
AVFile* file=[AVFile fileWithName:@"emotion" contentsAtPath:emotionPath];
AVFile *file = [AVFile fileWithName:@"emotion" contentsAtPath:emotionPath];
[file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if([weakSelf filterError:error]){
AVIMEmotionMessage* sendEmotionMessage=[AVIMEmotionMessage messageWithText:file.url attributes:nil];
if ([weakSelf filterError:error]) {
AVIMEmotionMessage *sendEmotionMessage=[AVIMEmotionMessage messageWithText:file.url attributes:nil];
[weakSelf.conversation sendMessage:sendEmotionMessage callback:^(BOOL succeeded, NSError *error) {
DLog(@"succeed: %d, error:%@ ",succeeded,error);
if([weakSelf filterError:error]){
if ([weakSelf filterError:error]) {
[weakSelf insertAVIMTypedMessage:sendEmotionMessage];
[weakSelf finishSendMessageWithBubbleMessageType:XHBubbleMessageMediaTypeEmotion];
}
Expand Down Expand Up @@ -515,7 +515,7 @@ - (void)didSendGeoLocationsPhoto:(UIImage *)geoLocationsPhoto geolocations:(NSSt
*/

- (BOOL)shouldDisplayTimestampForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == 0 || indexPath.row >= self.messages.count) {
if (indexPath.row == 0 || indexPath.row >= self.messages.count) {
return YES;
} else {
XHMessage *message = [self.messages objectAtIndex:indexPath.row];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ - (void)setLoadingMoreMessage:(BOOL)loadingMoreMessage {
[self.loadMoreActivityIndicatorView stopAnimating];
}
}
- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle {
self.loadMoreActivityIndicatorView.activityIndicatorViewStyle = activityIndicatorViewStyle;
}

- (XHShareMenuView *)shareMenuView {
if (!_shareMenuView) {
Expand Down

0 comments on commit d4b39de

Please sign in to comment.