From b4fb940cbcf9288a6ee6fd460e666f4ac4023f08 Mon Sep 17 00:00:00 2001 From: Matej Bukovinski Date: Mon, 10 Dec 2012 12:40:05 +0100 Subject: [PATCH 1/3] Send out progress callbacks sooner. - as soon as the NSURLConnection gets initialized - helps to allocate and show progress indication sooner and prevent large delays without progress indication (for example when the server takes long to respond) - estimated size is always 0 at this point, clients can use this to decide if they want to handle this callback or skip it --- SDWebImage/SDWebImageDownloaderOperation.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index f12ba1be..65f9af24 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -71,6 +71,10 @@ if (self.connection) { + if (self.progressBlock) + { + self.progressBlock(0, 0); + } [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; } else From 85759911b7f6bf6413d5cbb58a3687fe867204aa Mon Sep 17 00:00:00 2001 From: Matej Bukovinski Date: Thu, 13 Dec 2012 23:39:40 +0100 Subject: [PATCH 2/3] Changed the expected size to -1 in the initial progress callback. - simplifies callback code by removing possible division by 0 issues during progress computation --- SDWebImage/SDWebImageDownloaderOperation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index 65f9af24..52f7af9c 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -73,7 +73,7 @@ { if (self.progressBlock) { - self.progressBlock(0, 0); + self.progressBlock(0, -1); } [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; } From 7ba77023c7fb96b732e8d2dbbc26c1437c4be124 Mon Sep 17 00:00:00 2001 From: Matej Bukovinski Date: Thu, 13 Dec 2012 23:45:10 +0100 Subject: [PATCH 3/3] Using spaces instead of tabs for indentation. - also configured the Xcode project to use spaces instead of tabs by default --- SDWebImage.xcodeproj/project.pbxproj | 1 + SDWebImage/SDWebImageDownloaderOperation.m | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SDWebImage.xcodeproj/project.pbxproj b/SDWebImage.xcodeproj/project.pbxproj index acb9a3a4..e37a5852 100644 --- a/SDWebImage.xcodeproj/project.pbxproj +++ b/SDWebImage.xcodeproj/project.pbxproj @@ -140,6 +140,7 @@ 53922D70148C55820056699D /* Products */, ); sourceTree = ""; + usesTabs = 0; }; 53922D70148C55820056699D /* Products */ = { isa = PBXGroup; diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index 52f7af9c..df8db73c 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -71,10 +71,10 @@ if (self.connection) { - if (self.progressBlock) - { - self.progressBlock(0, -1); - } + if (self.progressBlock) + { + self.progressBlock(0, -1); + } [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; } else