|
|
@@ -78,46 +78,47 @@
|
|
|
|
|
|
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
|
|
{
|
|
|
-
|
|
|
- if([keyPath isEqualToString:@"queue_status"])
|
|
|
- {
|
|
|
- NSString* msg=@"";
|
|
|
- BOOL useToast = NO;
|
|
|
- switch ([[change objectForKey:NSKeyValueChangeNewKey] intValue]) {
|
|
|
- case QueueStatusFinish: {
|
|
|
- msg=@"Upload is complete.";
|
|
|
- [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
|
- useToast = NO;
|
|
|
- }
|
|
|
- break;
|
|
|
- case QueueStatusAdd: {
|
|
|
- msg=@"New tasks added.";
|
|
|
- [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
|
|
|
- useToast = YES;
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case QueueStatusFinishWithError:
|
|
|
- {
|
|
|
- NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
|
|
- NSDictionary* dict=[userDefaults objectForKey:@"UploadSettingKey"];
|
|
|
- if([dict[@"auto_rm_error"] boolValue])
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ if([keyPath isEqualToString:@"queue_status"])
|
|
|
+ {
|
|
|
+ NSString* msg=@"";
|
|
|
+ BOOL useToast = NO;
|
|
|
+ switch ([[change objectForKey:NSKeyValueChangeNewKey] intValue]) {
|
|
|
+ case QueueStatusFinish: {
|
|
|
msg=@"Upload is complete.";
|
|
|
- else
|
|
|
- msg=@"Some of the tasks have not been successfully uploaded.\n Check upload list for detail.";
|
|
|
-
|
|
|
- [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
|
- useToast = NO;
|
|
|
-
|
|
|
-
|
|
|
+ [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
|
+ useToast = NO;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case QueueStatusAdd: {
|
|
|
+ msg=@"New tasks added.";
|
|
|
+ [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
|
|
|
+ useToast = YES;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case QueueStatusFinishWithError:
|
|
|
+ {
|
|
|
+ NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
|
|
+ NSDictionary* dict=[userDefaults objectForKey:@"UploadSettingKey"];
|
|
|
+ if([dict[@"auto_rm_error"] boolValue])
|
|
|
+ msg=@"Upload is complete.";
|
|
|
+ else
|
|
|
+ msg=@"Some of the tasks have not been successfully uploaded.\n Check upload list for detail.";
|
|
|
+
|
|
|
+ [[UIApplication sharedApplication] setIdleTimerDisabled:NO];
|
|
|
+ useToast = NO;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- __weak typeof(self) weakself = self;
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
+
|
|
|
+
|
|
|
if(msg.length>0) {
|
|
|
if (useToast) {
|
|
|
[weakself.view makeToast:msg duration:3.0 position:CSToastPositionCenter];
|
|
|
@@ -130,9 +131,9 @@
|
|
|
[weakself presentViewController:alert animated:YES completion:nil];
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -643,8 +644,19 @@
|
|
|
}
|
|
|
case RESULT_NET_ERROR:
|
|
|
{
|
|
|
- [RAUtils message_alert:@"Can not connect to server,and the photos will upload when the network recover" title:title controller:weakself];
|
|
|
- [self addTasks];
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"Can not connect to server,still upload?" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+ [weakSelf addTasks];
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+
|
|
|
+ }];
|
|
|
+ [alertVC addAction:yesAction];
|
|
|
+ [alertVC addAction:noAction];
|
|
|
+ [self presentViewController:alertVC animated:yesAction completion:nil];
|
|
|
+
|
|
|
}
|
|
|
default:
|
|
|
break;
|