mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-03 22:56:57 +02:00
Fix SYIOS-41 : file uploads (and downloads) should be able to happen in parallel with basic progress meters
This commit is contained in:
@@ -35,14 +35,68 @@
|
||||
|
||||
@implementation OutgoingMessageTableCell
|
||||
|
||||
- (void)dealloc {
|
||||
[self stopAnimating];
|
||||
}
|
||||
|
||||
-(void)startAnimating {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMediaUploadProgressNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUploadProgress:) name:kMediaUploadProgressNotification object:nil];
|
||||
|
||||
self.activityIndicator.hidden = NO;
|
||||
[self.activityIndicator startAnimating];
|
||||
|
||||
[self updateUploadProgressTo:self.message.uploadProgress];
|
||||
}
|
||||
|
||||
-(void)stopAnimating {
|
||||
// remove any pie chart
|
||||
[pieChartView removeFromSuperview];
|
||||
pieChartView = nil;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMediaUploadProgressNotification object:nil];
|
||||
[self.activityIndicator stopAnimating];
|
||||
}
|
||||
|
||||
- (void)onUploadProgress:(NSNotification *)notif {
|
||||
// sanity check
|
||||
if ([notif.object isKindOfClass:[NSString class]]) {
|
||||
NSString* url = notif.object;
|
||||
|
||||
if ([url isEqualToString:self.message.thumbnailURL] || [url isEqualToString:self.message.attachmentURL]) {
|
||||
NSNumber* progressNumber = [notif.userInfo valueForKey:kMediaManagerProgressKey];
|
||||
|
||||
if (progressNumber) {
|
||||
[self updateUploadProgressTo:progressNumber.floatValue];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
- (void) updateUploadProgressTo:(CGFloat)progress {
|
||||
// nothing to display
|
||||
if (progress <= 0) {
|
||||
[pieChartView removeFromSuperview];
|
||||
pieChartView = nil;
|
||||
|
||||
self.activityIndicator.hidden = NO;
|
||||
} else {
|
||||
|
||||
if (!pieChartView) {
|
||||
pieChartView = [[PieChartView alloc] init];
|
||||
pieChartView.frame = self.activityIndicator.frame;
|
||||
pieChartView.progress = 0;
|
||||
pieChartView.progressColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.5];
|
||||
pieChartView.unprogressColor = [UIColor clearColor];
|
||||
|
||||
[self.contentView addSubview:pieChartView];
|
||||
}
|
||||
|
||||
self.message.uploadProgress = progress;
|
||||
self.activityIndicator.hidden = YES;
|
||||
pieChartView.progress = progress;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user