From 3356311c86d88ac555f9a87c4d022746fdea5975 Mon Sep 17 00:00:00 2001 From: kai60 Date: Sat, 17 Oct 2020 22:41:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B6=E6=AE=B5=E6=80=A7=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 10244 -> 10244 bytes Ifish.xcodeproj/project.pbxproj | 12 + .../CommonLogin/UMComLoginViewController.xib | 57 +- .../IfishP2PPlayBackListViewController.h | 3 + .../IfishP2PPlayBackListViewController.m | 622 ++++++--------- .../IfishP2PPlayBackListViewController.xib | 235 ++++++ .../IfishP2PPlayBack/IfishPlaybackViewCell.h | 9 +- .../IfishP2PPlayBack/IfishPlaybackViewCell.m | 32 +- .../IfishPlaybackViewCell.xib | 102 ++- .../CameraRecordViewController.m | 755 ++++-------------- .../ifishUserModel/TemperatureSetModel.h | 2 +- Ifish/views/mypicView/DatePickerCustomView.h | 16 + Ifish/views/mypicView/DatePickerCustomView.m | 114 +++ 13 files changed, 899 insertions(+), 1060 deletions(-) create mode 100644 Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.xib create mode 100644 Ifish/views/mypicView/DatePickerCustomView.h create mode 100644 Ifish/views/mypicView/DatePickerCustomView.m diff --git a/.DS_Store b/.DS_Store index 56287ef998acfb52120bb9c370c237a6cb98af99..343b7a6ad7bf8fca885df27f1cf94b2cb1866edd 100644 GIT binary patch delta 67 zcmZn(XbG6$LAU^hRb)@B|7Hdba0?&isjq6SP47=V=0=BuJcToW5|HnS^mW09N9 F1OTrk6ng*w delta 164 zcmZn(XbG6$F8U^hRb&So9~Hdbc!{>PKuMU_Ny^Icq$a`KZH7#KKGEH>SGk#fip eDv^R!VzQYW;fALuFdQU+*C0thzS7ku{3}H diff --git a/Ifish.xcodeproj/project.pbxproj b/Ifish.xcodeproj/project.pbxproj index 37019c6..6d0ace8 100644 --- a/Ifish.xcodeproj/project.pbxproj +++ b/Ifish.xcodeproj/project.pbxproj @@ -2245,6 +2245,9 @@ C024B7B12379668B00509424 /* NSMutableArray+AvoidCrash.h in Headers */ = {isa = PBXBuildFile; fileRef = C024B79D2379668B00509424 /* NSMutableArray+AvoidCrash.h */; }; C02ED596249E3B7300CAC37D /* InfoByImageViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = C02ED594249E3B7300CAC37D /* InfoByImageViewController.h */; }; C02ED597249E3B7300CAC37D /* InfoByImageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C02ED595249E3B7300CAC37D /* InfoByImageViewController.m */; }; + C072196A253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0721969253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib */; }; + C072196D253B1F4F0065CF17 /* DatePickerCustomView.h in Headers */ = {isa = PBXBuildFile; fileRef = C072196B253B1F4F0065CF17 /* DatePickerCustomView.h */; }; + C072196E253B1F4F0065CF17 /* DatePickerCustomView.m in Sources */ = {isa = PBXBuildFile; fileRef = C072196C253B1F4F0065CF17 /* DatePickerCustomView.m */; }; C0837A57244FF5510034FEC5 /* EGOCache.m in Sources */ = {isa = PBXBuildFile; fileRef = C0837A55244FF5500034FEC5 /* EGOCache.m */; }; C0837A58244FF5510034FEC5 /* EGOCache.h in Headers */ = {isa = PBXBuildFile; fileRef = C0837A56244FF5500034FEC5 /* EGOCache.h */; }; C0873EE12491060000D47D34 /* ESPUDPSocketClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C0873EBE249105FF00D47D34 /* ESPUDPSocketClient.h */; }; @@ -5704,6 +5707,9 @@ C024B79D2379668B00509424 /* NSMutableArray+AvoidCrash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+AvoidCrash.h"; sourceTree = ""; }; C02ED594249E3B7300CAC37D /* InfoByImageViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InfoByImageViewController.h; sourceTree = ""; }; C02ED595249E3B7300CAC37D /* InfoByImageViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InfoByImageViewController.m; sourceTree = ""; }; + C0721969253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IfishP2PPlayBackListViewController.xib; sourceTree = ""; }; + C072196B253B1F4F0065CF17 /* DatePickerCustomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatePickerCustomView.h; sourceTree = ""; }; + C072196C253B1F4F0065CF17 /* DatePickerCustomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DatePickerCustomView.m; sourceTree = ""; }; C0837A55244FF5500034FEC5 /* EGOCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EGOCache.m; sourceTree = ""; }; C0837A56244FF5500034FEC5 /* EGOCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EGOCache.h; sourceTree = ""; }; C0873EBE249105FF00D47D34 /* ESPUDPSocketClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESPUDPSocketClient.h; sourceTree = ""; }; @@ -6606,6 +6612,7 @@ 3D1C4FF3221A9EDD0096AE43 /* P2PPlayingbackVC.m */, 3D1C4FEF221A9EDD0096AE43 /* PlayBaseViewController.h */, 3D1C4FF5221A9EDD0096AE43 /* PlayBaseViewController.m */, + C0721969253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib */, ); path = IfishP2PPlayBack; sourceTree = ""; @@ -10156,6 +10163,8 @@ 883E79771D48B0280030E075 /* mypicView */ = { isa = PBXGroup; children = ( + C072196B253B1F4F0065CF17 /* DatePickerCustomView.h */, + C072196C253B1F4F0065CF17 /* DatePickerCustomView.m */, 883E79781D48B0280030E075 /* Box.png */, 883E79791D48B0280030E075 /* MydatePickerView.h */, 883E797A1D48B0280030E075 /* MydatePickerView.m */, @@ -12875,6 +12884,7 @@ C0873EF62491060000D47D34 /* ESPTools.h in Headers */, CB8B6468230F7F980032EB24 /* IfishMainInfoCell.h in Headers */, C0EA8A2A23AF74F4003DC53B /* SDWebImageOperation.h in Headers */, + C072196D253B1F4F0065CF17 /* DatePickerCustomView.h in Headers */, CB484E1122B8C8C90075F050 /* version.h in Headers */, 3D1C5122221A9EE00096AE43 /* IfishRecVideoViewCell.h in Headers */, CB48207C2334E99700A50C92 /* IQTextView.h in Headers */, @@ -14533,6 +14543,7 @@ 882956DD1DBDA3A300E9DDD7 /* ifishdropview_add_device@3x.png in Resources */, 881478241E712A2700BFB79C /* task_openShareCamera@3x.png in Resources */, 887492511E7BB58A00CDA284 /* gold_background@3x.png in Resources */, + C072196A253AE2290065CF17 /* IfishP2PPlayBackListViewController.xib in Resources */, 882957961DBDA3A400E9DDD7 /* xutobtn2_on@3x.png in Resources */, 885606AC1E32081C0002C17C /* sharing_v_attestation@3x.png in Resources */, 881A1D331DD2C31500BA1AF4 /* kankanlook_icon_sentiment@2x.png in Resources */, @@ -14628,6 +14639,7 @@ 883E78621D48A5E50030E075 /* RightViewController.m in Sources */, CBA61675228F9AB100ED380D /* NSLayoutConstraint+MASDebugAdditions.m in Sources */, 886FB1A11E5A9D0A00256332 /* FishDocSection0ViewImgCell.m in Sources */, + C072196E253B1F4F0065CF17 /* DatePickerCustomView.m in Sources */, 881672381EA5DE2B00BEBF23 /* UMComSimpleAssociatedFeedTableViewCell.m in Sources */, 883E76431D4897570030E075 /* TwoControlBackmsgmodel.m in Sources */, 3D3512DB2159C172009DDB0F /* IfishHotBarModifyNameVc.m in Sources */, diff --git a/Ifish/UMCommunity/UMCommunitySDK/UMComModules/CommonLogin/UMComLoginViewController.xib b/Ifish/UMCommunity/UMCommunitySDK/UMComModules/CommonLogin/UMComLoginViewController.xib index be89668..cde5bf8 100644 --- a/Ifish/UMCommunity/UMCommunitySDK/UMComModules/CommonLogin/UMComLoginViewController.xib +++ b/Ifish/UMCommunity/UMCommunitySDK/UMComModules/CommonLogin/UMComLoginViewController.xib @@ -1,9 +1,10 @@ - - + + + - - + + @@ -20,22 +21,22 @@ - + - + - - + + - - + + - + @@ -53,7 +54,7 @@ - + @@ -71,14 +72,14 @@ - - + + - + @@ -112,38 +113,38 @@ - - + - + - + diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.h b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.h index b06616a..c3827f3 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.h +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.h @@ -11,5 +11,8 @@ #import "IfishCameraModel.h" @interface IfishP2PPlayBackListViewController : BaseViewController @property (nonatomic,strong) IfishCameraModel *camera; +@property (weak, nonatomic) IBOutlet UIButton *startBtn; +@property (weak, nonatomic) IBOutlet UIButton *endBtn; +@property (weak, nonatomic) IBOutlet UIButton *searchBtn; @end diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.m index 6c29c4d..5ce3061 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.m @@ -10,13 +10,15 @@ #import "CameraNoParyBackVideoView.h" #import "P2PClient.h" #import "IfishPlaybackViewCell.h" +#import +#import "DatePickerCustomView.h" #define BACKVIEW_ROWH 60 #define ANIM_VIEW_WIDTH_AND_HEIGHT 80 //新 #import "P2PPlayingbackVC.h" @interface IfishP2PPlayBackListViewController () -@property(nonatomic,strong)UITableView *tableView; +@property(nonatomic,strong) IBOutlet UITableView *tableView; @property(retain, nonatomic) NSMutableArray *playbackFiles; @property(retain, nonatomic) NSMutableArray *playbackSize; @property(retain, nonatomic) NSMutableArray *timesData; @@ -26,24 +28,27 @@ @property(retain, nonatomic) NSMutableArray *timesDataMore; @property(nonatomic,strong) CameraNoParyBackVideoView *noDataView; @property(strong, nonatomic) NSString *nextEndDate; -@property (nonatomic) BOOL isloadMore;//是否更多 +@property (nonatomic) BOOL hasSDCard;//是否更多 @property(strong, nonatomic) UIView *movieView; @property (nonatomic) BOOL isInItDevice; //是否连接设备 +@property (nonatomic, strong) DatePickerCustomView *datePickView; +@property (nonatomic, strong) NSDate *startDate; +@property (nonatomic, strong) NSDate *endDate; @end @implementation IfishP2PPlayBackListViewController - (void)viewDidLoad { [super viewDidLoad]; - [[P2PClient sharedClient] setIsClearPlaybackFilesLength:YES];//isClearPlaybackFilesLength - // Do any additional setup after loading the view. - _isloadMore = NO; - _isInItDevice = NO; + + _hasSDCard = NO; + self.playbackFiles = [NSMutableArray arrayWithCapacity:0]; self.playbackSize = [NSMutableArray arrayWithCapacity:0]; self.playbackFilesMore = [NSMutableArray arrayWithCapacity:0]; self.playbackSizeMore = [NSMutableArray arrayWithCapacity:0]; - [self addTitleViewWithTitle:@"回放"]; + [self addTitleViewWithTitle:@"视频回放"]; + [self connectDevice]; [self initUI]; //[[P2PClient sharedClient] setPlaybackDelegate:self]; @@ -53,57 +58,35 @@ -(void)connectDevice{ - //LoginResult *loginResult = [UDManager getLoginInfo]; - //8225账号 - // NSString * P2PVerifyCode1 = @"1528438234"; - // NSString * P2PVerifyCode2 = @"992805759"; - // NSString *UserID = @"-2144354932"; - - UserModel *model=[[DataCenter defaultDtacenter] valueForKey:@"UserLogIn"]; + UserModel *model=[dataContorl getUserInfo]; NSString *userIDName=[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff]; - - //初始化设备 - if (!_isInItDevice) { - NSLog(@"正在初始化设备"); - _isInItDevice = [[P2PClient sharedClient] p2pConnectWithId:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2]; - - // _isInItDevice = [[P2PClient sharedClient] p2pConnectWithId:model.gwellUserID codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2]; - - } - - - if(_isInItDevice){ - - NSLog(@"p2pConnect success. 成功 可以操作设备了"); - //成功 可以操作设备了 - usleep(600000); - [self startMonitor]; - - }else{//new added - NSLog(@"p2pConnect failure.失败,不能操作设备"); - //[self connectDevice]; - return; - } - - -} --(void)startMonitor{ - - if (_isInItDevice) { - NSLog(@"发送呼叫命令"); - - [[P2PClient sharedClient] setIsBCalled:NO]; - [[P2PClient sharedClient] setP2pCallState:P2PCALL_STATUS_CALLING]; - - - [[P2PClient sharedClient] p2pCallWithId:self.camera.cameraId password:self.camera.cameraPass callType:P2PCALL_TYPE_PLAYBACK]; + if ([GWP2PClient sharedClient].linkStatus != P2PLinkStatusOK) { + NSLog(@"正在检查P2P连接状态"); + BOOL connectDevice = [[GWP2PClient sharedClient] connectWithAccount:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2 sessionID1:model.sessionID sessionID2:model.sessionID2 customerIDs:nil]; + if (connectDevice) { + + [[GWP2PClient sharedClient] getDeviceStorageInfomationWithDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { + + if (success) + { + self.hasSDCard=YES; + } + else + { + [self initNoSDDataViewHidden:NO]; + } + }]; + }else{ + NSLog(@"p2pConnect failure.失败,不能操作设备"); + } } } + -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [AppDelegate sharedDefault].canFullScreen = YES; @@ -113,36 +96,16 @@ -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; - //[AppDelegate sharedDefault].canFullScreen = YES; - [[NSNotificationCenter defaultCenter] removeObserver:self name:RECEIVE_REMOTE_MESSAGE object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:@"read_play_false" object:nil]; } -(void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveRemoteMessage:) name:RECEIVE_REMOTE_MESSAGE object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(readPlayFalse:) name:@"read_play_false" object:nil]; - [[P2PClient sharedClient] getSDCardInfoWithId:self.camera.cameraId password:self.camera.cameraPass]; } --(void)readPlayFalse:(NSNotification*)noti{ - /// - dispatch_async(dispatch_get_main_queue(), ^{ - [UIView transitionWithView:self.movieView duration:0.3 options:UIViewAnimationOptionCurveEaseOut - animations:^{ - self.movieView.alpha = 0.3; - } - - completion:^(BOOL finished){ - [self.movieView setHidden:YES]; - [self.view makeToast:NSLocalizedString(@"connection_failed_please_reconnect", nil)]; - } - ]; - }); -} + -(void)goBackAction{ @@ -152,114 +115,7 @@ } -- (void)receiveRemoteMessage:(NSNotification *)notification{ - - NSDictionary *parameter = [notification userInfo]; - int key = [[parameter valueForKey:@"key"] intValue]; - - switch (key) { - case RET_GET_PLAYBACK_FILES: - { - //回放文件名称 - NSArray *array = [NSArray arrayWithArray:(NSArray*)[parameter valueForKey:@"files"]]; - //回放文件的时间记录 - NSArray *times = [NSArray arrayWithArray:(NSArray*)[parameter valueForKey:@"times"]]; - //回放文件的播放时长 - NSArray *sizes = [NSArray arrayWithArray:(NSArray*)[parameter valueForKey:@"sizes"]]; - - - //若不是加载更多时,则往已playbackFiles数组存放回放文件 - //若是加载更多,则往playbackFilesMore的数组添加回放文件 - //若不是加载更多时,则往playbackSize数组存放回放文件的播放时长 - //若是上拉加载更多,则往playbackSizeMore数组末尾添加回放文件的播放时长 - if (_isloadMore) { - - for (NSString *file in array){ - [self.playbackFilesMore addObject:file]; - } - for (NSString *size in sizes){ - [self.playbackSizeMore addObject:size]; - } - //刷新表格 - dispatch_async(dispatch_get_main_queue(), ^{ - [self.tableView reloadData]; - if (self.playbackFilesMore.count < 1) { - //[self.view makeToast:NSLocalizedString(@"no_playback_file", nil)]; - [self.view makeToast:@"没有更多视频"]; - } - }); - self.timesDataMore = [NSMutableArray arrayWithArray:times]; - if (self.timesDataMore.count==0) { - return; - } - - //记录最近1天、3天...已显示文件里最后一个文件的时间(最早文件的时间) - //用于上拉加载时传入的结束时间 - self.nextEndDate = [self.timesDataMore lastObject]; - }else{ - - for (NSString *file in array){ - [self.playbackFiles addObject:file]; - } - for (NSString *size in sizes){ - [self.playbackSize addObject:size]; - } - //刷新表格 - dispatch_async(dispatch_get_main_queue(), ^{ - [self.tableView reloadData]; - if (self.playbackFiles.count < 1) { - //[self.view makeToast:NSLocalizedString(@"no_playback_file", nil)]; - [self initNoVideoDataViewHidden:NO]; - - } - }); - - self.timesData = [NSMutableArray arrayWithArray:times]; - if (self.timesData.count==0) { - return; - } - - //记录最近1天、3天...已显示文件里最后一个文件的时间(最早文件的时间) - //用于上拉加载时传入的结束时间 - self.nextEndDate = [self.timesData lastObject]; - - } - - } - break; - - 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] setCurrentLabel:1]; - [[P2PClient sharedClient] getPlaybackFilesWithId:self.camera.cameraId password:self.camera.cameraPass timeInterval:1]; - [[P2PClient sharedClient] setPlaybackDelegate:self]; - - }else{ - //sd卡不存在, - //[self.view makeToast:NSLocalizedString(@"no_storage", nil)]; - [self initNoSDDataViewHidden:NO]; - - } - }); - - } - break; - - - default: - break; - } - - -} -(void)initNoSDDataViewHidden:(BOOL)hidden @@ -273,7 +129,7 @@ if (!self.noDataView) { - self.noDataView = [[CameraNoParyBackVideoView alloc] initWithFrame:self.view.bounds]; + self.noDataView = [[CameraNoParyBackVideoView alloc] initWithFrame:self.tableView.frame]; [self.view addSubview:self.noDataView]; } @@ -288,7 +144,7 @@ { if (!self.noDataView) { //CGFloat viewH =200; - self.noDataView = [[CameraNoParyBackVideoView alloc] initWithFrame:self.view.bounds]; + self.noDataView = [[CameraNoParyBackVideoView alloc] initWithFrame:self.tableView.frame]; [self.view addSubview:self.noDataView]; } @@ -301,34 +157,90 @@ } -(void)initUI { - - - self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStyleGrouped]; - self.tableView.delegate = self; - self.tableView.dataSource = self; - self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - self.tableView.showsVerticalScrollIndicator = NO; - self.tableView.backgroundColor = RGB(241, 241, 241); - [self.view addSubview:self.tableView]; - - UIView *movieView = [[UIView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT, self.view.frame.size.width, self.view.frame.size.height-NAVIGATION_BAR_HEIGHT)]; - [movieView setBackgroundColor:XBlack_128]; - - UIImageView *animView = [[UIImageView alloc] initWithFrame:CGRectMake((movieView.frame.size.width-ANIM_VIEW_WIDTH_AND_HEIGHT)/2, (movieView.frame.size.height-ANIM_VIEW_WIDTH_AND_HEIGHT)/2, ANIM_VIEW_WIDTH_AND_HEIGHT, ANIM_VIEW_WIDTH_AND_HEIGHT)]; - - NSArray *imagesArray = [NSArray arrayWithObjects:LXImageWithImageName(@"movie1.png"),LXImageWithImageName(@"movie2.png"),LXImageWithImageName(@"movie3.png"),nil]; - - animView.animationImages = imagesArray; - animView.animationDuration = ((CGFloat)[imagesArray count])*100.0f/1000.0f; - animView.animationRepeatCount = 0; - [animView startAnimating]; - [movieView addSubview:animView]; - [movieView setHidden:YES]; - [self.view addSubview:movieView]; - self.movieView = movieView; - - + NSDate *nowDate = [NSDate date]; // 当前时间 + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + formatter.dateFormat = @"yyyy-MM-dd HH:mm"; + NSString *string = [formatter stringFromDate:nowDate]; // + [self.startBtn setTitle:[formatter stringFromDate:[nowDate dateByAddingTimeInterval:-60*60]] forState:UIControlStateNormal]; + [self.endBtn setTitle:string forState:UIControlStateNormal]; + self.startDate=nowDate; + self.startDate=[nowDate dateByAddingTimeInterval:-60*60*2]; } + +- (IBAction)startTimeClick:(UIButton *)sender { + + [self.datePickView removeFromSuperview]; + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier: @"zh_CN"]]; + [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"]; + DatePickerCustomView* dateView = [DatePickerCustomView showInView:self.view Mode:UIDatePickerModeDateAndTime date:[dateFormatter dateFromString:[sender titleForState:UIControlStateNormal]]]; + dateView.datePicker.maximumDate=[NSDate date]; + + self.datePickView=dateView; + WEAK_SELF; + + __weak DatePickerCustomView* weakDateView =dateView; + dateView.dateChanged =^{ + + [sender setTitle:[dateFormatter stringFromDate:weakDateView.datePicker.date] forState:UIControlStateNormal]; + weakSelf.startDate=weakDateView.datePicker.date; + + }; + dateView.cancelBlock = ^{ + + }; +} +- (IBAction)endTimeClick:(UIButton *)sender { + + [self.datePickView removeFromSuperview]; + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier: @"zh_CN"]]; + [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"]; + DatePickerCustomView* dateView = [DatePickerCustomView showInView:self.view Mode:UIDatePickerModeDateAndTime date:[dateFormatter dateFromString:[sender titleForState:UIControlStateNormal]]]; + dateView.datePicker.maximumDate=[NSDate date]; + + self.datePickView=dateView; + + __weak DatePickerCustomView* weakDateView =dateView; + WEAK_SELF; + dateView.dateChanged =^{ + + [sender setTitle:[dateFormatter stringFromDate:weakDateView.datePicker.date] forState:UIControlStateNormal]; + weakSelf.endDate=weakDateView.datePicker.date; + }; + dateView.cancelBlock = ^{ + + }; +} +- (IBAction)searchClick:(UIButton *)sender { + + [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + [[GWP2PClient sharedClient] getDevicePlaybackFilesWithDeviceID:self.camera.cameraId devicePassword:self.camera.cameraPass startDate:self.startDate endDate:self.endDate completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { + [MBProgressHUD hideHUDForView:self.view animated:YES]; + NSLog(@"dataDictionary=%@",dataDictionary); + [self.playbackFiles removeAllObjects]; + if (success&&[dataDictionary[@"error value"] intValue]==0) + { + + NSArray*files=dataDictionary[@"files"]; + if ([files isKindOfClass:[NSArray class]]&&files.count) + { + [self.playbackFiles addObjectsFromArray:files]; + + [self.tableView reloadData]; + } + else + { + [self initNoVideoDataViewHidden:NO]; + } + } + else + { + [self initNoVideoDataViewHidden:NO]; + } + }]; +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. @@ -336,17 +248,12 @@ -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ - return 2; + return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ - if (section ==0) { - - return [self.playbackFiles count]; - } - return [self.playbackFilesMore count]; - + return self.playbackFiles.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ @@ -359,68 +266,15 @@ IfishPlaybackViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IfishPlaybackViewCell"]; + GWPlaybackFileModel*model=[self.playbackFiles objectAtIndex:indexPath.row]; + if (!cell) { cell = [[[NSBundle mainBundle]loadNibNamed:@"IfishPlaybackViewCell" owner:self options:nil]lastObject]; } + cell.model=model; + - //每一分区这里加载不同数据源 - if (indexPath.section ==0) { - if (self.playbackFiles.count!=0) { - - NSString* name = [self.playbackFiles objectAtIndex:indexPath.row]; - - int iSize = 0; - if ([self.playbackFiles count] == [self.playbackSize count]) //查询到了文件长度 - { - NSNumber* number = [self.playbackSize objectAtIndex:indexPath.row]; - iSize = [number intValue]; - } - if (iSize != 0) {//支持返回播放时长 - //cell.videoTime.text = [NSString stringWithFormat:@"%@ (%02d:%02d)", name, iSize/60, iSize%60]; - cell.videoTime.text = [NSString stringWithFormat:@"%@", name]; - cell.videoLongth.text = [NSString stringWithFormat:@"%02d分钟",iSize/60]; - if (iSize<60) { - - cell.videoLongth.text = [NSString stringWithFormat:@"%02d秒钟",iSize%60]; - } - - } - else - { - cell.videoTime.text = [NSString stringWithFormat:@"%@", name]; - cell.videoLongth.text = @"未知"; - } - - } - - }else{ - //更多 - if (self.playbackFilesMore.count !=0) { - - NSString* name = [self.playbackFilesMore objectAtIndex:indexPath.row]; - - int iSize = 0; - if ([self.playbackFilesMore count] == [self.playbackSizeMore count]) //查询到了文件长度 - { - NSNumber* number = [self.playbackSizeMore objectAtIndex:indexPath.row]; - iSize = [number intValue]; - } - if (iSize != 0) {//支持返回播放时长 - //cell.videoTime.text = [NSString stringWithFormat:@"%@ (%02d:%02d)", name, iSize/60, iSize%60]; - cell.videoTime.text = [NSString stringWithFormat:@"%@", name]; - cell.videoLongth.text = [NSString stringWithFormat:@"%02d分钟",iSize/60]; - - } - else - { - cell.videoTime.text = [NSString stringWithFormat:@"%@", name]; - cell.videoLongth.text = @"未知"; - } - - } - - } return cell; @@ -450,122 +304,122 @@ } - --(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ - - if (section==0) { - //描述 + 回放列表 + 今天 + 1 像素线 - return 50 +BACKVIEW_ROWH +BACKVIEW_ROWH + 1; - } - return 0.1; -} - --(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ - - if (section ==1) { - - return BACKVIEW_ROWH; - } - return 0.1; -} --(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ - - CGFloat space = 10; - - if (section ==0) { - - UIView *section0Header =[[UIView alloc] init]; - section0Header.frame = CGRectMake(0, 0, self.view.frame.size.width, 191); - - UILabel *describleLabe=[[UILabel alloc] init]; - describleLabe.frame = CGRectMake(0, 0,self.view.frame.size.width, 50); - describleLabe.textColor =RGB(102, 102, 102); - describleLabe.textAlignment = NSTextAlignmentCenter; - describleLabe.text = @"30分钟录制一次,录像最多存储7日"; - describleLabe.font = [UIFont systemFontOfSize:12]; - describleLabe.backgroundColor = RGB(241, 245, 246); - - [section0Header addSubview:describleLabe]; - - UIView *listLabeBack =[[UIView alloc] init]; - listLabeBack.frame = CGRectMake(0,CGRectGetMaxY(describleLabe.frame), self.view.frame.size.width,BACKVIEW_ROWH); - listLabeBack.backgroundColor = [UIColor whiteColor]; - - [section0Header addSubview:listLabeBack]; - - UILabel *listLabe=[[UILabel alloc] init]; - listLabe.frame = CGRectMake(space,CGRectGetHeight(listLabeBack.frame)/2,200, 20); - listLabe.textColor =RGB(102, 102, 102); - listLabe.font = [UIFont systemFontOfSize:15]; - listLabe.text = @"回放列表"; - [listLabeBack addSubview:listLabe]; - CGFloat listlW = 50; - UILabel *listl=[[UILabel alloc] init]; - listl.frame = CGRectMake(self.view.frame.size.width - space -listlW -4,CGRectGetHeight(listLabeBack.frame)/2,listlW, 20); - listl.textColor =RGB(102, 102, 102); - listl.font = [UIFont systemFontOfSize:14]; - listl.text = @"时长"; - listl.textAlignment = NSTextAlignmentRight; - [listLabeBack addSubview:listl]; - - - //一像素分割线 - UIView *lineView =[[UIView alloc] init]; - lineView.frame = CGRectMake(0, CGRectGetMaxY(listLabeBack.frame), self.view.frame.size.width,1); - lineView.backgroundColor = RGB(241, 241, 241); - [section0Header addSubview:lineView]; - //今天 - UIView *todayLabeBack =[[UIView alloc] init]; - todayLabeBack.frame = CGRectMake(0,CGRectGetMaxY(lineView.frame),self.view.frame.size.width, BACKVIEW_ROWH); - todayLabeBack.backgroundColor = [UIColor whiteColor]; - - [section0Header addSubview:todayLabeBack]; - UILabel *todayLabe=[[UILabel alloc] init]; - todayLabe.frame = CGRectMake(space,0,self.view.frame.size.width, BACKVIEW_ROWH); - todayLabe.textColor =RGB(153, 153, 153); - todayLabe.font = [UIFont systemFontOfSize:14]; - todayLabe.text = @"最近24小时"; - todayLabe.backgroundColor = [UIColor whiteColor]; - //todayLabe.text. - [todayLabeBack addSubview:todayLabe]; - - - - return section0Header; - } - - return nil; - -} - --(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ - CGFloat space = 10; - - if (section ==1) { - //更多 - UIView *moreLabeBack =[[UIView alloc] init]; - moreLabeBack.frame = CGRectMake(0,0,self.view.frame.size.width, BACKVIEW_ROWH); - moreLabeBack.backgroundColor = [UIColor whiteColor]; - UILabel *moreLabe=[[UILabel alloc] init]; - moreLabe.frame = CGRectMake(space,0,self.view.frame.size.width, BACKVIEW_ROWH); - moreLabe.textColor =RGB(153, 153, 153); - moreLabe.font = [UIFont systemFontOfSize:14]; - moreLabe.text = @"查看更多"; - moreLabe.backgroundColor = [UIColor whiteColor]; - [moreLabeBack addSubview:moreLabe]; - moreLabe.userInteractionEnabled = YES; - UITapGestureRecognizer *moreGesture =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreDataRequset)]; - [moreLabe addGestureRecognizer:moreGesture]; - - return moreLabeBack; - - } - return nil; -} +// +//-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ +// +// if (section==0) { +// //描述 + 回放列表 + 今天 + 1 像素线 +// return 50 +BACKVIEW_ROWH +BACKVIEW_ROWH + 1; +// } +// return 0.1; +//} +// +//-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ +// +// if (section ==1) { +// +// return BACKVIEW_ROWH; +// } +// return 0.1; +//} +//-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ +// +// CGFloat space = 10; +// +// if (section ==0) { +// +// UIView *section0Header =[[UIView alloc] init]; +// section0Header.frame = CGRectMake(0, 0, self.view.frame.size.width, 191); +// +// UILabel *describleLabe=[[UILabel alloc] init]; +// describleLabe.frame = CGRectMake(0, 0,self.view.frame.size.width, 50); +// describleLabe.textColor =RGB(102, 102, 102); +// describleLabe.textAlignment = NSTextAlignmentCenter; +// describleLabe.text = @"30分钟录制一次,录像最多存储7日"; +// describleLabe.font = [UIFont systemFontOfSize:12]; +// describleLabe.backgroundColor = RGB(241, 245, 246); +// +// [section0Header addSubview:describleLabe]; +// +// UIView *listLabeBack =[[UIView alloc] init]; +// listLabeBack.frame = CGRectMake(0,CGRectGetMaxY(describleLabe.frame), self.view.frame.size.width,BACKVIEW_ROWH); +// listLabeBack.backgroundColor = [UIColor whiteColor]; +// +// [section0Header addSubview:listLabeBack]; +// +// UILabel *listLabe=[[UILabel alloc] init]; +// listLabe.frame = CGRectMake(space,CGRectGetHeight(listLabeBack.frame)/2,200, 20); +// listLabe.textColor =RGB(102, 102, 102); +// listLabe.font = [UIFont systemFontOfSize:15]; +// listLabe.text = @"回放列表"; +// [listLabeBack addSubview:listLabe]; +// CGFloat listlW = 50; +// UILabel *listl=[[UILabel alloc] init]; +// listl.frame = CGRectMake(self.view.frame.size.width - space -listlW -4,CGRectGetHeight(listLabeBack.frame)/2,listlW, 20); +// listl.textColor =RGB(102, 102, 102); +// listl.font = [UIFont systemFontOfSize:14]; +// listl.text = @"时长"; +// listl.textAlignment = NSTextAlignmentRight; +// [listLabeBack addSubview:listl]; +// +// +// //一像素分割线 +// UIView *lineView =[[UIView alloc] init]; +// lineView.frame = CGRectMake(0, CGRectGetMaxY(listLabeBack.frame), self.view.frame.size.width,1); +// lineView.backgroundColor = RGB(241, 241, 241); +// [section0Header addSubview:lineView]; +// //今天 +// UIView *todayLabeBack =[[UIView alloc] init]; +// todayLabeBack.frame = CGRectMake(0,CGRectGetMaxY(lineView.frame),self.view.frame.size.width, BACKVIEW_ROWH); +// todayLabeBack.backgroundColor = [UIColor whiteColor]; +// +// [section0Header addSubview:todayLabeBack]; +// UILabel *todayLabe=[[UILabel alloc] init]; +// todayLabe.frame = CGRectMake(space,0,self.view.frame.size.width, BACKVIEW_ROWH); +// todayLabe.textColor =RGB(153, 153, 153); +// todayLabe.font = [UIFont systemFontOfSize:14]; +// todayLabe.text = @"最近24小时"; +// todayLabe.backgroundColor = [UIColor whiteColor]; +// //todayLabe.text. +// [todayLabeBack addSubview:todayLabe]; +// +// +// +// return section0Header; +// } +// +// return nil; +// +//} +// +//-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ +// CGFloat space = 10; +// +// if (section ==1) { +// //更多 +// UIView *moreLabeBack =[[UIView alloc] init]; +// moreLabeBack.frame = CGRectMake(0,0,self.view.frame.size.width, BACKVIEW_ROWH); +// moreLabeBack.backgroundColor = [UIColor whiteColor]; +// UILabel *moreLabe=[[UILabel alloc] init]; +// moreLabe.frame = CGRectMake(space,0,self.view.frame.size.width, BACKVIEW_ROWH); +// moreLabe.textColor =RGB(153, 153, 153); +// moreLabe.font = [UIFont systemFontOfSize:14]; +// moreLabe.text = @"查看更多"; +// moreLabe.backgroundColor = [UIColor whiteColor]; +// [moreLabeBack addSubview:moreLabe]; +// moreLabe.userInteractionEnabled = YES; +// UITapGestureRecognizer *moreGesture =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(moreDataRequset)]; +// [moreLabe addGestureRecognizer:moreGesture]; +// +// return moreLabeBack; +// +// } +// return nil; +//} #pragma mark - moreDataRequset -(void)moreDataRequset{ - _isloadMore =YES; + // //today NSDate *nowDate = [NSDate date]; NSInteger interval =31; diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.xib b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.xib new file mode 100644 index 0000000..594f1a4 --- /dev/null +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishP2PPlayBackListViewController.xib @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.h b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.h index df189b2..0012375 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.h +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.h @@ -7,11 +7,12 @@ // #import +#import @interface IfishPlaybackViewCell : UITableViewCell -@property (weak, nonatomic) IBOutlet UIImageView *palybackVideo; - -@property (weak, nonatomic) IBOutlet UILabel *videoLongth; -@property (weak, nonatomic) IBOutlet UILabel *videoTime; +@property (weak, nonatomic) IBOutlet UIImageView *playImageView; +@property (weak, nonatomic) IBOutlet UILabel *startTimeLabel; +@property (weak, nonatomic) IBOutlet UILabel *endTimeLabel; +@property (nonatomic, strong) GWPlaybackFileModel *model; @end diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.m index a2f5fb7..411aa3c 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.m @@ -13,7 +13,7 @@ - (void)awakeFromNib { [super awakeFromNib]; // Initialization code - self.palybackVideo.image = LXImageWithImageName(@"playback_iocn_video"); + self.playImageView.image = LXImageWithImageName(@"playback_iocn_video"); } @@ -22,5 +22,35 @@ // Configure the view for the selected state } +-(void)setModel:(GWPlaybackFileModel *)model +{ + _model=model; + + NSString*start=[NSString stringWithFormat:@"%ld%02ld%02ld%02ld%02ld",model.year,model.month,model.day,model.hour,model.minute]; + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + formatter.dateFormat = @"yyyyMMddHHmm"; + NSDate*date=[formatter dateFromString:start]; + + NSString*end=[NSString stringWithFormat:@"%ld%02ld%02ld%02ld%02ld",model.year,model.month,model.day,model.hour,model.minute]; + if (date) + { + if ([model.cType isEqualToString:@"S"]) + { + date=[date dateByAddingTimeInterval:model.time]; + } + else + { + date=[date dateByAddingTimeInterval:model.time*60]; + } + end=[formatter stringFromDate:date]; + } + else + { + + } + self.startTimeLabel.text=start; + self.endTimeLabel.text=end; + NSLog(@"date =%@ time=%ld",model.date,model.time); +} @end diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.xib b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.xib index e7cb869..4bc54b0 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.xib +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/IfishPlaybackViewCell.xib @@ -1,60 +1,78 @@ - - - - - + + + - + + - + - - + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishcameraBottomHView/CameraRecordViewController.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishcameraBottomHView/CameraRecordViewController.m index e2852f6..97ff62e 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishcameraBottomHView/CameraRecordViewController.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishcameraBottomHView/CameraRecordViewController.m @@ -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 *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 *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 *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 diff --git a/Ifish/models/ifishUserModel/TemperatureSetModel.h b/Ifish/models/ifishUserModel/TemperatureSetModel.h index 56544c1..96f7339 100644 --- a/Ifish/models/ifishUserModel/TemperatureSetModel.h +++ b/Ifish/models/ifishUserModel/TemperatureSetModel.h @@ -11,5 +11,5 @@ @interface TemperatureSetModel : NSObject @property(nonatomic,copy)NSString*title; @property(nonatomic,copy)NSString*temperatureLabel; -//@property(nonatomic); +@property(nonatomic,copy)NSString*status;//开关状态,新增 @end diff --git a/Ifish/views/mypicView/DatePickerCustomView.h b/Ifish/views/mypicView/DatePickerCustomView.h new file mode 100644 index 0000000..d63e15b --- /dev/null +++ b/Ifish/views/mypicView/DatePickerCustomView.h @@ -0,0 +1,16 @@ +// +// DatePickerCustomView.h +// E-Mobile +// +// Created by Yang on 15/9/18. +// +// + +#import + +@interface DatePickerCustomView : UIView +@property(nonatomic,copy)dispatch_block_t dateChanged; +@property(nonatomic,copy)dispatch_block_t cancelBlock; +@property(nonatomic,strong)UIDatePicker* datePicker; ++(instancetype)showInView:(UIView*)view Mode:(UIDatePickerMode)mode date:(NSDate*)date; +@end diff --git a/Ifish/views/mypicView/DatePickerCustomView.m b/Ifish/views/mypicView/DatePickerCustomView.m new file mode 100644 index 0000000..0c910fe --- /dev/null +++ b/Ifish/views/mypicView/DatePickerCustomView.m @@ -0,0 +1,114 @@ +// +// DatePickerCustomView.m +// E-Mobile +// +// Created by Yang on 15/9/18. +// +// +#import "DatePickerCustomView.h" + +@interface DatePickerCustomView(){ + +} +@property(nonatomic,strong)UIButton* timePickerCancelBtn; +@property(nonatomic,strong)UIView* buttonView; +@end + +@implementation DatePickerCustomView + ++(instancetype)showInView:(UIView*)view Mode:(UIDatePickerMode)mode date:(NSDate*)date +{ + DatePickerCustomView* customView = [[self alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, view.frame.size.height)]; + if (customView) { + customView.backgroundColor=RGBA(0, 0, 0, 0.3); + + UIButton* timePickerCancelBtn = [UIButton buttonWithType:UIButtonTypeCustom]; + customView.timePickerCancelBtn = timePickerCancelBtn; + timePickerCancelBtn.tag = 100; + timePickerCancelBtn.frame = customView.bounds; + [timePickerCancelBtn addTarget:customView action:@selector(datePickerCancelBtnPressed:) forControlEvents:UIControlEventTouchUpInside]; + [customView addSubview:timePickerCancelBtn]; + + UIDatePicker* datePicker = [[UIDatePicker alloc] initWithFrame: CGRectMake(0, customView.frame.size.height+40, customView.frame.size.width, 216)]; + customView.datePicker = datePicker; + [datePicker setLocale:[NSLocale autoupdatingCurrentLocale]]; + [datePicker setDatePickerMode:mode]; + datePicker.backgroundColor=[UIColor whiteColor]; + datePicker.tag = 101; + if (date) { + [datePicker setDate:date]; + } +// [datePicker addTarget:customView action:@selector(datePickerChanged:) forControlEvents:UIControlEventValueChanged]; + [customView addSubview:datePicker]; + + UIView *buttonView = [[UIView alloc] initWithFrame:CGRectMake(0, customView.frame.size.height, customView.frame.size.width, 40)]; + customView.buttonView = buttonView; + buttonView.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1]; + [customView addSubview:buttonView]; + + UIButton *cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 40)]; + [cancelBtn addTarget:customView action:@selector(datePickerCancelBtnPressed:) forControlEvents:UIControlEventTouchUpInside]; + [cancelBtn setTitle:NSLocalizedString(@"取消", nil) forState:UIControlStateNormal]; + [cancelBtn setTitle:NSLocalizedString(@"取消", nil) forState:UIControlStateSelected]; + cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15]; + [cancelBtn setTitleColor:[UIColor colorWithRed:21.0/255 green:126.0/255 blue:251.0/255 alpha:1] forState:UIControlStateNormal]; + [cancelBtn setTitleColor:[UIColor colorWithRed:21.0/255 green:126.0/255 blue:251.0/255 alpha:1] forState:UIControlStateSelected]; + [buttonView addSubview:cancelBtn]; + + UIButton *commitBtn = [[UIButton alloc] initWithFrame:CGRectMake(customView.frame.size.width-60, 0, 60, 40)]; + [commitBtn addTarget:customView action:@selector(datePickerCommitBtnPressed:) forControlEvents:UIControlEventTouchUpInside]; + [commitBtn setTitle:NSLocalizedString(@"确定", nil) forState:UIControlStateNormal]; + [commitBtn setTitle:NSLocalizedString(@"确定", nil) forState:UIControlStateSelected]; + commitBtn.titleLabel.font = [UIFont systemFontOfSize:15]; + [commitBtn setTitleColor:[UIColor colorWithRed:21.0/255 green:126.0/255 blue:251.0/255 alpha:1] forState:UIControlStateNormal]; + [commitBtn setTitleColor:[UIColor colorWithRed:21.0/255 green:126.0/255 blue:251.0/255 alpha:1] forState:UIControlStateSelected]; + [buttonView addSubview:commitBtn]; + + [customView showDatePickerInView:view]; + } + return customView; +} + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + /*init code*/ + } + return self; +} + +-(void)datePickerCancelBtnPressed:(UIButton*)btn{ + [UIView animateWithDuration:0.2 animations:^{ + self.datePicker.frame = CGRectMake(0, self.frame.size.height+40, self.frame.size.width, 216); + self.buttonView.frame = CGRectMake(0, self.frame.size.height, self.frame.size.width, 40); + }completion:^(BOOL finished) { + if (self.cancelBlock) { + self.cancelBlock(); + } + [self removeFromSuperview]; + }]; +} + +-(void)datePickerCommitBtnPressed:(UIButton*)btn { + [UIView animateWithDuration:0.2 animations:^{ + self.datePicker.frame = CGRectMake(0, self.frame.size.height+40, self.frame.size.width, 216); + self.buttonView.frame = CGRectMake(0, self.frame.size.height, self.frame.size.width, 40); + }completion:^(BOOL finished) { + self.dateChanged(); + [self removeFromSuperview]; + }]; +} + +-(void)showDatePickerInView:(UIView*)view{ + [view addSubview:self]; + [UIView animateWithDuration:0.2 animations:^{ + self.datePicker.frame = CGRectMake(0, self.frame.size.height-216, self.frame.size.width, 216); + self.buttonView.frame = CGRectMake(0, self.frame.size.height-216-40, self.frame.size.width, 40); + }]; +} + +-(void)datePickerChanged:(id)sender{ + self.dateChanged(); +} +@end