阶段性完成

This commit is contained in:
kai60
2020-10-17 22:41:26 +08:00
parent 55d25d8fba
commit 3356311c86
13 changed files with 899 additions and 1060 deletions
@@ -11,6 +11,9 @@
#import "IfishCameraRecordfirstCell.h"
#import "IfishCameraRecordSecondCell.h"
#import "IfishCameraRecordThirdCell.h"
#import "TemperatureSetModel.h"
#import "TemperatureSetCell.h"
#import "MydatePickerView.h"
#define RECODIEECELL_TIME 911
#define RECODIEECELL_BTN 922
#define RECODIEECELL_SWiTCH 933
@@ -32,8 +35,8 @@ static const CGFloat ToastFade = 0.2;
@property(nonatomic) NSIndexPath *buttonIndex;
@property(assign) unsigned int remoteRecordState;
//本app 需求模式 非摄像头模式
@property(nonatomic) BOOL isManual;
@property(nonatomic,strong) NSMutableArray*array;
@property (nonatomic, strong)MydatePickerView *mydatepicView;
@end
@@ -42,42 +45,17 @@ static const CGFloat ToastFade = 0.2;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self addTitleViewWithTitle:@"手动录制"];
_timestr= @"00:00";
_isRecording = NO;
_isManual = NO;
[self addTitleViewWithTitle:@"录制视频"];
[self creatUI];
self.view.backgroundColor = RGB(242, 242, 242);
// self.view.backgroundColor = RGB(242, 242, 242);
}
-(void)goBackAction{
if (_isRecording) {
UIAlertController*ac=[UIAlertController alertControllerWithTitle:@"" message:@"是否结束手动录制" preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:ac animated:YES completion:nil];
[ac addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction*action){
}]];
[ac addAction:[UIAlertAction actionWithTitle:@"结束" style:UIAlertActionStyleDefault handler:^(UIAlertAction*action){
[[P2PClient sharedClient] setRemoteRecordWithId:self.camera.cameraId
password:self.camera.cameraPass state:SETTING_VALUE_REMOTE_RECORD_STATE_OFF];
[self.navigationController popViewControllerAnimated:YES];
}]];
}else{
[self.navigationController popViewControllerAnimated:YES];
}
[self.navigationController popViewControllerAnimated:YES];
}
-(void)creatUI{
@@ -88,7 +66,7 @@ static const CGFloat ToastFade = 0.2;
self.tab.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tab.showsVerticalScrollIndicator = NO;
self.tab.scrollEnabled = NO;
self.tab.backgroundColor = RGB(242, 242, 242);
//self.tab.backgroundColor = RGB(242, 242, 242);
[self.view addSubview:self.tab];
}
@@ -102,68 +80,16 @@ static const CGFloat ToastFade = 0.2;
BOOL connectDevice = [[GWP2PClient sharedClient] connectWithAccount:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2 sessionID1:model.sessionID sessionID2:model.sessionID2 customerIDs:nil];
if (connectDevice) {
[self connectCamera];
}else{
NSLog(@"p2pConnect failure.失败,不能操作设备");
}
}
}
//连接到摄像头
-(void)connectCamera{
[[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:self.camera.cameraId password:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
if (success) {
_isConnectCamera = YES;
[self monitorP2PCall];
NSLog(@"当前连接设备信息:%@",dataDictionary);
}else{
_isConnectCamera = YES;
[self monitorP2PCall];
// _isConnectCamera = NO;
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [self.view makeToast:@"连接设备失败"];
// [self hiddenMonitoringUI:NO callWithErrorType:100 isReCall:NO];
// });
// return;
}
}];
}
#pragma mark --尝试连接摄像头
-(void)monitorP2PCall{
if ([self.player isPlaying]) {//如果已经连接,则不重复发出连接申请
return;
}
//p2p未连接
if ([GWP2PClient sharedClient].linkStatus != P2PLinkStatusOK) {
[self connectDevice];
return;
}
//未连接到设备
if (!_isConnectCamera) {
[self connectCamera];
return;
}
WEAK_SELF;
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[weakSelf.player p2pCallDeviceWithDeviceId:self.camera.cameraId password:self.camera.cameraPass definition:GWP2PPTZDefinitionSD calling:^(NSDictionary *parameters) {
//呼叫设备
NSLog(@"[p2pCallDevice-Calling],paras=%@",parameters);
} accept:^(NSDictionary *parameters) {
NSLog(@"[p2pCallDevice-Accept],paras=%@",parameters);
} reject:^(GWP2PCallError error, NSString *errorCode) {
} ready:^{
} allowLAN:YES];
});
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
@@ -171,577 +97,206 @@ static const CGFloat ToastFade = 0.2;
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveRemoteMessage:) name:RECEIVE_REMOTE_MESSAGE object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ack_receiveRemoteMessage:) name:ACK_RECEIVE_REMOTE_MESSAGE object:nil];
[[P2PClient sharedClient] getNpcSettingsWithId:self.camera.cameraId password:self.camera.cameraPass];
// [[P2PClient sharedClient] getSDCardInfoWithId:self.camera.cameraId password:self.camera.cameraPass];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self name:RECEIVE_REMOTE_MESSAGE object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:ACK_RECEIVE_REMOTE_MESSAGE object:nil];
}
#pragma mark - receiveRemoteMessage
- (void)receiveRemoteMessage:(NSNotification *)notification
{
NSDictionary *parameter = [notification userInfo];
int key = [[parameter valueForKey:@"key"] intValue];
switch (key) {
case RET_GET_SDCARD_INFO:
{
NSInteger result = [[parameter valueForKey:@"result"] intValue];
dispatch_async(dispatch_get_main_queue(), ^{
if (result == 1) {
//[self.view makeToast:@"sdk卡可使用"];
//获取状态信息
// [[P2PClient sharedClient] getNpcSettingsWithId:self.camera.cameraId password:self.camera.cameraPass];
if (_isManual) {
if (self.remoteRecordState ==1){
//[self.view makeToast:@"请先关闭自动录制"];
[self showLableAction:@"请先关闭自动录制"];
dispatch_async(dispatch_get_main_queue(), ^{
[self hiddenTostVIew];
});
[self resetTimerlabel];
return ;
}
NSArray *buttonindex =@[self.buttonIndex];
[self.tab reloadRowsAtIndexPaths:buttonindex withRowAnimation:UITableViewRowAnimationNone];
[[P2PClient sharedClient] setRemoteRecordWithId:self.camera.cameraId
password:self.camera.cameraPass state:SETTING_VALUE_REMOTE_RECORD_STATE_ON];
}else{
[self showLableAction:@"请先关闭自动录制"];
dispatch_async(dispatch_get_main_queue(), ^{
[self hiddenTostVIew];
});
[self resetTimerlabel];
}
}else{
//sd卡不存在,
//停止计时
dispatch_async(dispatch_get_main_queue(), ^{
[self hiddenTostVIew];
});
[self resetTimerlabel];
[self.view makeToast:NSLocalizedString(@"no_storage", nil)];
}
});
}
break;
case RET_GET_NPCSETTINGS_PRERECORD: //预录像开关 获取时
{
NSInteger state = [[parameter valueForKey:@"state"] intValue];
NSLog(@"预录像开关 获取时state%ld",(long)state);
}
break;
case RET_SET_NPCSETTINGS_PRERECORD: //预录像开关 设置时
{
NSInteger result = [[parameter valueForKey:@"result"] intValue];
if(result==0){
NSLog(@"预录像开关设置result%ld",(long)result);
}else{
NSLog(@"预录像开关设置result%ld",(long)result);
}
}
break;
case RET_SET_NPCSETTINGS_REMOTE_RECORD:
{
NSInteger result = [[parameter valueForKey:@"result"] integerValue];
if(result==0){
//设置成功主动获取一次状态 刷新
dispatch_async(dispatch_get_main_queue(), ^{
[self hiddenTostVIew];
});
[[P2PClient sharedClient] getNpcSettingsWithId:self.camera.cameraId password:self.camera.cameraPass];
}else{
NSLog(@"设置失败:%li",(long)result);
}
}
break;
case RET_GET_NPCSETTINGS_REMOTE_RECORD:
{
//
NSInteger state = [[parameter valueForKey:@"state"] intValue];
self.remoteRecordState = (unsigned int)state;
if (state ==0) {
dispatch_async(dispatch_get_main_queue(), ^{
[self resetTimerlabel];
});
}else{
}
if (_isManual) {
//手动模式开启不刷新switch按钮状态
return;
}
NSLog(@"获取 remote record state:%li",(long)state);
dispatch_async(dispatch_get_main_queue(), ^{
NSArray *index =@[self.switchIndex];
[self.tab reloadRowsAtIndexPaths:index withRowAnimation:UITableViewRowAnimationNone];
// NSArray *buttonindex =@[self.buttonIndex];
// [self.tab reloadRowsAtIndexPaths:buttonindex withRowAnimation:UITableViewRowAnimationNone];
});
}
case RET_GET_NPCSETTINGS_RECORD_TYPE:
{
NSInteger type = [[parameter valueForKey:@"type"] intValue];
//0手动模式 摄像头模式
NSLog(@"获取录像模式类型type%ld",(long)type);
}
break;
case RET_SET_NPCSETTINGS_RECORD_TYPE:
{
NSInteger result = [[parameter valueForKey:@"result"] intValue];
//0类型设置成功
if (result==0) {
//[[P2PClient sharedClient] setRemoteRecordWithId:self.camera.cameraId
// password:self.camera.cameraPass state:SETTING_VALUE_REMOTE_RECORD_STATE_ON];
}
NSLog(@"设置录像模式类型result%ld",(long)result);
}
break;
default:
break;
}
}
#pragma mark -ack_receiveRemoteMessage
- (void)ack_receiveRemoteMessage:(NSNotification *)notification{
NSDictionary *parameter = [notification userInfo];
int key = [[parameter valueForKey:@"key"] intValue];
int result = [[parameter valueForKey:@"result"] intValue];
switch (key) {
case ACK_RET_GET_SDCARD_INFO:
{
dispatch_async(dispatch_get_main_queue(), ^{
if(result==1){
[self.view makeToast:NSLocalizedString(@"device_password_error", nil)];
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// usleep(800000);
//
//
// });
}else if(result==2){
DLog(@"resend do device update");
}
});
DLog(@"ACK_RET_GET_SDCARD_INFO:%i",result);
}
break;
case ACK_RET_SET_SDCARD_INFO:
{
dispatch_async(dispatch_get_main_queue(), ^{
if(result==1){
[self.view makeToast:NSLocalizedString(@"device_password_error", nil)];
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// usleep(800000);
// dispatch_async(dispatch_get_main_queue(), ^{
// });
// });
}else if(result==2){
DLog(@"resend do device update");
}
});
}
break;
default:
break;
}
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section ==2) {
return 2;
}
return 1;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 3;
return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
TemperatureSetCell*cell=[tableView dequeueReusableCellWithIdentifier:@"TemperatureSetCell"];
if (cell==nil) {
cell=[[[NSBundle mainBundle]loadNibNamed:@"TemperatureSetCell" owner:self options:nil]lastObject];
}
cell.backgroundView=nil;
cell.backgroundColor= RGB(242, 242, 242);
if (indexPath.section ==0 && indexPath.row ==0) {
IfishCameraRecordfirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IfishCameraRecordfirstCell"];
if (!cell) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"IfishCameraRecordfirstCell" owner:self options:nil]lastObject];
TemperatureSetModel*model=[[TemperatureSetModel alloc]init];
model.title=@"即时录制";
model.temperatureLabel=@"";
model.status=[[DataCenter defaultDtacenter].cache stringForKey:@"NowRecord"];
cell.titleLabel.text=model.title;
cell.temperaturelabel.text=model.temperatureLabel;
[cell.temPSwitch addTarget:self action:@selector(nowRecordBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateSelected];
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
cell.selected=[model.status isEqualToString:@"1"];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}else if (indexPath.section ==2 && indexPath.row ==0){
IfishCameraRecordSecondCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IfishCameraRecordSecondCell"];
if (!cell) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"IfishCameraRecordSecondCell" owner:self options:nil]lastObject];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.tag = RECODIEECELL_TIME;
self.timerIndex = indexPath;
cell.timeLabe.text = _timestr;
_isRecording ? [cell.timeLabe setTextColor:RGB(51, 51, 51)] : [cell.timeLabe setTextColor:RGB(153, 153, 153)];
[cell cellRecordBViewCorner];
return cell;
}else if (indexPath.section ==2 && indexPath.row ==1){
IfishCameraRecordThirdCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IfishCameraRecordThirdCell"];
if (!cell) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"IfishCameraRecordThirdCell" owner:self options:nil]lastObject];
}
cell.tag = RECODIEECELL_BTN;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.recordBtn addTarget:self action:@selector(recordBtnAction:) forControlEvents:UIControlEventTouchUpInside];
if (_isRecording) {
cell.recordBtn.selected = YES;
[cell.recordBtn setBackgroundColor:RGB(255,115,92)];
[cell.recordBtn setTitle:@"结束录制" forState:UIControlStateNormal];
}else{
cell.recordBtn.selected = NO;
[cell.recordBtn setBackgroundColor:RGB(0,184,239)];
[cell.recordBtn setTitle:@"开始录制" forState:UIControlStateNormal];
}
self.buttonIndex =indexPath;
[cell cellSetRecordBtnBackViewCorner];
return cell;
}else if (indexPath.section ==1 && indexPath.row ==0){
self.switchIndex = indexPath;
IfishCameraRecordFourCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IfishCameraRecordFourCell"];
if (!cell) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"IfishCameraRecordFourCell" owner:self options:nil]lastObject];
}
cell.tag = RECODIEECELL_SWiTCH;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.zidongSw addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
if (self.remoteRecordState==1) {
[cell.zidongSw setOn:YES];
}else{
[cell.zidongSw setOn:NO];
}
return cell;
TemperatureSetModel*model=[[TemperatureSetModel alloc]init];
model.title=@"定时录制";
model.temperatureLabel=[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecordTime"].length?[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecordTime"]:@"09:00-16:00";
model.status=[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecord"];
cell.titleLabel.text=model.title;
cell.temperaturelabel.text=model.temperatureLabel;
[cell.temPSwitch addTarget:self action:@selector(schduleRecordAction:) forControlEvents:UIControlEventTouchUpInside];
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateSelected];
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
cell.selected=[model.status isEqualToString:@"1"];
}
return nil;
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section ==0 && indexPath.row ==0) {
return kScreenSize.width*0.516;
}else if (indexPath.section ==2 && indexPath.row ==0){
return kScreenSize.width*0.357;
}else if (indexPath.section ==1 && indexPath.row ==0){
return 46*KWidth_Scale;
}else if (indexPath.section ==2 && indexPath.row ==1){
return 76*KWidth_Scale;
}
return 0;
return 50;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section==0) {
return kScreenSize.width*0.213;
}
return 5;
return 5;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (section ==0) {
UIView *sectionV1=[[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width,kScreenSize.width*0.213)];
sectionV1.backgroundColor = RGB(242, 242, 242);
return sectionV1;
}
UIView *sectionV2=[[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width,5)];
sectionV2.backgroundColor = RGB(242, 242, 242);
sectionV2.backgroundColor =[UIColor whiteColor];
return sectionV2;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section==1)
{
if (!self.mydatepicView) {
_mydatepicView=[[MydatePickerView alloc]init];
_mydatepicView.frame=CGRectMake(0,0,kScreenSize.width,kScreenSize.height);
[_mydatepicView setIsNewXuanduo:YES];
[_mydatepicView.picView reloadAllComponents];
[_mydatepicView.cancleButton addTarget:self action:@selector(cancleButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_mydatepicView.sureButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
NSString*time=[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecordTime"].length?[[DataCenter defaultDtacenter].cache stringForKey:@"schduleRecordTime"]:@"09:00-16:00";
NSString*start=[[time componentsSeparatedByString:@"-"] firstObject];
NSString*end=[[time componentsSeparatedByString:@"-"] lastObject];
NSString*startHour=[[start componentsSeparatedByString:@":"] firstObject];
NSString*startMin=[[start componentsSeparatedByString:@":"] lastObject];
NSString*endHour=[[end componentsSeparatedByString:@":"] firstObject];
NSString*endMin=[[end componentsSeparatedByString:@":"] lastObject];
_mydatepicView.startString=startHour;
_mydatepicView.endString=startMin;
_mydatepicView.startString1=endHour;
_mydatepicView.endString1=endHour;
[_mydatepicView.picView selectRow:[(NSArray*)(_mydatepicView.dataArr[0]) indexOfObject:startHour] inComponent:0 animated:YES];
[_mydatepicView.picView selectRow:[(NSArray*)(_mydatepicView.dataArr[1]) indexOfObject:startMin] inComponent:1 animated:YES];
[_mydatepicView.picView selectRow:[(NSArray*)(_mydatepicView.dataArr[2]) indexOfObject:endHour] inComponent:2 animated:YES];
[_mydatepicView.picView selectRow:[(NSArray*)(_mydatepicView.dataArr[3]) indexOfObject:endMin] inComponent:3 animated:YES];
}
[self.view addSubview:_mydatepicView];
}
}
#pragma mark - recordBtnAction
-(void)recordBtnAction:(UIButton*)btn{
#pragma mark 设置时间段
-(void)doneButtonClick{
if (btn.selected) {
[self resetTimerlabel];
_isManual = NO;
//停止录制
[self startTostVIew];
[[P2PClient sharedClient] setRemoteRecordWithId:self.camera.cameraId
password:self.camera.cameraPass state:SETTING_VALUE_REMOTE_RECORD_STATE_OFF];
[self showLableAction:@"录制成功,请在回放中查看"];
}else{
[self startRunTimerlabel];
_isManual = YES;
//开始录制
//获取SDCard状态
[self startTostVIew];
[[P2PClient sharedClient] getSDCardInfoWithId:self.camera.cameraId password:self.camera.cameraPass];
}
}
-(void)startRunTimerlabel
{
//IfishCameraRecordThirdCell *cell=[self.view viewWithTag:RECODIEECELL_BTN];
//cell.recordBtn.selected =YES;
_isRecording=YES;
__weak typeof(self)weakSelf=self;
NSInteger count = 30*60;
//NSInteger count = -1;
//NSInteger count = 60;
weakSelf.timer = [NSTimer scheduledTimerWithTimeInterval:1 count:count callback:^{
weakSelf.second++;
if (weakSelf.second ==60) {
weakSelf.second = 0;
weakSelf.minute++;
}
if (weakSelf.minute ==30) {
weakSelf.minute =0;
weakSelf.second =0;
[self resetTimerlabel];
_isManual = NO;
//停止录制
[self startTostVIew];
[[P2PClient sharedClient] setRemoteRecordWithId:self.camera.cameraId
password:self.camera.cameraPass state:SETTING_VALUE_REMOTE_RECORD_STATE_OFF];
[self showLableAction:@"录制成功,请在回放中查看"];
return ;
}
_timestr= [IfishHelperUtils formatCameraPalybackTime:weakSelf.minute second:weakSelf.second];
NSArray *index =@[self.timerIndex];
[self.tab reloadRowsAtIndexPaths:index withRowAnimation:UITableViewRowAnimationNone];
}];
[[NSRunLoop currentRunLoop] addTimer: weakSelf.timer forMode:NSRunLoopCommonModes];
// NSArray *buttonindex =@[self.buttonIndex];
// [self.tab reloadRowsAtIndexPaths:buttonindex withRowAnimation:UITableViewRowAnimationNone];
}
-(void)resetTimerlabel
{
_isRecording=NO;
if (_timer) {
[_timer unfireTimer];
}
self.minute =0;
self.second =0;
_timestr = @"00:00";
NSArray *index =@[self.timerIndex];
[self.tab reloadRowsAtIndexPaths:index withRowAnimation:UITableViewRowAnimationNone];
NSArray *buttonindex =@[self.buttonIndex];
[self.tab reloadRowsAtIndexPaths:buttonindex withRowAnimation:UITableViewRowAnimationNone];
}
#pragma mark -加载中
-(void)startTostVIew{
self.progressAlert = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:self.progressAlert];
self.progressAlert.mode=MBProgressHUDModeIndeterminate;
self.progressAlert.customView = [[UIView alloc] init];
//self.progressAlert.labelText = [NSString stringWithFormat:@"%@...",NSLocalizedString(@"validating", nil)];
[self.progressAlert show:YES];
//设置5秒超时
[self.progressAlert hide:YES afterDelay:5];
}
-(void)hiddenTostVIew
{
[self.progressAlert hide:YES];
}
#pragma mark - switchAction:
-(void)switchAction:(UISwitch*)sender
{
IfishCameraRecordFourCell *cell =[self.view viewWithTag:RECODIEECELL_SWiTCH];
UISwitch* swt=(UISwitch*)sender;
cell.zidongSw = swt;
if (_isRecording) {
dispatch_async(dispatch_get_main_queue(), ^{
[cell.zidongSw setOn:NO];
});
//[self.view makeToast:@"请先结束手动录制"];
[self showLableAction:@"请先结束手动录制"];
return;
}
[self startTostVIew];
if (swt.isOn) {
_isManual = NO;
[[P2PClient sharedClient] setRemoteRecordWithId:self.camera.cameraId
password:self.camera.cameraPass state:SETTING_VALUE_REMOTE_RECORD_STATE_ON];
[[P2PClient sharedClient] setDeviceRecordType:GWP2PRecordTypeSchedule withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
NSLog(@"data=%@",dataDictionary);
}];;
_mydatepicView.resultString=nil;
if (_mydatepicView.startString==nil||_mydatepicView.endString==nil) {
[self showTitle:@"" messsage:@"请选择时间"];
}else{
_isManual = YES;
[[P2PClient sharedClient] setRemoteRecordWithId:self.camera.cameraId
password:self.camera.cameraPass state:SETTING_VALUE_REMOTE_RECORD_STATE_ON];
_mydatepicView.resultString=[NSString stringWithFormat:@"%@:%@-%@:%@",_mydatepicView.startString,_mydatepicView.endString,_mydatepicView.startString1,_mydatepicView.endString1];
[[DataCenter defaultDtacenter].cache setString:_mydatepicView.resultString forKey:@"schduleRecordTime"];
[_mydatepicView removeFromSuperview];
TemperatureSetCell*cell=[self.tab cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]];
cell.temperaturelabel.text=_mydatepicView.resultString;
}
}
-(void)cancleButtonClick{
[_mydatepicView removeFromSuperview];
}
-(void)nowRecordBtnAction:(UIButton*)btn{
btn.selected=!btn.selected;
[[DataCenter defaultDtacenter].cache setString:[NSString stringWithFormat:@"%ld",btn.selected] forKey:@"NowRecord"];
if (btn.selected)
{
}else
{
}
}
-(void)schduleRecordAction:(UISwitch*)btn
{
btn.selected=!btn.selected;
[[DataCenter defaultDtacenter].cache setString:[NSString stringWithFormat:@"%ld",btn.selected] forKey:@"schduleRecord"];
if (btn.selected) {
[[GWP2PClient sharedClient] setDeviceRecordType:GWP2PRecordTypeSchedule withDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
NSLog(@"data=%@",dataDictionary);
}];
}else{
}
}
- (void)showLableAction:(NSString *)str{
UILabel *laberAction =[[UILabel alloc]init];
CGFloat labW = 200;
laberAction.frame =CGRectMake(kScreenSize.width/2 - labW/2,kScreenSize.height*3/4 - 50 , labW, 40);
laberAction.clipsToBounds =YES;
laberAction.layer.cornerRadius =5;
laberAction.layer.backgroundColor = [UIColor blackColor].CGColor;
laberAction.alpha =1;
laberAction.text =str;
laberAction.textAlignment =NSTextAlignmentCenter;
//laberAction.backgroundColor =IndicatorBack_COLOR;
laberAction.font=[UIFont systemFontOfSize:14];
laberAction.textColor=[UIColor whiteColor];
[self.view addSubview:laberAction];
[UIView animateWithDuration:ToastFade
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
laberAction.alpha = 1.0;
} completion:^(BOOL finished) {
[UIView animateWithDuration:ToastFade
delay:1.5
options:UIViewAnimationOptionCurveEaseIn
animations:^{
laberAction.alpha = 0.0;
} completion:^(BOOL finished) {
[laberAction removeFromSuperview];
}];
}];
}
@end