Browse Source

RA Image
修改提示消息,去掉 error failed

Ray Zhang 9 năm trước cách đây
mục cha
commit
5459eed82a

BIN
Ants Contract/AntsContract.xcworkspace/xcuserdata/Ray.xcuserdatad/UserInterfaceState.xcuserstate


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


+ 2 - 2
RA Image/RA Image/BasicModeViewController.m

@@ -443,7 +443,7 @@
                             [weakself.photos insertObject:photoDic atIndex:0];
                             weakself.photoCount++;
                         } else {
-                            [RAUtils message_alert:@"Save photo failed" title:@"Warning" controller:weakPreVC];
+                            [RAUtils message_alert:@"Save photo failed, storage full?" title:@"Warning" controller:weakPreVC];
                         }
                     });
                     
@@ -473,7 +473,7 @@
                     [self.photos insertObject:photoDic atIndex:0];
                     self.photoCount++;
                 } else {
-                    [RAUtils message_alert:@"Save photo failed" title:@"Warning" controller:self];
+                    [RAUtils message_alert:@"Save photo failed, storage full?" title:@"Warning" controller:self];
                 }
             });
             

+ 3 - 0
RA Image/RA Image/UploadCell.m

@@ -7,6 +7,7 @@
 //
 
 #import "UploadCell.h"
+#import "const.h"
 
 @interface UploadCell ()
 
@@ -38,6 +39,8 @@
 }
 
 - (void)setProgress:(float)progress {
+    
+    DebugLog(@"cell %p setProgress %f",self,progress);
     if (progress < 0) {
         progress = 0.0f;
     }

+ 18 - 5
RA Image/RA Image/UploadViewController.m

@@ -51,11 +51,12 @@
     
     
     UIAlertAction *OK = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
-               NSMutableArray* arr_tasks =[NSMutableArray new];
+        
+        NSMutableArray* arr_tasks =[NSMutableArray new];
         for(NSMutableDictionary* task in appdelegate.uploadManager.arr_queue)
         {
             if([task[@"status"] intValue]==TaskStatusFinish||[task[@"status"] intValue]==TaskStatusError)
-               [arr_tasks addObject:task];
+                [arr_tasks addObject:task];
         }
         [appdelegate.uploadManager removeTasks:arr_tasks];
         
@@ -86,9 +87,9 @@
         //        NSArray* arr2 = [change objectForKey:NSKeyValueChangeNewKey];
         //        if(arr1.count!=arr2.count)
         
-        
+        __weak typeof(self) weakself = self;
         dispatch_async(dispatch_get_main_queue(), ^{
-            
+            blockDebugLog(@"arr_queue changed reload tableview");
             [self.tableView reloadData];
         });
         
@@ -114,12 +115,13 @@
 {
     AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
     
-    
+    DebugLog(@"cellForRowAtIndexPath %ld",indexPath.row);
     
     
     {
         NSString *CellIdentifier = @"UploadCell";
         UploadCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
+        
         NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
         
         if (cell.operation) {
@@ -155,9 +157,20 @@
         cell.state=  status;
         cell.errorMsg = item_json[@"msg"];
         
+        
+        
         RAUploadOperation* op = item_json[@"operation"];
+        
+        __block RAUploadOperation* block_op = op;
+        __block UploadCell* block_cell = cell;
+        __block NSIndexPath* block_index = indexPath;
+        long idx = indexPath.row;
+        __weak typeof(self) weakself = self;
         op.updateUI=^(){
             
+            
+            blockDebugLog(@"updateUI @ row%ld %p \n operation %p",idx,block_cell,block_op);
+            
             NSString* status =nil;
             switch ([item_json[@"status"] intValue]) {
                 case TaskStatusStart:

+ 7 - 0
RedAnt ERP Mobile/common/const.h

@@ -10,11 +10,18 @@
     #ifdef DEBUG
    //     #define DebugLog( s, ... ) fprintf(stderr,"%s\n",[[NSString stringWithFormat:s, ##__VA_ARGS__] UTF8String])//
 #define DebugLog( s, ... ) fprintf(stderr, "<%p %s:(%d)> %s \n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent]UTF8String], __LINE__, [[NSString stringWithFormat:(s), ##__VA_ARGS__]UTF8String] )
+
+#define blockDebugLog( s, ... ) fprintf(stderr, "<%p %s:(%d)> %s \n",weakself, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent]UTF8String], __LINE__, [[NSString stringWithFormat:(s), ##__VA_ARGS__]UTF8String] )
+
     #else
         #define DebugLog( s, ... )
+
+        #define blockDebugLog( s, ... )
     #endif
 #else
     #define DebugLog( s, ... )
+
+    #define blockDebugLog( s, ... )
 #endif
 
 

+ 26 - 3
common/upload/RAUploadManager.m

@@ -43,7 +43,7 @@
        
 
         self.newtaskStatus = TaskStatusWait;
-        self.maxThread = 3;
+        self.maxThread = 1;
 //        self.autoStart = true;
 //        self.removeError=true;
 //        self.removeFinish = true;
@@ -180,7 +180,11 @@
 //    [self.arr_queue_lock unlock];
     
     @synchronized(self) {
-        [[self mutableArrayValueForKey:@"arr_queue"] addObjectsFromArray:tasks];
+//        [[self mutableArrayValueForKey:@"arr_queue"] addObjectsFromArray:tasks];
+        
+        
+        NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self mutableArrayValueForKey:@"arr_queue"].count,tasks.count )];
+        [[self mutableArrayValueForKey:@"arr_queue"] insertObjects:tasks atIndexes:indexSet];
     }
     
     if(self.newtaskStatus==TaskStatusWait)
@@ -213,7 +217,26 @@
 //    [self.arr_queue_lock unlock];
     
     @synchronized(self) {
-        [[self mutableArrayValueForKey:@"arr_queue"] removeObjectsInArray:tasks];
+//        [[self mutableArrayValueForKey:@"arr_queue"] removeObjectsInArray:tasks];
+        
+//        NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self mutableArrayValueForKey:@"arr_queue"].count,tasks.count )];
+        
+        NSIndexSet *indexSet = [self.arr_queue indexesOfObjectsPassingTest:^BOOL(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop)
+                                            {
+                                                return [tasks containsObject:obj];
+                                                //                return [tasks indexOfObject:obj];
+                                            }];
+//        [NSIndexSet new];
+//        for(NSMutableDictionary* task in tasks)
+//        {
+//
+//            [self.arr_queue indexOfObject:task];
+//            indexSet set
+//        }
+        
+        [[self mutableArrayValueForKey:@"arr_queue"] removeObjectsAtIndexes:indexSet];
+//        -removeObjectFrom<Key>AtIndex
+//        [ insertObjects:tasks atIndexes:indexSet];
     }
     
 //    if (self.delegate && [self.delegate respondsToSelector:@selector(uploadManager:didRemoveTasks:)]) {