Commit 75f1c453 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

Downloads: update stats every 0.5s only

parent 3d9c4731
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
VLCHTTPFileDownloader *_httpDownloader; VLCHTTPFileDownloader *_httpDownloader;
WRRequestDownload *_FTPDownloadRequest; WRRequestDownload *_FTPDownloadRequest;
NSTimeInterval _lastStatsUpdate;
} }
@end @end
...@@ -228,9 +229,12 @@ ...@@ -228,9 +229,12 @@
- (void)progressUpdatedTo:(CGFloat)percentage receivedDataSize:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize - (void)progressUpdatedTo:(CGFloat)percentage receivedDataSize:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize
{ {
if ((_lastStatsUpdate > 0 && ([NSDate timeIntervalSinceReferenceDate] - _lastStatsUpdate > .5)) || _lastStatsUpdate <= 0) {
[self.progressPercent setText:[NSString stringWithFormat:@"%.1f%%", percentage*100]]; [self.progressPercent setText:[NSString stringWithFormat:@"%.1f%%", percentage*100]];
[self.timeDL setText:[self calculateRemainingTime:receivedDataSize expectedDownloadSize:expectedDownloadSize]]; [self.timeDL setText:[self calculateRemainingTime:receivedDataSize expectedDownloadSize:expectedDownloadSize]];
[self.speedRate setText:[self calculateSpeedString:receivedDataSize]]; [self.speedRate setText:[self calculateSpeedString:receivedDataSize]];
_lastStatsUpdate = [NSDate timeIntervalSinceReferenceDate];
}
[self.progressView setProgress:percentage animated:YES]; [self.progressView setProgress:percentage animated:YES];
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment