Просмотр исходного кода

RA Image
修复批量操作后重复创新的问题。
修复上传列表clear后的刷新问题

Ray Zhang 9 лет назад
Родитель
Сommit
f58cc564c7

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


+ 44 - 7
RA Image/RA Image/UploadViewController.m

@@ -115,19 +115,29 @@
 {
 {
     AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
     AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
     
     
-    DebugLog(@"cellForRowAtIndexPath %ld",indexPath.row);
+
     
     
     
     
     {
     {
         NSString *CellIdentifier = @"UploadCell";
         NSString *CellIdentifier = @"UploadCell";
         UploadCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
         UploadCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
         
         
+        
+        
         NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
         NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
 //        
 //        
 //        if (cell.operation) {
 //        if (cell.operation) {
 //            cell.operation.updateUI = nil;
 //            cell.operation.updateUI = nil;
 //        }
 //        }
         
         
+//<<<<<<< .mine
+//        DebugLog(@"cellForRowAtIndexPath %ld %p",indexPath.row,cell);
+//        DebugLog(@"item_json %@",item_json);
+        RAUploadOperation* op = item_json[@"operation"];
+//
+//        
+//=======
+//>>>>>>> .r32582
         NSString* status =nil;
         NSString* status =nil;
         switch ([item_json[@"status"] intValue]) {
         switch ([item_json[@"status"] intValue]) {
             case TaskStatusStart:
             case TaskStatusStart:
@@ -159,13 +169,22 @@
         
         
         
         
         
         
-        RAUploadOperation* op = item_json[@"operation"];
         
         
+//<<<<<<< .mine
+//        
 //        __block RAUploadOperation* block_op = op;
 //        __block RAUploadOperation* block_op = op;
 //        __block UploadCell* block_cell = cell;
 //        __block UploadCell* block_cell = cell;
 //        __block NSIndexPath* block_index = indexPath;
 //        __block NSIndexPath* block_index = indexPath;
 //        long idx = indexPath.row;
 //        long idx = indexPath.row;
 //        __weak typeof(self) weakself = self;
 //        __weak typeof(self) weakself = self;
+//=======
+//        __block RAUploadOperation* block_op = op;
+//        __block UploadCell* block_cell = cell;
+//        __block NSIndexPath* block_index = indexPath;
+//        long idx = indexPath.row;
+//        __weak typeof(self) weakself = self;
+//>>>>>>> .r32582
+//        DebugLog(@"OPERATION %p SET UPDATEUI",op);
         op.updateUI=^(){
         op.updateUI=^(){
             
             
             
             
@@ -312,6 +331,15 @@
 //    
 //    
 //}
 //}
 //
 //
+//<<<<<<< .mine
+//- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
+//    UploadCell *upCell = (UploadCell *)cell;
+////    upCell.name = nil;
+////    upCell.progress = 0;
+////    upCell.state = nil;
+////    upCell.errorMsg = nil;
+////    
+//=======
 - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
 - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
     UploadCell *upCell = (UploadCell *)cell;
     UploadCell *upCell = (UploadCell *)cell;
     upCell.name = nil;
     upCell.name = nil;
@@ -321,14 +349,23 @@
     if (upCell.operation) {
     if (upCell.operation) {
         upCell.operation.updateUI = nil;
         upCell.operation.updateUI = nil;
     }
     }
-//    AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
-//    if (indexPath.row < Appdelegate.uploadManager.arr_queue.count) {// Clear List先调用此方法,再调用numberOfRowsInSection,所以先判断避免Crash
-//        NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
-//        RAUploadOperation* op = item_json[@"operation"];
-//        op.updateUI = nil;
+//>>>>>>> .r32582
+////    AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
+////    if (indexPath.row < Appdelegate.uploadManager.arr_queue.count) {// Clear List先调用此方法,再调用numberOfRowsInSection,所以先判断避免Crash
+////        NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
+////        RAUploadOperation* op = item_json[@"operation"];
+////        op.updateUI = nil;
+////    }
+//<<<<<<< .mine
+//    if (upCell.operation) {
+//        upCell.operation.updateUI = nil;
+//        DebugLog(@"OPERATION %p SET UPDATEUI",upCell.operation);
 //    }
 //    }
+//}
+//=======
     
     
 }
 }
+//>>>>>>> .r32582
 /*
 /*
 #pragma mark - UploadManager Delegate
 #pragma mark - UploadManager Delegate
 
 

+ 13 - 10
common/upload/RAUploadOperation.m

@@ -80,7 +80,7 @@
 //    return;
 //    return;
 
 
     
     
-    __weak typeof(self) weakSelf = self;
+    __weak typeof(self) weakself = self;
     
     
     
     
     __block NSMutableDictionary* block_task = _taskinfo;
     __block NSMutableDictionary* block_task = _taskinfo;
@@ -99,7 +99,7 @@
     }
     }
     
     
     [NetworkUtils upload:[self filePath:_taskinfo ]  Params:_taskinfo[@"params"] ToHost:_taskinfo[@"url"] Result:^(NSMutableDictionary *result) {
     [NetworkUtils upload:[self filePath:_taskinfo ]  Params:_taskinfo[@"params"] ToHost:_taskinfo[@"url"] Result:^(NSMutableDictionary *result) {
-        DebugLog(@"upload result: %@",result);
+        blockDebugLog(@"upload result: %@",result);
         int r=[result[@"result"] intValue];
         int r=[result[@"result"] intValue];
         if(r==2|| r==RESULT_BARCODE_ERROR)
         if(r==2|| r==RESULT_BARCODE_ERROR)
         {
         {
@@ -127,7 +127,7 @@
                 block_task[@"msg"]=result[@"connection lost, retry..."];
                 block_task[@"msg"]=result[@"connection lost, retry..."];
                 
                 
                 RAUploadOperation* operation = [[RAUploadOperation alloc] initWithTaskinfo:block_task retry:_maxRetry];
                 RAUploadOperation* operation = [[RAUploadOperation alloc] initWithTaskinfo:block_task retry:_maxRetry];
-                operation.updateUI= self.updateUI;
+                operation.updateUI= weakself.updateUI;
                 block_task[@"operation"] = operation;
                 block_task[@"operation"] = operation;
                 [Appdelegate.uploadManager.operation_queue addOperation:operation];
                 [Appdelegate.uploadManager.operation_queue addOperation:operation];
              //   [self upload:url];
              //   [self upload:url];
@@ -136,12 +136,12 @@
         
         
         dispatch_async(dispatch_get_main_queue(), ^{
         dispatch_async(dispatch_get_main_queue(), ^{
 
 
-            if(self.updateUI)
-                self.updateUI();
+            if(weakself.updateUI)
+                weakself.updateUI();
         });
         });
-        [weakSelf willChangeValueForKey:@"isFinished"];
+        [weakself willChangeValueForKey:@"isFinished"];
         finished = true;
         finished = true;
-        [weakSelf didChangeValueForKey:@"isFinished"];
+        [weakself didChangeValueForKey:@"isFinished"];
 //        [self completeOperation];
 //        [self completeOperation];
         
         
         
         
@@ -150,9 +150,12 @@
         dispatch_async(dispatch_get_main_queue(), ^{
         dispatch_async(dispatch_get_main_queue(), ^{
 //            ((UIProgressView*) block_task[@"ui_pregress"]).progress = progress;
 //            ((UIProgressView*) block_task[@"ui_pregress"]).progress = progress;
             block_task[@"progress"]=[NSNumber numberWithFloat:progress];
             block_task[@"progress"]=[NSNumber numberWithFloat:progress];
-            
-            if(self.updateUI)
-                self.updateUI();
+//            NSLog(@"updateUI progress %p",weakself);
+            if(weakself.updateUI)
+            {
+//                NSLog(@"updateUI progress CALL");
+                weakself.updateUI();
+            }
         });
         });
         
         
     } DecryptHandler:^id(NSString *result) {
     } DecryptHandler:^id(NSString *result) {