summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-08-14 04:06:34 +0300
committerGravatar Vitaly Takmazov2016-08-14 04:06:34 +0300
commit24214562b017cd45edc04c39daa343c57de16aaa (patch)
tree434898b690874485fa6a8ad3d8f75077a040a1a1 /Juick
parent561df6a1c494bf820c0ed7e3a5b448efd41003f2 (diff)
new infinite scroll
Diffstat (limited to 'Juick')
-rw-r--r--Juick/Juick-Prefix.pch1
-rw-r--r--Juick/MessagesViewController.h1
-rw-r--r--Juick/MessagesViewController.m20
3 files changed, 13 insertions, 9 deletions
diff --git a/Juick/Juick-Prefix.pch b/Juick/Juick-Prefix.pch
index bd31eac..42ff0f3 100644
--- a/Juick/Juick-Prefix.pch
+++ b/Juick/Juick-Prefix.pch
@@ -16,6 +16,7 @@
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import <SDWebImage/UIImageView+WebCache.h>
+ #import <UIScrollView+InfiniteScroll.h>
#import "NSString+HTML.h"
#import "UIImage+Utils.h"
#import "NSDate+TimeAgo.h"
diff --git a/Juick/MessagesViewController.h b/Juick/MessagesViewController.h
index b0c6a7f..38123bd 100644
--- a/Juick/MessagesViewController.h
+++ b/Juick/MessagesViewController.h
@@ -7,7 +7,6 @@
//
#import <UIKit/UIKit.h>
-#import "SVPullToRefresh.h"
@interface MessagesViewController : UITableViewController<UISplitViewControllerDelegate>
- (void)loadFromPath:(NSString *)messagesPath withParams:(NSDictionary *)params withTitle:(NSString *)title;
diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m
index 2cf4267..25622a9 100644
--- a/Juick/MessagesViewController.m
+++ b/Juick/MessagesViewController.m
@@ -39,14 +39,8 @@ static NSString *CellIdentifier = @"MessageCell";
[self setParams:[[NSMutableDictionary alloc] initWithDictionary:params]];
self.title = title;
__weak MessagesViewController * weakSelf = self;
- [self.tableView addPullToRefreshWithActionHandler:^{
- [weakSelf.messages removeAllObjects];
- [weakSelf refreshData];
- }];
- [self.tableView addInfiniteScrollingWithActionHandler:^{
- [weakSelf refreshData];
- }];
- [self.tableView triggerPullToRefresh];
+ [self.messages removeAllObjects];
+ [weakSelf refreshData];
}
- (void) refreshData {
@@ -55,6 +49,7 @@ static NSString *CellIdentifier = @"MessageCell";
[Message pullNextFromPath:self.path params:self.params callback:^(NSArray *next) {
[self.messages addObjectsFromArray:next];
[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
+ [self.refreshControl performSelectorOnMainThread:@selector(endRefreshing) withObject:nil waitUntilDone:NO];
self.dataLoading = NO;
}];
});
@@ -84,6 +79,15 @@ static NSString *CellIdentifier = @"MessageCell";
[self.tableView registerNib:[UINib nibWithNibName:@"MessageCell" bundle:nil] forCellReuseIdentifier:CellIdentifier];
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 500.0f;
+ self.refreshControl = [UIRefreshControl new];
+ [self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
+ __weak MessagesViewController * weakSelf = self;
+ [self.tableView addInfiniteScrollWithHandler:^(UITableView * _Nonnull tableView) {
+ NSNumber *lastMid = ((Message *)[weakSelf.messages lastObject]).MID;
+ [weakSelf.params setValue:lastMid forKey:@"before_mid"];
+ [weakSelf refreshData];
+ [weakSelf.tableView finishInfiniteScroll];
+ }];
}
- (void) composePressed {