Skip to content

Commit

Permalink
#111 Scroll to bottom on messages load
Browse files Browse the repository at this point in the history
  • Loading branch information
devashishmamgain committed Nov 30, 2015
1 parent 7d35a32 commit 7410af2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
9 changes: 3 additions & 6 deletions sample-with-framework/Applozic/Applozic/ALMQTTService.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,20 @@ - (void)subAckReceived:(MQTTSession *)session msgID:(UInt16)msgID grantedQoss:(N


- (void)connected:(MQTTSession *)session {
NSLog(@"####delegate callback for connected.");

}

- (void)connectionClosed:(MQTTSession *)session {
NSLog(@"####disconnect from mqtt");

}

- (void)handleEvent:(MQTTSession *)session
event:(MQTTSessionEvent)eventCode
error:(NSError *)error {
NSLog(@"####inside handleEvent");
}

- (void)received:(MQTTSession *)session type:(int)type qos:(MQTTQosLevel)qos retained:(BOOL)retained duped:(BOOL)duped mid:(UInt16)mid data:(NSData *)data {
NSLog(@"###MQTTreceived command");
NSLog(@"####type: %i", type);
NSLog(@"####data: %@", data);

}


Expand Down
4 changes: 0 additions & 4 deletions sample-with-framework/Applozic/Applozic/ALMessageDBService.m
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ - (NSArray *)getUnreadMessages:(NSString *) contactId
[fetchRequest setPredicate:predicate];
NSError *fetchError = nil;
NSArray *result = [dbHandler.managedObjectContext executeFetchRequest:fetchRequest error:&fetchError];
if ([contactId isEqualToString:@"applozic"]) {
NSLog(@"the fetch request %@",fetchRequest);
NSLog(@"COUNT VALUE: %lu", result.count);
}
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ -(void) loadChatView

[self.mTableView reloadData];


if (isLoadEarlierTapped) {
if ((theArray != nil && theArray.count < self.rp )|| self.mMessageListArray.count == self.mTotalCount) {
self.mTableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectZero];
Expand All @@ -470,10 +471,13 @@ -(void) loadChatView
}
self.startIndex = theArray.count;

if (self.mMessageListArray.count != 0) {
/*if (self.mMessageListArray.count != 0) {
CGRect theFrame = [self.mTableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:theArray.count-1 inSection:0]];
[self.mTableView setContentOffset:CGPointMake(0, theFrame.origin.y)];
}
}*/
dispatch_async(dispatch_get_main_queue(), ^{
[super scrollTableViewToBottomWithAnimation:YES];
});

}
}
Expand Down Expand Up @@ -922,7 +926,6 @@ -(void)fetchAndRefresh:(BOOL)flag{
dispatch_async(dispatch_get_main_queue(), ^{
[super scrollTableViewToBottomWithAnimation:YES];
[self setTitle];

});
NSLog(@"FETCH AND REFRESH METHOD");
}
Expand Down Expand Up @@ -954,7 +957,6 @@ -(void)individualNotificationhandler:(NSNotification *) notification
-(void) syncCall:(NSString *) contactId updateUI:(NSNumber *) updateUI alertValue: (NSString *) alertValue
{
if ([self.contactIds isEqualToString:contactId]) {
//[self fetchAndRefresh];
NSLog(@"current contact thread is opened");
[self fetchAndRefresh:YES];
//[self processMarkRead];
Expand Down Expand Up @@ -1013,19 +1015,17 @@ -(void)handleNotification:(UIGestureRecognizer*)gestureRecognizer{
}

- (IBAction)loadEarlierButtonAction:(id)sender {

[self processLoadEarlierMessages];

}

-(void)processLoadEarlierMessages{

NSString *time;
if(self.mMessageListArray.count > 0 && self.mMessageListArray != NULL){
if(self.mMessageListArray.count > 0 && self.mMessageListArray != NULL) {
ALMessage * theMessage = self.mMessageListArray[0];
time = theMessage.createdAtTime;
}
else{
else {
time = NULL;
}
[ALMessageService getMessageListForUser:self.contactIds startIndex:@"0" pageSize:@"50" endTimeInTimeStamp:time withCompletion:^(NSMutableArray *messages, NSError *error){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS

ALMessageDBService* messageDBService = [[ALMessageDBService alloc]init];
self.unreadCount=[messageDBService getUnreadMessages:[alContact userId]];
NSLog(@"unread count for userId: %@ is %ld", [alContact userId], (unsigned long)self.unreadCount.count);

// NSLog(@"self.unreadCount Array of ||%@|| withCount ||%lu|| is %@",[alContact userId],(unsigned long)self.unreadCount.count,self.unreadCount);

Expand Down

0 comments on commit 7410af2

Please sign in to comment.