Selaa lähdekoodia

1.传输列表非流量环境下上传/下载文件优化. 根据网络变化自动显示和隐藏

huangxiaodong 8 kuukautta sitten
vanhempi
commit
d32fdde734

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

@@ -38,6 +38,7 @@
 
 @property (nonatomic, strong) receiveView *curReceiveView;
 @property (nonatomic, strong) nonWifiTipInRecordView *nonWifiTipInRecordV;
+@property (nonatomic, assign) CGFloat nonWifiTipViewHeight;
 
 
 //@property (nonatomic,strong) uploadFileRecordTableViewHeadView *leftHeadView;
@@ -79,6 +80,8 @@
     
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadTaskFinishedNoti:) name:nasDownloadTaskFinishedNotification object:nil];
     
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkStateChange:)  name:NetWorkChangeNotification        object:nil];
+    
     [self.view setBackgroundColor:[UIColor whiteColor]];
     
     self.titleLabel.text = NSLocalizedString(@"my_set_no_File_Transfer_List",nil) ;
@@ -192,32 +195,34 @@
         [weakSelf didClickHeadFun: index];
     };
     
-    CGFloat nonWifiTipViewHeight = 0;
+    _nonWifiTipViewHeight = 0;
+    [self.view addSubview:self.nonWifiTipInRecordV];
     
     BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
     //当前网络为流量 与流量传输没开
     if ([AFNetworkReachabilityManager sharedManager].isReachableViaWWAN
-        && !isCanUseCellular || 1) {
-        [self.view addSubview:self.nonWifiTipInRecordV];
-        
-        [self.nonWifiTipInRecordV mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.left.mas_equalTo(15);
-            make.right.mas_equalTo(-15);
-            make.top.mas_equalTo(self.uploadFileRecordheadV.mas_bottom).offset(0.0);
-            make.height.mas_equalTo(56);
-        }];
-        
-        nonWifiTipViewHeight = 56;
-        
-#pragma mark 点击去开启
-        KWeakSelf
-        self.nonWifiTipInRecordV.didClickBut = ^{
-            [weakSelf gotoTranSettingVCFun];
-        };
+        && !isCanUseCellular) {
+        _nonWifiTipViewHeight = 56;
+    }
+    
+    [self.nonWifiTipInRecordV mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(15);
+        make.right.mas_equalTo(-15);
+        make.top.mas_equalTo(self.uploadFileRecordheadV.mas_bottom).offset(0.0);
+        make.height.mas_equalTo(_nonWifiTipViewHeight);
+    }];
+    
+    if(_nonWifiTipViewHeight == 0){
+        self.nonWifiTipInRecordV.hidden = YES;
     }
     
+#pragma mark 点击去开启
+    self.nonWifiTipInRecordV.didClickBut = ^{
+        [weakSelf gotoTranSettingVCFun];
+    };
+    
     
-    CGFloat curHeight = SCREEN_H - (H_STATE_BAR + 64.f) - 50 - nonWifiTipViewHeight - 15;
+    CGFloat curHeight = SCREEN_H - (H_STATE_BAR + 64.f) - 50 - _nonWifiTipViewHeight - 15;
     
     
     _uploadFileRecordBgScorllV= [[uploadFileRecordBgScorllView alloc] init];
@@ -228,7 +233,7 @@
     [_uploadFileRecordBgScorllV mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.mas_equalTo(0);
         make.right.mas_equalTo(0);
-        if(nonWifiTipViewHeight > 0){
+        if(_nonWifiTipViewHeight > 0){
             make.top.mas_equalTo(self.nonWifiTipInRecordV.mas_bottom).offset(0.0);
         }
         else{
@@ -1423,4 +1428,94 @@
     [self.navigationController pushViewController:nextVC animated:YES];
 }
 
+#pragma - mark - 监听网络变化
+- (void)networkStateChange:(NSNotification *)notification
+{
+    
+    //处理UI变化
+    
+    if([AFNetworkReachabilityManager sharedManager].isReachableViaWiFi){//目前是wifi
+        
+        if(_nonWifiTipViewHeight <=0){
+            return;//wifi 而且前面没有显示提示开启wifi传输 不需要处理
+        }
+        
+        _nonWifiTipViewHeight = 0;
+        [self RefreshBaseUIFun];
+        self.nonWifiTipInRecordV.hidden = YES;
+    }
+    else if([AFNetworkReachabilityManager sharedManager].isReachableViaWWAN){//目前是流量模式
+        
+        BOOL isCanUseCellular = [HWDataManager getBoolWithKey:stringKeyAddSn(Const_file_Transfe_canUse_Cellular_all)];
+        //当前网络为流量 与流量传输没开
+        if (!isCanUseCellular) {
+            _nonWifiTipViewHeight = 56;
+            [self RefreshBaseUIFun];
+            self.nonWifiTipInRecordV.hidden = NO;
+        }
+    }
+    
+}
+
+#pragma mark 更新UI
+- (void)RefreshBaseUIFun
+{
+    [self.nonWifiTipInRecordV mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(15);
+        make.right.mas_equalTo(-15);
+        make.top.mas_equalTo(self.uploadFileRecordheadV.mas_bottom).offset(0.0);
+        make.height.mas_equalTo(_nonWifiTipViewHeight);
+    }];
+    
+
+    CGFloat curHeight = SCREEN_H - (H_STATE_BAR + 64.f) - 50 - _nonWifiTipViewHeight - 15;
+        
+    [_uploadFileRecordBgScorllV mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
+        make.right.mas_equalTo(0);
+        if(_nonWifiTipViewHeight > 0){
+            make.top.mas_equalTo(self.nonWifiTipInRecordV.mas_bottom).offset(0.0);
+        }
+        else{
+            make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
+        }
+        
+        make.bottom.mas_equalTo(0);
+    }];
+        
+
+    [_leftTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(SCREEN_W*0.0);
+        make.width.mas_equalTo(SCREEN_W);
+        make.top.mas_equalTo(0);
+        make.height.mas_equalTo(curHeight);
+    }];
+
+    [_midTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(SCREEN_W*1.0);
+        make.width.mas_equalTo(SCREEN_W);
+        make.top.mas_equalTo(0);
+        make.height.mas_equalTo(curHeight);
+    }];
+
+       
+    [_rightTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(SCREEN_W*2.0);
+        make.width.mas_equalTo(SCREEN_W);
+        make.top.mas_equalTo(0);
+        make.height.mas_equalTo(curHeight);
+    }];
+
+       
+    [_curReceiveView mas_remakeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(SCREEN_W*3.0);
+        make.width.mas_equalTo(SCREEN_W);
+        make.top.mas_equalTo(0);
+        make.height.mas_equalTo(curHeight);
+    }];
+     
+    _uploadFileRecordBgScorllV.contentSize = CGSizeMake(SCREEN_W*4.0, curHeight);
+    
+}
+
 @end