Explorar o código

1.修改iOS RAImage上传设置。

Pen Li %!s(int64=7) %!d(string=hai) anos
pai
achega
71d25df051
Modificáronse 1 ficheiros con 61 adicións e 49 borrados
  1. 61 49
      RA Image/RA Image/UploadSettingController.m

+ 61 - 49
RA Image/RA Image/UploadSettingController.m

@@ -29,44 +29,47 @@
     
     UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStylePlain target:self action:@selector(saveItemClick:)];
     self.navigationItem.rightBarButtonItem = saveItem;
-    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-    BOOL autoUpload = YES;
-//    BOOL autoRmFinish = YES;
-//    BOOL autoRmErr = NO;
-    BOOL compress = YES;
-    BOOL onlyWiFi = NO;
-    int retryCount = 5;
-    int retryTimeInterval = 300;
+//    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+//    BOOL autoUpload = YES;
+////    BOOL autoRmFinish = YES;
+////    BOOL autoRmErr = NO;
+//    BOOL compress = YES;
+//    BOOL onlyWiFi = NO;
+//    int retryCount = 5;
+//    int retryTimeInterval = 300;
+//
+//    NSDictionary *param = [self userDefaultsValue:kUploadSetting];
+//    if (param) {
+//        autoUpload = [[param objectForKey:@"auto_upload"] boolValue];
+//        retryCount = [[param objectForKey:@"retry_count"] intValue];
+////        autoRmFinish = [[param objectForKey:@"auto_rm_finish"] boolValue];
+////        autoRmErr = [[param objectForKey:@"auto_rm_error"] boolValue];
+//        compress = [[param objectForKey:@"compress_img"] boolValue];
+//        onlyWiFi = [[param objectForKey:@"only_wifi"] boolValue];
+//        NSNumber *timeInterval = [param objectForKey:@"retry_time_interval"];
+//        if (timeInterval != nil) {
+//            retryTimeInterval = [timeInterval intValue];
+//        }
+//    } else {
+//
+//        autoUpload = appDelegate.uploadManager.autoStart;
+//        retryCount = appDelegate.uploadManager.maxRetry;
+////        autoRmFinish = appDelegate.uploadManager.removeFinish;
+////        autoRmErr = appDelegate.uploadManager.removeError;
+//        compress = appDelegate.compressFile;
+//        onlyWiFi = appDelegate.uploadManager.onlyWiFi;
+//        retryTimeInterval = appDelegate.uploadManager.retryTimeInterval;
+//    }
+    
+    RAUPloadManagerConfigure *configure = [[RAUPloadManagerConfigure alloc] init];
     
-    NSDictionary *param = [self userDefaultsValue:kUploadSetting];
-    if (param) {
-        autoUpload = [[param objectForKey:@"auto_upload"] boolValue];
-        retryCount = [[param objectForKey:@"retry_count"] intValue];
-//        autoRmFinish = [[param objectForKey:@"auto_rm_finish"] boolValue];
-//        autoRmErr = [[param objectForKey:@"auto_rm_error"] boolValue];
-        compress = [[param objectForKey:@"compress_img"] boolValue];
-        onlyWiFi = [[param objectForKey:@"only_wifi"] boolValue];
-        NSNumber *timeInterval = [param objectForKey:@"retry_time_interval"];
-        if (timeInterval != nil) {
-            retryTimeInterval = [timeInterval intValue];
-        }
-    } else {
-        
-        autoUpload = appDelegate.uploadManager.autoStart;
-        retryCount = appDelegate.uploadManager.maxRetry;
-//        autoRmFinish = appDelegate.uploadManager.removeFinish;
-//        autoRmErr = appDelegate.uploadManager.removeError;
-        compress = appDelegate.compressFile;
-        onlyWiFi = appDelegate.uploadManager.onlyWiFi;
-        retryTimeInterval = appDelegate.uploadManager.retryTimeInterval;
-    }
-    self.autoSwitch.on = autoUpload;
+    self.autoSwitch.on = configure.autoUpload;
 //    self.autoRmFinishSwitch.on = autoRmFinish;
 //    self.autoRmErrorSwith.on = autoRmErr;
-    self.retryCountBox.text = [NSString stringWithFormat:@"%d",retryCount];
-    self.compressSwitch.on = compress;
-    self.onlyWiFiSwitch.on = onlyWiFi;
-    self.retryTimeIntervalBox.text = [NSString stringWithFormat:@"%d",retryTimeInterval];
+    self.retryCountBox.text = [NSString stringWithFormat:@"%d",configure.retryCount];
+    self.compressSwitch.on = configure.compressImage;
+    self.onlyWiFiSwitch.on = configure.onlyWIFI;
+    self.retryTimeIntervalBox.text = [NSString stringWithFormat:@"%d",(int)configure.retryTimeIntetval];
     [self registListenKeyboard];
 }
 
@@ -99,25 +102,34 @@
     int retryCount = [self.retryCountBox.text intValue];
     BOOL onlyWiFi = self.onlyWiFiSwitch.isOn;
     int retryTimeInterval = [self.retryTimeIntervalBox.text intValue];
-    NSDictionary *param = @{
-                            @"auto_upload" : @(autoUpload),
-//                            @"auto_rm_finish"   : @(autoRmFinish),
-//                            @"auto_rm_error"    : @(autoRmErr),
-                            @"compress_img"     : @(compress),
-                            @"retry_count" : @(retryCount),
-                            @"only_wifi" : @(onlyWiFi),
-                            @"retry_time_interval" : @(retryTimeInterval)
-                            };
-    [self setUserDefaultsValue:param forKey:kUploadSetting];
+//    NSDictionary *param = @{
+//                            @"auto_upload" : @(autoUpload),
+////                            @"auto_rm_finish"   : @(autoRmFinish),
+////                            @"auto_rm_error"    : @(autoRmErr),
+//                            @"compress_img"     : @(compress),
+//                            @"retry_count" : @(retryCount),
+//                            @"only_wifi" : @(onlyWiFi),
+//                            @"retry_time_interval" : @(retryTimeInterval)
+//                            };
+//    [self setUserDefaultsValue:param forKey:kUploadSetting];
+
+    [RAUploadManager configureUploadManager:^(RAUPloadManagerConfigure *configure) {
+       
+        configure.autoUpload = autoUpload;
+        configure.compressImage = compress;
+        configure.retryCount = retryCount;
+        configure.onlyWIFI = onlyWiFi;
+        configure.retryTimeIntetval = retryTimeInterval;
+    }];
     
     AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-    appDelegate.uploadManager.maxRetry = retryCount;
-    appDelegate.uploadManager.autoStart = autoUpload;
+//    appDelegate.uploadManager.maxRetry = retryCount;
+//    appDelegate.uploadManager.autoStart = autoUpload;
 //    appDelegate.uploadManager.removeFinish = autoRmFinish;
 //    appDelegate.uploadManager.removeError = autoRmErr;
     appDelegate.compressFile = compress;
-    appDelegate.uploadManager.onlyWiFi = onlyWiFi;
-    appDelegate.uploadManager.retryTimeInterval = retryTimeInterval;
+//    appDelegate.uploadManager.onlyWiFi = onlyWiFi;
+//    appDelegate.uploadManager.retryTimeInterval = retryTimeInterval;
     
     [self.navigationController popViewControllerAnimated:YES];
 }