Steven 2 months ago
parent
commit
a12807a81d

+ 1 - 9
KulexiuForTeacher/KulexiuForTeacher/Common/Base/WebView/KSBaseWKWebViewController.m

@@ -890,19 +890,11 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
     }];
 }
 
-- (void)removeLoadHud {
-    [LOADING_MANAGER removeCustomLoading];
-}
-
 - (void)videCropImage:(UIImage *)cover content:(NSDictionary *)content {
     NSData *imgData = [UIImage turnsImaegDataByImage:cover];
     NSString *fileName = @"videoCoverImage";
     
-    [LOADING_MANAGER showCancelCustomLoading:@"上传中..." cancel:^{
-        [UPLOAD_MANAGER cancelUploadCallback:^{
-            [self removeLoadHud];
-        }];
-    }];
+    [LOADING_MANAGER showCustomLoading:@"上传中..."];
     [UPLOAD_MANAGER configWithfilePath:@"/user/"];
     [UPLOAD_MANAGER uploadFile:imgData fileName:fileName fileSuffix:[UIImage typeForImageData:imgData] progress:^(int64_t bytesWritten, int64_t totalBytes) {
         // 显示进度

+ 22 - 4
KulexiuForTeacher/KulexiuForTeacher/Common/Tools/Custom/KSMediaManager.m

@@ -27,6 +27,8 @@
 
 @property (nonatomic, strong) NSString *presentName;
 
+@property (nonatomic, assign) BOOL isAborted;
+
 @end
 
 @implementation KSMediaManager
@@ -196,7 +198,10 @@
 //
 //        NSLog(@"原视频大小:%@",[NSString stringWithFormat:@"%.2fM",(CGFloat)size/(1024*1024)]);
         dispatch_main_sync_safe(^{
-            [LOADING_MANAGER showCustomLoading:@"上传中..."];
+            self.isAborted = NO;
+            [LOADING_MANAGER showCancelCustomLoading:@"上传中..." cancel:^{
+                [self cacelCurrentTask];
+            }];
         });
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
             
@@ -207,7 +212,7 @@
                 NSLog(@"导出后的视频:%@",[NSString stringWithFormat:@"%.2fM",(CGFloat)outputData.length/(1024*1024)]);
                 // Export completed, send video here, send by outputPath or NSData
                 // 导出完成,在这里写上传代码,通过路径或者通过NSData上传
-                if (self.callback) {
+                if (self.callback && self.isAborted == NO) {
                     dispatch_main_sync_safe(^{
                         self.callback(outputPath, self.imageArray, self.imageAsset);
                     });
@@ -361,7 +366,10 @@
                 [tzImagePickerVc hideProgressHUD];
                 if (!error) {
                     dispatch_main_async_safe(^{
-                        [LOADING_MANAGER showCustomLoading:@"上传中..."];
+                        self.isAborted = NO;
+                        [LOADING_MANAGER showCancelCustomLoading:@"上传中..." cancel:^{
+                            [self cacelCurrentTask];
+                        }];
                     });
                     [[TZImageManager manager] getVideoOutputPathWithAsset:asset presetName:self.presentName success:^(NSString *outputPath) {
                         // NSData *data = [NSData dataWithContentsOfFile:outputPath];
@@ -373,7 +381,7 @@
                         NSLog(@"导出后的视频:%@",[NSString stringWithFormat:@"%.2fM",(CGFloat)outputData.length/(1024*1024)]);
                         // Export completed, send video here, send by outputPath or NSData
                         // 导出完成,在这里写上传代码,通过路径或者通过NSData上传
-                        if (self.callback) {
+                        if (self.callback && self.isAborted == NO) {
                             self.callback(outputPath, self.imageArray, self.imageAsset);
                         }
                         
@@ -447,4 +455,14 @@
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
 }
 
+- (void)cacelCurrentTask {
+    self.isAborted = YES;
+    [UPLOAD_MANAGER cancelUploadCallback:^{
+        [self removeLoadHud];
+    }];
+}
+
+- (void)removeLoadHud {
+    [LOADING_MANAGER removeCustomLoading];
+}
 @end

+ 2 - 2
KulexiuForTeacher/KulexiuForTeacher/Module/Mine/CreateStyle/Controller/MyStyleViewController.m

@@ -129,9 +129,9 @@
 }
 
 - (void)requestMyStyleRefreshTimeFlag:(BOOL)refreshTimeFlag {
-    [LOADING_MANAGER showCustomLoading:@"加载中..."];
+    
     [KSNetworkingManager queryTeacherStyleRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
-        [LOADING_MANAGER removeCustomLoading];
+        
         if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
             NSDictionary *result = [dic ks_dictionaryValueForKey:@"data"];
             NSString *subjectIds = [result ks_stringValueForKey:@"subjectId"];