Browse Source

1.代码优化

huangxiaodong 1 year ago
parent
commit
79485848f6

+ 14 - 20
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileManager/uploadFileManager.m

@@ -110,15 +110,19 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
     
     self.curUploadModelNumbers = indexPathsForSelectedItems.count;
     
+    NSLock *lock = [NSLock new];
+    
+    
     for (TZAssetModel * model in indexPathsForSelectedItems) {
         uploadFileDataModel * curModel = [uploadFileDataModel new];
         curModel.asset = model.asset;
         curModel.localIdentifier = model.asset.localIdentifier;
         
         BOOL isRepeatingTasksType = NO;
+        [lock lock];
         //查询上传任务是否存在
         if(_databaseArr && _databaseArr.count == 3 ){
-            NSMutableArray *uploadingArr = _databaseArr[0];
+            NSMutableArray *uploadingArr = [[NSMutableArray alloc] initWithArray:_databaseArr[0]];
             for (uploadFileDataModel *preModel in uploadingArr) {
                 if([preModel.localIdentifier isEqualToString:curModel.localIdentifier]){
                     isRepeatingTasksType = YES;
@@ -126,6 +130,7 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
                 }
             }
         }
+        [lock unlock];
         
         if(isRepeatingTasksType){
             continue;
@@ -157,23 +162,6 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
                     }
             }];
 
-            //真正的视频数据
-//            PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
-//            options.version = PHVideoRequestOptionsVersionOriginal;
-//            [[PHImageManager defaultManager] requestAVAssetForVideo:curModel.asset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
-//                if ([asset isKindOfClass:[AVURLAsset class]]) {
-//
-//                    AVURLAsset* urlAsset = (AVURLAsset*)asset;
-//                    NSData *videoData = [NSData dataWithContentsOfURL:urlAsset.URL];
-//
-//                    if (videoData) {
-//                        curModel.videoData = videoData;
-//                        [cachesFileManager getFileNameWithContent:curModel.videoData fileName:curModel.filename type:uploadFileTypeVideo];
-//                        curModel.videoData = nil;
-//                    }
-//             }
-//            }];
-
         }
         else{
             curModel.curUploadFileType = uploadFileTypeImage;
@@ -227,11 +215,15 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
     NSMutableArray *curArr = totalArr[0];
     
     //for (int i=0; i<_curUploadModelNumbers; i++)
+    NSLock *lock = [NSLock new];
+    [lock lock];
+    [_fileModelDataArr removeAllObjects];
     for (int i=0; i<curArr.count; i++)
     {
        uploadFileDataModel *bg_mod  = curArr[i];
        [_fileModelDataArr addObject:bg_mod];
-   }
+    }
+    [lock unlock];
     
 //    for (int i=0; i<_fileModelDataArr.count; i++) {
 //       uploadFileDataModel *bg_mod  = _fileModelDataArr[i];
@@ -599,7 +591,9 @@ static uploadFileManager * cur_uploadFileShareInstance = nil;
     BOOL isSuc = false;
     
     BOOL isDelUploadingModel = false;
-    for (uploadFileDataModel *uploadFileDataMod in delArr) {
+    
+    NSMutableArray *curDelArr = [NSMutableArray arrayWithArray:delArr];
+    for (uploadFileDataModel *uploadFileDataMod in curDelArr) {
         
         NSMutableString* where = [[NSMutableString alloc] initWithString:@"where "];
         

+ 6 - 6
创维盒子/双子星云手机/Class/Set/uploadFile/uploadFileRecordViewController.m

@@ -355,12 +355,12 @@
 -(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems
 {
     
-    //[self realGotoUploadFile:indexPathsForSelectedItems];
-    KWeakSelf
-    [[uploadFileManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
-
-        [weakSelf realGotoUploadFile:indexPathsForSelectedItems];
-    }];
+    [self realGotoUploadFile:indexPathsForSelectedItems];
+//    KWeakSelf
+//    [[uploadFileManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
+//
+//        [weakSelf realGotoUploadFile:indexPathsForSelectedItems];
+//    }];
     
 }