|
24 | 24 | #import "QBImagePickerController.h" |
25 | 25 | #import "Helper.h" |
26 | 26 | #import "FileListUploadCell.h" |
| 27 | +#import "Coding_FileManager.h" |
27 | 28 |
|
28 | 29 |
|
29 | | -@interface FileListViewController () <SWTableViewCellDelegate, EaseToolBarDelegate, QBImagePickerControllerDelegate> |
| 30 | +@interface FileListViewController () <SWTableViewCellDelegate, EaseToolBarDelegate, QBImagePickerControllerDelegate, Coding_FileManagerDelegate> |
30 | 31 | @property (nonatomic, strong) UITableView *myTableView; |
31 | 32 | @property (nonatomic, strong) ODRefreshControl *refreshControl; |
32 | 33 | @property (strong, nonatomic) ProjectFiles *myFiles; |
@@ -86,6 +87,8 @@ - (void)loadView{ |
86 | 87 |
|
87 | 88 | _refreshControl = [[ODRefreshControl alloc] initInScrollView:self.myTableView]; |
88 | 89 | [_refreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged]; |
| 90 | + |
| 91 | + [Coding_FileManager sharedManager].delegate = self; |
89 | 92 | if (!self.rootFolders) { |
90 | 93 | self.rootFolders = [ProjectFolders emptyFolders]; |
91 | 94 | } |
@@ -267,35 +270,35 @@ - (void)qb_imagePickerControllerDidCancel:(QBImagePickerController *)imagePicker |
267 | 270 |
|
268 | 271 | #pragma mark uploadTask |
269 | 272 | - (void)addUploadTaskWithFileName:(NSString *)fileName{ |
270 | | - __weak typeof(self) weakSelf = self; |
271 | | - |
272 | 273 | Coding_FileManager *manager = [Coding_FileManager sharedManager]; |
273 | | - [manager addUploadTaskWithFileName:fileName completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { |
274 | | - if (error) { |
275 | | - [weakSelf showError:error]; |
276 | | - }else{ |
277 | | - ProjectFile *curFile = responseObject; |
278 | | - if (curFile.name && curFile.name.length > 0) { |
279 | | - curFile.project_id = weakSelf.curProject.id; |
280 | | - [weakSelf.myFiles.list insertObject:curFile atIndex:0]; |
281 | | - } |
282 | | - } |
283 | | - [weakSelf configuploadFiles]; |
284 | | - }]; |
285 | | - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
286 | | - [self configuploadFiles]; |
287 | | - }); |
| 274 | + [manager addUploadTaskWithFileName:fileName]; |
| 275 | + [self configuploadFiles]; |
288 | 276 | } |
289 | 277 |
|
290 | 278 | - (void)removeUploadTaskWithFileName:(NSString *)fileName{ |
291 | 279 | Coding_FileManager *manager = [Coding_FileManager sharedManager]; |
292 | 280 | [manager removeCUploadTaskForFile:fileName hasError:NO]; |
293 | | - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
294 | | - [self configuploadFiles]; |
295 | | - }); |
| 281 | + [self configuploadFiles]; |
296 | 282 | } |
297 | 283 |
|
| 284 | +- (void)completionUploadWithResult:(id)responseObject error:(NSError *)error{ |
| 285 | + if (error) { |
| 286 | + [self showError:error]; |
| 287 | + }else{ |
| 288 | + ProjectFile *curFile = responseObject; |
| 289 | + if (curFile.name && curFile.name.length > 0) { |
| 290 | + curFile.project_id = self.curProject.id; |
| 291 | + [self.myFiles.list insertObject:curFile atIndex:0]; |
| 292 | + self.curFolder.count = @(self.curFolder.count.integerValue +1); |
| 293 | + } |
| 294 | + } |
| 295 | + [self configuploadFiles]; |
| 296 | +} |
298 | 297 |
|
| 298 | +#pragma mark Coding_FileManagerDelegate |
| 299 | +- (void)completionUploadResponse:(NSURLResponse *)response withResponseObject:(id)responseObject andError:(NSError *)error{ |
| 300 | + [self completionUploadWithResult:responseObject error:error]; |
| 301 | +} |
299 | 302 |
|
300 | 303 | #pragma mark Table M |
301 | 304 | - (NSInteger)totalDataRow{ |
|
0 commit comments