فهرست منبع

1.修改RA Image iOS上传参数检查提示和WiFi检查提示顺序。

Pen Li 8 سال پیش
والد
کامیت
2595983d03

BIN
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 54 - 42
RA Image/RA Image/BasicModeViewController.m

@@ -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;

+ 5 - 4
RA Image/RA Image/ModelModeViewController.m

@@ -97,10 +97,6 @@
 
 - (IBAction)uploadBtnClick:(id)sender {
     
-    if (![self shouldUploadWithCurrentNerworkStatus]) {
-        [self.view makeToast:@"Current network is not WiFi,we don't upload until wifi connected." duration:3.0 position:CSToastPositionCenter];
-//        return;
-    }
     
     if(self.barcode.length ==0)
     {
@@ -116,6 +112,7 @@
         [RAUtils message_alert:@"Manufacturer does not set." title:@"Warning" controller:self];
         return;
     }
+
     
     AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
     
@@ -148,6 +145,10 @@
 }
 -(void) addTasks
 {
+    if (![self shouldUploadWithCurrentNerworkStatus]) {
+        [self.view makeToast:@"Current network is not WiFi,you can upload it manually when wifi connected." duration:3.0 position:CSToastPositionCenter];
+    }
+    
     AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
     
     NSString *manufacturer = self.manufacturer;

+ 6 - 5
RA Image/RA Image/PopModeViewController.m

@@ -69,10 +69,7 @@
 
 - (IBAction)uploadBtnClick:(UIButton *)sender {
     
-    if (![self shouldUploadWithCurrentNerworkStatus]) {
-        [self.view makeToast:@"Current network is not WiFi,we don't upload until wifi connected." duration:3.0 position:CSToastPositionCenter];
-//        return;
-    }
+
     
     // check piid, photo...
     if(self.barcode.length ==0)
@@ -86,6 +83,8 @@
         return;
     }
     
+
+    
     
         AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
     NSString* encryptu=[AESCrypt AES128Encrypt:Appdelegate.user key:@"usai"];
@@ -109,7 +108,9 @@
     
     AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
     
-    
+    if (![self shouldUploadWithCurrentNerworkStatus]) {
+        [self.view makeToast:@"Current network is not WiFi,you can upload it manually when wifi connected." duration:3.0 position:CSToastPositionCenter];
+    }
     
     //prepare upload
     NSMutableArray* tasks = [NSMutableArray new];