...
|
...
|
@@ -19,7 +19,7 @@ |
|
|
|
|
|
@property (assign, nonatomic, getter = isExecuting) BOOL executing;
|
|
|
@property (assign, nonatomic, getter = isFinished) BOOL finished;
|
|
|
@property (assign, nonatomic) NSUInteger expectedSize;
|
|
|
@property (assign, nonatomic) NSInteger expectedSize;
|
|
|
@property (strong, nonatomic) NSMutableData *imageData;
|
|
|
@property (strong, nonatomic) NSURLConnection *connection;
|
|
|
@property (strong, atomic) NSThread *thread;
|
...
|
...
|
@@ -36,7 +36,7 @@ |
|
|
BOOL responseFromCached;
|
|
|
}
|
|
|
|
|
|
- (id)initWithRequest:(NSURLRequest *)request options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock
|
|
|
- (id)initWithRequest:(NSURLRequest *)request options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSInteger, NSInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock
|
|
|
{
|
|
|
if ((self = [super init]))
|
|
|
{
|
...
|
...
|
@@ -94,7 +94,7 @@ |
|
|
{
|
|
|
if (self.progressBlock)
|
|
|
{
|
|
|
self.progressBlock(0, -1);
|
|
|
self.progressBlock(0, NSURLResponseUnknownLength);
|
|
|
}
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self];
|
|
|
|
...
|
...
|
@@ -208,7 +208,7 @@ |
|
|
{
|
|
|
if (![response respondsToSelector:@selector(statusCode)] || [((NSHTTPURLResponse *)response) statusCode] < 400)
|
|
|
{
|
|
|
NSUInteger expected = response.expectedContentLength > 0 ? (NSUInteger)response.expectedContentLength : 0;
|
|
|
NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0;
|
|
|
self.expectedSize = expected;
|
|
|
if (self.progressBlock)
|
|
|
{
|
...
|
...
|
@@ -242,7 +242,7 @@ |
|
|
// Thanks to the author @Nyx0uf
|
|
|
|
|
|
// Get the total bytes downloaded
|
|
|
const NSUInteger totalSize = self.imageData.length;
|
|
|
const NSInteger totalSize = self.imageData.length;
|
|
|
|
|
|
// Update the data source, we must pass ALL the data, not just the new bytes
|
|
|
CGImageSourceRef imageSource = CGImageSourceCreateIncremental(NULL);
|
...
|
...
|
|