Bläddra i källkod

1.代码优化

huangxiaodong 1 år sedan
förälder
incheckning
ad66b8a90e
1 ändrade filer med 62 tillägg och 37 borttagningar
  1. 62 37
      创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm

+ 62 - 37
创维盒子/双子星云手机/CloudPlayer/PlayerViewController.mm

@@ -517,7 +517,7 @@ ComontAlretViewControllerDelegate>
                         NSString * dataStr = (NSString*)data;
                         if([dataStr isEqualToString:@"offline_notification"]){
                             HLog(@"被别人挤下线了");
-                            [self LogoutByOtherFun];
+                            [weakSelf LogoutByOtherFun];
                         }
                          
                          return;
@@ -660,8 +660,7 @@ ComontAlretViewControllerDelegate>
 //                }
             }
             else if ([messageType isEqualToString:@"sync_wifi"]){
-                [self.commandChannelManager rc_sendData:[RCCommandHelp noSyncWifiBack]];
-                [[iToast makeText:NSLocalizedString(@"player_Tip_ios_no_wifi_Sync",nil)] show];
+                [weakSelf sync_wifiBackHandleFun];
             }
             else if ([messageType isEqualToString:@"reProduceText"]){
                 if ([[dataDict allKeys] containsObject:@"data"]) {
@@ -695,9 +694,7 @@ ComontAlretViewControllerDelegate>
             else if ([messageType isEqualToString:@"shakeit"]){
                 HLog(@"\n-----摇一摇成功------");
             }else if ([messageType isEqualToString:@"keyboardFeedbackBean"]){/*调起键盘*/
-                [self->hidenTextField becomeFirstResponder];
-//                [self->hidenTextField setText:@"1234"];
-                [self->hidenTextField setEnabled:YES];
+                [weakSelf keyboardFeedbackBeanFun];
             }else if ([messageType isEqualToString:@"FileRandomReady"]){/*申请文件上传得到答复*/
                 [weakSelf applyUploadFileServiceResponseFun:dataDict];
             }
@@ -722,6 +719,19 @@ ComontAlretViewControllerDelegate>
     }
 }
 
+#pragma mark wifi handle
+- (void)sync_wifiBackHandleFun
+{
+    [self.commandChannelManager rc_sendData:[RCCommandHelp noSyncWifiBack]];
+    [[iToast makeText:NSLocalizedString(@"player_Tip_ios_no_wifi_Sync",nil)] show];
+}
+
+- (void)keyboardFeedbackBeanFun
+{
+    [self->hidenTextField becomeFirstResponder];
+//                [self->hidenTextField setText:@"1234"];
+    [self->hidenTextField setEnabled:YES];
+}
 
 
 - (void)textDidChange:(UITextField *)textField{
@@ -1448,19 +1458,7 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
 #pragma mark 重启盒子
     //{"type":"reboot"}
     nextVC.needToReboot = ^{
-        
-        NSString *commondStr  = @"{\"type\":\"reboot\"}";
-        [weakSelf send_data:commondStr];
-        
-        [weakSelf startForceStartTimerFun];
-        
-        //最后一帧 没显示正在重启问题
-        self->_canShowImgAndVoiceType = YES;
-        
-        self->_isRebootIngType = YES;
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(30 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-            [weakSelf reconnectDevice];
-        });
+        [weakSelf needToRebootFun];
     };
     
 #pragma mark TV投屏
@@ -1476,14 +1474,7 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
     
 #pragma mark 恢复出厂盒子
     nextVC.needToReset = ^{
-        
-        NSString *commondStr  = @"{\"type\":\"reset\"}";
-        [weakSelf send_data:commondStr];
-        
-        //最后一帧 没显示正在重启问题
-        //self->_canShowImgAndVoiceType = YES;
-        self->_isResetingType = YES;
-        
+        [weakSelf needToResetFun];
     };
     
 #pragma mark 恢复出厂盒子 ok
@@ -1493,7 +1484,6 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
         
 #pragma mark 获取云机剩余空间
     nextVC.getBaseInfo = ^{
-        
         NSString *commondStr  = @"{\"type\":\"getBaseInfo\"}";
         [weakSelf send_data:commondStr];
     };
@@ -1501,19 +1491,43 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
     
 #pragma mark 获取云机版本信息
     nextVC.getSysInfo = ^{
-        
         NSString *commondStr  = @"{\"type\":\"getSysInfo\"}";
         [weakSelf send_data:commondStr];
     };
     
 #pragma mark 获取TV投屏状态
     nextVC.getTvStatus = ^{
-        
         NSString *commondStr  = @"{\"type\":\"TvStatus\"}";
         [weakSelf send_data:commondStr];
     };
 }
 
+- (void)needToRebootFun
+{
+    NSString *commondStr  = @"{\"type\":\"reboot\"}";
+    [self send_data:commondStr];
+    
+    [self startForceStartTimerFun];
+    
+    //最后一帧 没显示正在重启问题
+    _canShowImgAndVoiceType = YES;
+    
+    _isRebootIngType = YES;
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(30 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        [self reconnectDevice];
+    });
+}
+
+- (void)needToResetFun
+{
+    NSString *commondStr  = @"{\"type\":\"reset\"}";
+    [self send_data:commondStr];
+    
+    //最后一帧 没显示正在重启问题
+    //self->_canShowImgAndVoiceType = YES;
+    _isResetingType = YES;
+}
+
 #pragma mark 启动timer 秒后检查是否软件重启成功
 - (void)startForceStartTimerFun
 {
@@ -1776,12 +1790,17 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
             make.bottom.mas_equalTo(0.f);
         }];
         
-        
+        KWeakSelf
         _PlayerControlButTipV.didKnowPlayerControlButTip = ^{
-            self->mPlayerView.controlBtn.hidden = NO;
+            [weakSelf setMPlayerViewControlBtnHiddenBy:NO];
         };
     }
 }
+
+- (void)setMPlayerViewControlBtnHiddenBy:(BOOL)isHide
+{
+    mPlayerView.controlBtn.hidden = isHide;
+}
 #pragma mark - PlayerControlViewDelegate---控制器按键
 //- (void)stopShareBtnBePressed:(id)sender
 //{
@@ -1996,17 +2015,14 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
     
     linkErrTip = [[NSString alloc] initWithFormat:@"[%ld]%@",type,linkErrTip];
     
+    KWeakSelf
     linkFailAlretVC= [[ComontAlretViewController alloc] initWithTiTle:NSLocalizedString(@"player_link_fail_title",nil)
                                                                                       msg:linkErrTip
                                                                                  imageStr:nil
                                                                               cancelTitle:NSLocalizedString(@"single_sign_on_exit",nil)
                                                                                   okTitle:NSLocalizedString(@"player_link_fail_tryAgain",nil) isOkBtnHighlight:YES
                                                                                didClickOk:^{
-        [self showNewIndicator];
-        self->reConnectAccount = 0;
-        [self tryAgain];
-        
-        self->linkFailAlretVC = nil;
+        [weakSelf tryAgainInLinkFailFun];
          
      } didClickCancel:^{
          exit(0);
@@ -2019,6 +2035,15 @@ NSDate *lastVideoTome;/*上一帧数据时间*/
      }];
 }
 
+- (void)tryAgainInLinkFailFun
+{
+    [self showNewIndicator];
+    reConnectAccount = 0;
+    [self tryAgain];
+    
+    linkFailAlretVC = nil;
+}
+
 BOOL inReconnect = NO;
 - (void)tryAgain
 {