浏览代码

HTTP File Downloader: minor cleanup

Felix Paul Kühne 12 年之前
父节点
当前提交
a3789054ce
共有 1 个文件被更改,包括 10 次插入7 次删除
  1. 10 7
      AspenProject/VLCHTTPFileDownloader.m

+ 10 - 7
AspenProject/VLCHTTPFileDownloader.m

@@ -95,24 +95,19 @@
 
 -(void)connectionDidFinishLoading:(NSURLConnection *)connection {
     APLog(@"http file download complete");
-    _downloadInProgress = NO;
-    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
-
     VLCAppDelegate * appDelegate = [UIApplication sharedApplication].delegate;
     [appDelegate updateMediaList];
 
-    [self.delegate downloadEnded];
+    [self _downloadEnded];
 }
 
 -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
     APLog(@"http file download failed (%i)", error.code);
-    _downloadInProgress = NO;
-    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
 
     if ([self.delegate respondsToSelector:@selector(downloadFailedWithErrorDescription:)])
         [self.delegate downloadFailedWithErrorDescription:error.description];
 
-    [self.delegate downloadEnded];
+    [self _downloadEnded];
 }
 
 - (void)cancelDownload
@@ -121,6 +116,14 @@
     if ([self.delegate respondsToSelector:@selector(downloadFailedWithErrorDescription:)])
         [self.delegate downloadFailedWithErrorDescription:@"Download canceled by user"];
 
+    [self _downloadEnded];
+}
+
+- (void)_downloadEnded
+{
+    _downloadInProgress = NO;
+    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
+
     [self.delegate downloadEnded];
 }