| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- //
- // UploadSettingController.m
- // RA Image
- //
- // Created by Jack on 2017/5/9.
- // Copyright © 2017年 USAI. All rights reserved.
- //
- #import "UploadSettingController.h"
- #import "RAUploadManager.h"
- #import "RASingleton.h"
- @interface UploadSettingController ()<UITextFieldDelegate>
- @property (strong, nonatomic) IBOutlet UISwitch *autoSwitch;
- @property (strong, nonatomic) IBOutlet UITextField *retryCountBox;
- //@property (strong, nonatomic) IBOutlet UISwitch *autoRmFinishSwitch;
- //@property (strong, nonatomic) IBOutlet UISwitch *autoRmErrorSwith;
- @property (strong, nonatomic) IBOutlet UISwitch *compressSwitch;
- @property (strong, nonatomic) IBOutlet UISwitch *onlyWiFiSwitch;
- @property (strong, nonatomic) IBOutlet UITextField *retryTimeIntervalBox;
- @end
- @implementation UploadSettingController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- 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;
- //
- // 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];
-
- self.autoSwitch.on = configure.autoUpload;
- // self.autoRmFinishSwitch.on = autoRmFinish;
- // self.autoRmErrorSwith.on = autoRmErr;
- 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];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark - Action
- - (IBAction)autoSwitchValueChange:(UISwitch *)sender {
-
- }
- - (IBAction)autoRmFinishClick:(UISwitch *)sender {
- }
- - (IBAction)autoRmErrClick:(UISwitch *)sender {
- }
- - (IBAction)compressSwitchClick:(UISwitch *)sender {
-
- }
- - (void)saveItemClick:(UIBarButtonItem *)sender {
- BOOL autoUpload = self.autoSwitch.isOn;
- // BOOL autoRmFinish = self.autoRmFinishSwitch.isOn;
- // BOOL autoRmErr = self.autoRmErrorSwith.isOn;
- BOOL compress = self.compressSwitch.isOn;
- 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];
- [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.removeFinish = autoRmFinish;
- // appDelegate.uploadManager.removeError = autoRmErr;
- RASingleton.sharedInstance.compressFile = compress;
- // appDelegate.uploadManager.onlyWiFi = onlyWiFi;
- // appDelegate.uploadManager.retryTimeInterval = retryTimeInterval;
-
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark - Textfield Delegate
- - (void)textFieldDidBeginEditing:(UITextField *)textField {
- self.currentFirstResponder = textField;
- }
- - (void)textFieldDidEndEditing:(UITextField *)textField {
- self.currentFirstResponder = nil;
- }
- @end
|