Explorar o código

HTTP File Downloader: minor cleanup

Felix Paul Kühne %!s(int64=12) %!d(string=hai) anos
pai
achega
a3789054ce
Modificáronse 1 ficheiros con 10 adicións e 7 borrados
  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];
 }