summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-08-15 01:24:24 +0300
committerGravatar Vitaly Takmazov2016-08-15 01:24:24 +0300
commit9d2b52bb9ee096c546028bd0257944cade21ab4e (patch)
tree649b4b471884b9fb0ca87ca2f229487b3b38f035
parenta778c55cd848b0d0d452a20e8eaf6a477c068ca3 (diff)
DFImageManager
-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
-rw-r--r--Podfile3
-rw-r--r--Podfile.lock18
6 files changed, 30 insertions, 36 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";
diff --git a/Podfile b/Podfile
index 14ac0e8..0bc7b0c 100644
--- a/Podfile
+++ b/Podfile
@@ -2,13 +2,12 @@
platform :ios, "9.0"
target "Juick" do
- pod 'UIScrollView-InfiniteScroll'
pod 'MWFeedParser'
pod 'TTTAttributedLabel'
pod 'SWRevealViewController'
pod 'PDKeychainBindingsController'
pod 'RestKit', '~> 0.26.0'
- pod 'SDWebImage'
+ pod 'DFImageManager'
pod 'FontAwesome+iOS'
pod 'NSDate+TimeAgo'
pod 'SIAlertView'
diff --git a/Podfile.lock b/Podfile.lock
index 09b8c5b..4903e8e 100644
--- a/Podfile.lock
+++ b/Podfile.lock
@@ -1,5 +1,11 @@
PODS:
- AFNetworking (1.3.4)
+ - DFImageManager (2.0.1):
+ - DFImageManager/Core (= 2.0.1)
+ - DFImageManager/UI (= 2.0.1)
+ - DFImageManager/Core (2.0.1)
+ - DFImageManager/UI (2.0.1):
+ - DFImageManager/Core
- FontAwesome+iOS (0.1.4)
- ISO8601DateFormatterValueTransformer (0.6.1):
- RKValueTransformers (~> 1.1.0)
@@ -34,32 +40,28 @@ PODS:
- RestKit/Support (0.26.0):
- TransitionKit (~> 2.2)
- RKValueTransformers (1.1.3)
- - SDWebImage (3.8.1):
- - SDWebImage/Core (= 3.8.1)
- - SDWebImage/Core (3.8.1)
- SIAlertView (1.3)
- SOCKit (1.1)
- SWRevealViewController (2.3.0)
- TransitionKit (2.2.1)
- TTTAttributedLabel (2.0.0)
- - UIScrollView-InfiniteScroll (0.9.1)
- XLForm (3.2.0)
DEPENDENCIES:
+ - DFImageManager
- FontAwesome+iOS
- MWFeedParser
- NSDate+TimeAgo
- PDKeychainBindingsController
- RestKit (~> 0.26.0)
- - SDWebImage
- SIAlertView
- SWRevealViewController
- TTTAttributedLabel
- - UIScrollView-InfiniteScroll
- XLForm
SPEC CHECKSUMS:
AFNetworking: cf8e418e16f0c9c7e5c3150d019a3c679d015018
+ DFImageManager: c19b62a3e15d89f3532ae6fdb222531ec7e811b1
FontAwesome+iOS: 9070b682a9255ca0fdc34bcfb129ad0ba2b73b87
ISO8601DateFormatterValueTransformer: 52da467d6ec899d6aedda8e48280ac92e8ee97e6
MWFeedParser: 2cf646014c1baf6ad1b08c480b40a08180079247
@@ -67,15 +69,13 @@ SPEC CHECKSUMS:
PDKeychainBindingsController: fa8cb3cf99f2ea9240d61066ed0549f34e2cec3c
RestKit: 112fba5bd1f97598aac0db7981863d5fdc0263a2
RKValueTransformers: e5ed67e3811229b616fe01bddeeafe3bb337b1b9
- SDWebImage: 35f9627a3e44b4f292a8a8ce6a531fa488239b91
SIAlertView: 20c794b55eaf44d888773ea51647cf8907723919
SOCKit: c7376ac262bea9115b8f749358f762522a47d392
SWRevealViewController: 6d3fd97f70112fd7cef9de14df4260eacce4c63a
TransitionKit: 9ceccda4cd0cdc0a05ef85eb235e5a3292c3c250
TTTAttributedLabel: 8cffe8e127e4e82ff3af1e5386d4cd0ad000b656
- UIScrollView-InfiniteScroll: 14e204c50ca4040467e1cbfa141dad7a18919b56
XLForm: 2250b4e96ab8ffa5f3355838c79edd90de451782
-PODFILE CHECKSUM: ae435862624639d3aaa4efde0455ce6631e1b0f7
+PODFILE CHECKSUM: de7137f8c5e20473136582ff4c6b99b9e14b2b81
COCOAPODS: 1.0.1