瀏覽代碼

1.修改下载暂停后重新开启 速度不显示问题

huangxiaodong 1 年之前
父節點
當前提交
12858663a4

+ 27 - 59
创维盒子/双子星云手机/Class/Set/uploadFile/receiveView/boxDownloadFileRecordCell.m

@@ -162,7 +162,7 @@
     [_fileSpeedlabel mas_makeConstraints:^(MASConstraintMaker *make) {
         make.right.mas_equalTo(_upLoadStateButton.mas_left).offset(-10);
         make.left.mas_equalTo(_progressBgView.mas_centerX);
-        make.height.mas_equalTo(15);
+//        make.height.mas_equalTo(15);
         make.top.mas_equalTo(_progressBgView.mas_bottom).offset(3);
     }];
     
@@ -217,7 +217,6 @@
 - (void)setCurShareFileDataModel:(ShareFileDataModel *)curShareFileDataModel
 {
   
-    _fileSpeedlabel.hidden = YES;
     _progressBgView.hidden = NO;
     _upLoadStateButton.hidden = NO;
     
@@ -241,6 +240,9 @@
     
     _curShareFileDataModel = curShareFileDataModel;
     
+    if(_curShareFileDataModel.downloadBoxStateType != downloadBoxStateDownloadloading){
+        _fileSpeedlabel.hidden = YES;
+    }
     
     //HLog(@"1111111: %@ %@",curShareFileDataModel.fileUrl,curShareFileDataModel.fileSize);
 
@@ -310,9 +312,6 @@
         [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_suspend"] forState:UIControlStateNormal];
         _fileSpeedlabel.hidden = NO;
         
-        //
-        _fileSpeedlabel.text = @"";
-        
         if(curShareFileDataModel.preTimeInterval <= 0
            || curShareFileDataModel.currentSize == curShareFileDataModel.preDownloadBytes){
             //_fileSpeedlabel.text = @"--";
@@ -351,7 +350,6 @@
     else{
         _upLoadStateButton.hidden = YES;
         _progressBgView.hidden = YES;
-        _fileSpeedlabel.text = @"";
     }
     
     
@@ -483,7 +481,7 @@
        ){
         return;
     }
-    
+    NSString * speedStr = nil;
     //进度设置
     CGRect frame = CGRectMake(0, 0, SCREEN_W - 15*2 - 34*2, 2);
     
@@ -510,9 +508,6 @@
         frame.size.width = 10.0;
     }
     
-//    HLog(@"%f, %f, %f, %f,",frame.origin.x,frame.origin.y,frame.size.width,frame.size.height);
-//    HLog(@"%@",_progressSelectView);
-    
     _progressSelectView.frame = frame;
     //_glayer.frame = frame;
     
@@ -542,22 +537,17 @@
         didUploadStr = [[NSString alloc] initWithFormat:@"%.2fG",didUploadSize_k/1024.0/1024.0];
     }
     
-//    if(curShareFileDataModel.downloadBoxStateType == downloadBoxStateBegin){
-//        [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_wait"] forState:UIControlStateNormal];
-//    }
-//    else 
-        if(curShareFileDataModel.downloadBoxStateType == downloadBoxStateDownloadloading){
-        [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_suspend"] forState:UIControlStateNormal];
-        _fileSpeedlabel.hidden = NO;
-        
-        //
-        _fileSpeedlabel.text = @"";
-        
-        if(curShareFileDataModel.preTimeInterval <= 0
-           || curShareFileDataModel.currentSize == curShareFileDataModel.preDownloadBytes){
-            //_fileSpeedlabel.text = @"--";
-        }
-        else{
+    _fileProgresslabel.text = [[NSString alloc] initWithFormat:@"%@/%@",didUploadStr,totalSizeStr];
+
+    if(curShareFileDataModel.downloadBoxStateType == downloadBoxStateDownloadloading){
+    [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_suspend"] forState:UIControlStateNormal];
+    _fileSpeedlabel.hidden = NO;
+    
+    if(curShareFileDataModel.preTimeInterval <= 0
+       || curShareFileDataModel.currentSize == curShareFileDataModel.preDownloadBytes){
+        //_fileSpeedlabel.text = @"--";
+    }
+    else{
             NSTimeInterval  timers = curShareFileDataModel.curTimeInterval - curShareFileDataModel.preTimeInterval;
             
             if(timers > 0){
@@ -565,7 +555,7 @@
                 
                 long speed= (curShareFileDataModel.currentSize - curShareFileDataModel.preDownloadBytes) / timers;
                 
-                NSString * speedStr = nil;
+                
                 NSInteger speed_k = speed / (1024);
                 if(speed_k < 1024){
                     speedStr = [[NSString alloc] initWithFormat:@"%ldKB/s",speed_k];
@@ -574,43 +564,17 @@
                     speedStr = [[NSString alloc] initWithFormat:@"%.1fMB/s",speed_k/1024.0];
                 }
                 
-                _fileSpeedlabel.text = speedStr;
+                //HLog(@"22211:%@",_fileSpeedlabel.description);
             }
         }
         
         curShareFileDataModel.preTimeInterval = curShareFileDataModel.curTimeInterval;
         curShareFileDataModel.preDownloadBytes = curShareFileDataModel.currentSize;
     }
-    else if(curShareFileDataModel.downloadBoxStateType == downloadBoxStateSuspend){
-        [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_start"] forState:UIControlStateNormal];
-    }
-    else if(curShareFileDataModel.downloadBoxStateType == downloadBoxStateFail){
-        [_upLoadStateButton setImage:[UIImage imageNamed:@"uploadFile_reStart"] forState:UIControlStateNormal];
-        _progressBgView.hidden = YES;
-    }
-    else{
-        _upLoadStateButton.hidden = YES;
-        _progressBgView.hidden = YES;
-    }
-    
-    
-    if(curShareFileDataModel.downloadBoxStateType == downloadBoxStateDone){
-        NSString*tipStr = NSLocalizedString(@"File_download_Path_other_done",nil);
-        
-        if([iTools canSaveFileToAlbumByPhoto:YES withName:curShareFileDataModel.fileName]
-           ||[iTools canSaveFileToAlbumByPhoto:NO withName:curShareFileDataModel.fileName]){
-            tipStr = NSLocalizedString(@"File_download_Path_default_done",nil);
-        }
-        
-        _fileProgresslabel.text = [[NSString alloc] initWithFormat:@"%@  %@",totalSizeStr,tipStr];
-    }
-    else if(curShareFileDataModel.downloadBoxStateType == downloadBoxStateFail){
-        _fileProgresslabel.text = [[NSString alloc] initWithFormat:@"%@",totalSizeStr];
-    }
-    else{
-        _fileProgresslabel.text = [[NSString alloc] initWithFormat:@"%@/%@",didUploadStr,totalSizeStr];
+
+    if (speedStr) {
+        self->_fileSpeedlabel.text = speedStr;
     }
-    
 }
 
 
@@ -701,9 +665,13 @@
     _curShareFileDataModel.currentSize = downloadedSize;
     _curShareFileDataModel.curTimeInterval = [[NSDate date] timeIntervalSince1970];
     
-    mainBlock(^{
-        [self updateDataDownloadingBy:self->_curShareFileDataModel];
+    KWeakSelf
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        [weakSelf updateDataDownloadingBy:self->_curShareFileDataModel];
     });
+//    mainBlock(^{
+//        [self updateDataDownloadingBy:self->_curShareFileDataModel];
+//    });
 
 }