summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/Juick-Prefix.pch4
-rw-r--r--Juick/MessagesViewController.m38
-rw-r--r--Juick/RevealPanelViewController.h1
-rw-r--r--Juick/Views/MessageCell.m2
4 files changed, 20 insertions, 25 deletions
diff --git a/Juick/Juick-Prefix.pch b/Juick/Juick-Prefix.pch
index 42ff0f3..7836550 100644
--- a/Juick/Juick-Prefix.pch
+++ b/Juick/Juick-Prefix.pch
@@ -15,10 +15,10 @@
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <MobileCoreServices/MobileCoreServices.h>
- #import <SDWebImage/UIImageView+WebCache.h>
- #import <UIScrollView+InfiniteScroll.h>
+ #import <UIImageView+DFImageManager.h>
#import "NSString+HTML.h"
#import "UIImage+Utils.h"
#import "NSDate+TimeAgo.h"
#import "TTTAttributedLabel.h"
+ #import <SWRevealViewController.h>
#endif
diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m
index fe2c14d..91833e1 100644
--- a/Juick/MessagesViewController.m
+++ b/Juick/MessagesViewController.m
@@ -6,8 +6,6 @@
// Copyright (c) 2013 com.juick. All rights reserved.
//
-#import "SWRevealViewController.h"
-
#import "MessagesViewController.h"
#import "MessageCell.h"
@@ -44,6 +42,9 @@ static NSString *CellIdentifier = @"MessageCell";
}
- (void) refreshData {
+ if ([self.path isEqualToString:[Message threadUrl]]) {
+ [self.messages removeAllObjects];
+ }
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
self.dataLoading = YES;
[Message pullNextFromPath:self.path params:self.params callback:^(NSArray *next) {
@@ -77,19 +78,7 @@ static NSString *CellIdentifier = @"MessageCell";
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) {
- if ([weakSelf.path isEqualToString:[Message threadUrl]]) {
- [weakSelf.messages removeAllObjects];
- } else {
- NSNumber *lastMid = ((Message *)[weakSelf.messages lastObject]).MID;
- [weakSelf.params setValue:lastMid forKey:@"before_mid"];
- }
- [weakSelf refreshData];
- [weakSelf.tableView finishInfiniteScroll];
- }];
-}
+ [self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];}
- (void) composePressed {
CATransition* transition = [CATransition animation];
@@ -140,12 +129,7 @@ static NSString *CellIdentifier = @"MessageCell";
Message *msg = [_messages objectAtIndex:indexPath.row];
[cell setMessage:msg];
if ([msg.attach length] > 0) {
- SDWebImageManager * manager = [SDWebImageManager sharedManager];
- [manager downloadWithURL:[NSURL URLWithString:msg.attach] options:SDWebImageContinueInBackground progress:^(NSInteger receivedSize, NSInteger expectedSize) {
- // <#code#>
- } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
- [cell.attach setImage:[UIImage imageWithImage:image convertToWidth:300.0f]];
- }];
+ [cell.attach df_setImageWithResource:[NSURL URLWithString:msg.attach]];
} else {
cell.attach.image = nil;
}
@@ -170,5 +154,17 @@ static NSString *CellIdentifier = @"MessageCell";
self.navigationItem.leftBarButtonItem = barButtonItem;
}
+-(void)scrollViewDidScroll:(UIScrollView *)scrollView_ {
+ CGFloat actualPosition = scrollView_.contentOffset.y;
+ CGFloat contentHeight = scrollView_.contentSize.height - scrollView_.contentSize.height / 2;
+ if (actualPosition >= contentHeight && !self.dataLoading) {
+ NSNumber *lastMid = ((Message *)[self.messages lastObject]).MID;
+ if (![self.path isEqualToString:[Message threadUrl]]) {
+ [self.params setValue:lastMid forKey:@"before_mid"];
+ }
+ [self refreshData];
+ }
+}
+
@end
diff --git a/Juick/RevealPanelViewController.h b/Juick/RevealPanelViewController.h
index 0300274..ff5006c 100644
--- a/Juick/RevealPanelViewController.h
+++ b/Juick/RevealPanelViewController.h
@@ -9,7 +9,6 @@
#import <UIKit/UIKit.h>
#import <FAImageView.h>
#import "LoginViewController.h"
-#import <SDWebImage/UIImageView+WebCache.h>
@interface RevealPanelViewController : UIViewController<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) IBOutlet UITableView *tableView;
diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m
index 8759e63..65565a8 100644
--- a/Juick/Views/MessageCell.m
+++ b/Juick/Views/MessageCell.m
@@ -23,7 +23,7 @@
- (void) setMessage:(Message *)msg {
_message = msg;
- [self.avatar setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/a/%d.png", [msg.userID intValue]]] placeholderImage:[UIImage imageNamed:@"0.png"] options:SDWebImageContinueInBackground];
+ [self.avatar df_setImageWithResource:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/a/%d.png", [msg.userID intValue]]]];
self.title.text = msg.user;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";