Authored by Fabrice Aneche

reformat a long method call

@@ -124,32 +124,35 @@ static NSString *const kCompletedCallbackKey = @"completed"; @@ -124,32 +124,35 @@ static NSString *const kCompletedCallbackKey = @"completed";
124 else { 124 else {
125 request.allHTTPHeaderFields = wself.HTTPHeaders; 125 request.allHTTPHeaderFields = wself.HTTPHeaders;
126 } 126 }
127 - operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request options:options progress:^(NSInteger receivedSize, NSInteger expectedSize) {  
128 - if (!wself) return;  
129 - SDWebImageDownloader *sself = wself;  
130 - NSArray *callbacksForURL = [sself callbacksForURL:url];  
131 - for (NSDictionary *callbacks in callbacksForURL) {  
132 - SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];  
133 - if (callback) callback(receivedSize, expectedSize);  
134 - }  
135 - }  
136 - completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {  
137 - if (!wself) return;  
138 - SDWebImageDownloader *sself = wself;  
139 - NSArray *callbacksForURL = [sself callbacksForURL:url];  
140 - if (finished) {  
141 - [sself removeCallbacksForURL:url];  
142 - }  
143 - for (NSDictionary *callbacks in callbacksForURL) {  
144 - SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey];  
145 - if (callback) callback(image, data, error, finished);  
146 - }  
147 - }  
148 - cancelled:^{  
149 - if (!wself) return;  
150 - SDWebImageDownloader *sself = wself;  
151 - [sself removeCallbacksForURL:url];  
152 - }]; 127 + operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request
  128 + options:options
  129 + progress:^(NSInteger receivedSize, NSInteger expectedSize) {
  130 + if (!wself) return;
  131 + SDWebImageDownloader *sself = wself;
  132 + NSArray *callbacksForURL = [sself callbacksForURL:url];
  133 + for (NSDictionary *callbacks in callbacksForURL) {
  134 + SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
  135 + if (callback) callback(receivedSize, expectedSize);
  136 + }
  137 + }
  138 + completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
  139 + if (!wself) return;
  140 + SDWebImageDownloader *sself = wself;
  141 + NSArray *callbacksForURL = [sself callbacksForURL:url];
  142 + if (finished) {
  143 + [sself removeCallbacksForURL:url];
  144 + }
  145 + for (NSDictionary *callbacks in callbacksForURL) {
  146 + SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey];
  147 + if (callback) callback(image, data, error, finished);
  148 + }
  149 + }
  150 + cancelled:^{
  151 + if (!wself) return;
  152 + SDWebImageDownloader *sself = wself;
  153 + [sself removeCallbacksForURL:url];
  154 + }];
  155 +
153 [wself.downloadQueue addOperation:operation]; 156 [wself.downloadQueue addOperation:operation];
154 if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) { 157 if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) {
155 // Emulate LIFO execution order by systematically adding new operations as last operation's dependency 158 // Emulate LIFO execution order by systematically adding new operations as last operation's dependency