| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- //
- // ApexDriverUploadListVC.m
- // Apex And Drivers
- //
- // Created by Jack on 2018/6/6.
- // Copyright © 2018年 USAI. All rights reserved.
- //
- #import "ApexDriverUploadListVC.h"
- #import "ApexDriverUploadCell.h"
- #import "AppDelegate.h"
- @interface ApexDriverUploadListVC ()
- @property (strong, nonatomic) IBOutlet UITableView *tableView;
- @end
- @implementation ApexDriverUploadListVC
- + (NSString *)storyboardID {
- return NSStringFromClass([self class]);
- }
- + (instancetype)viewControllerFromStoryboard {
- ApexDriverUploadListVC *uploadVC = [[UIStoryboard storyboardWithName:@"Upload" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
- return uploadVC;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (UITableView *)uploadTableView {
- return self.tableView;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- ApexDriverUploadCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ApexDriverUploadCell" forIndexPath:indexPath];
-
- AppDelegate* appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
- NSDictionary * item_json = appdelegate.uploadManager.arr_queue[indexPath.row];
-
- RAUploadOperation* op = item_json[@"operation"];
-
-
-
- NSString* status =nil;
- switch ([item_json[@"status"] intValue]) {
- case TaskStatusStart:
- status=@"uploading";
- break;
- case TaskStatusStop:
- status=@"stop";
- break;
- case TaskStatusError:
- status=@"warning";
- break;
- case TaskStatusWait:
- status=@"waiting";
- break;
- case TaskStatusFinish:
- status=@"finish";
- break;
-
- default:
- status=@"warning";
- break;
- }
-
- double progress =[item_json[@"progress"] doubleValue];
- cell.progress = progress;
- cell.orderID = item_json[@"order"];
- cell.action = item_json[@"action"];
- cell.status = status;
- cell.errMsg = item_json[@"msg"];
-
- op.updateUI=^(){
-
- NSString* status =nil;
- switch ([item_json[@"status"] intValue]) {
- case TaskStatusStart:
- status=@"uploading";
- break;
- case TaskStatusStop:
- status=@"stop";
- break;
- case TaskStatusError:
- status=@"warning";
- break;
- case TaskStatusWait:
- status=@"waiting";
- break;
- case TaskStatusFinish:
- status=@"finish";
- break;
-
- default:
- status=@"warning";
- break;
- }
- double progress =[item_json[@"progress"] doubleValue];
- cell.progress = progress;
- cell.orderID = item_json[@"order"];
- cell.action = item_json[@"action"];
- cell.status = status;
- cell.errMsg = item_json[@"msg"];
-
- };
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
-
- ApexDriverUploadCell *upCell = (ApexDriverUploadCell *)cell;
-
- AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
- NSUInteger row = indexPath.row;
- NSUInteger count = Appdelegate.uploadManager.arr_queue.count;
- if (count > row) {
- NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
- RAUploadOperation* operation = item_json[@"operation"];
- ApexDriverUploadCell *newCell = (ApexDriverUploadCell *)[tableView cellForRowAtIndexPath:indexPath];
- if (newCell != upCell) {
- // reload row
- } else {
- operation.updateUI = nil; // restart 会调用就会导致cell不会刷新
- }
- }
- [upCell reset];
- }
- @end
|