소스 검색

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];
 }