ThingsDetailViewController.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. //
  2. // ThingsDetailViewController.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 3/16/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "RequestHandler.h"
  9. #import "DeviceModel.h"
  10. #import "CustomImageView.h"
  11. #import "CustomLabel.h"
  12. #import "CustomTextField.h"
  13. #import "CustomButton.h"
  14. #import "UIImageView+WebCache.h"
  15. #import "CustomTableView.h"
  16. #import "ChangeDeviceNamePopupView.h"
  17. #import "ValidateUtil.h"
  18. #import "CommandClassControlDetailView.h"
  19. #import "ThingsViewController.h"
  20. #import "ThingsDetailViewController.h"
  21. #import "ModifyDeviceNamePopupView.h"
  22. #import "JYPullToRefreshController.h"
  23. #import "ThingsForcedDelViewController.h"
  24. #import "ThingsGeneralDelViewController.h"
  25. /**
  26. Hub 명 Text Color : kUITextColor03
  27. Update 알람 Text Color : kUITextColor04
  28. Device 상태 표시 Text Color
  29. - 꺼짐 : kUITextColor01
  30. - 켜짐 : kUITextColor02
  31. - 잠김 : kUITextColor02
  32. - 열림 : kUITextColor01
  33. 도어센서 마지막 동작 Text Color : kUITextColor01
  34. 도어센서 상태표시 Text Color
  35. - 열림 : kUITextColor02
  36. - 닫힘 : kUITextColor01
  37. Offline Text Color : kUITextColor01
  38. 노드명 표시 Text Color : kUITextColor03
  39. value 표시 Text Color : kUITextColor04
  40. (이미지 명)
  41. 플러그 on : img_things_detail_06_01_plug_state_on
  42. 플러그 off : img_things_detail_06_01_plug_state_off
  43. 밸브 on : img_things_detail_05_02_valve_state_locked
  44. 밸브 off : img_things_detail_05_02_valve_state_unlocked
  45. 도어센서 on : img_things_detail_01_02_sensor_door_open
  46. 도어센서 off : img_things_detail_01_02_sensor_door_close
  47. 장치 열림,켜짐 : img_things_detail_06_99_btn_off ,~off_press
  48. 장치 닫힘,꺼짐 : img_things_detail_06_99_btn_on ,~on_press
  49. **/
  50. @implementation ThingsDetailTitleTableViewCell
  51. @end
  52. @implementation ThingsDetailControlTableViewCell
  53. - (void)awakeFromNib {
  54. _controlContainer.pagingEnabled = YES;
  55. _controlContainer.scrollEnabled = NO;
  56. _pageControl.hidden = YES;
  57. }
  58. @end
  59. @implementation ThingsDetailOptionTableViewCell
  60. @end
  61. @implementation ThingsDetailDeviceIdTableViewCell
  62. @end
  63. @interface ThingsDetailViewController () <UITableViewDataSource, UITableViewDelegate ,changeDeviceNameDelegate> {
  64. DeviceDetailModel *_deviceDetail;
  65. // ModifyDeviceNamePopupView *_mpopup;
  66. NSArray<NodeModel> *_mandatoryNodes, *_optionalNodes;
  67. UIPageControl *_pageControl;
  68. NSTimer *_deviceBackgroundTimer;
  69. }
  70. @property (strong, nonatomic) JYPullToRefreshController *refreshController;
  71. @end
  72. #pragma mark - Class Definition
  73. @implementation ThingsDetailViewController
  74. - (void)viewDidLoad {
  75. [super viewDidLoad];
  76. // Do any additional setup after loading the view.
  77. [self initUI];
  78. [self prepareViewDidLoad];
  79. }
  80. - (void)initUI {
  81. //initialize tableView
  82. [self initTableViewAsDefaultStyle:_tableView];
  83. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 30.0f)];
  84. // [self setThingsDetailPopoverOptions];
  85. [self initRefreshController];
  86. [self setMoreBtnArray];
  87. }
  88. - (void)initRefreshController {
  89. //set refresh controls
  90. __weak typeof(self) weakSelf = self;
  91. self.refreshController = [[JYPullToRefreshController alloc] initWithScrollView:self.tableView];
  92. self.refreshController.pullToRefreshHandleAction = ^{
  93. [weakSelf requestDeviceDetail:@YES];
  94. };
  95. }
  96. //- (void)setThingsDetailPopoverOptions {
  97. // //set Popover Contents
  98. // __weak typeof(self) weakSelf = self;
  99. // _popooverOptionArray = [[NSMutableArray alloc] init];
  100. //
  101. // [_popooverOptionArray addObject:@{@"menuName" : NSLocalizedString(@"새로 고침",nil),
  102. // @"iconName": @"img_bg_morepopup_icon_refresh",
  103. // @"target": weakSelf,
  104. // @"selector": [NSValue valueWithPointer:@selector(requestDeviceDetail:)]}];
  105. //
  106. // if ([JDFacade facade].loginUser.level > 10) {
  107. // [_popooverOptionArray addObject:@{@"menuName" : NSLocalizedString(@"이름 변경", @"이름 변경"),
  108. // @"iconName": @"img_bg_morepopup_icon_edit",
  109. // @"target": weakSelf,
  110. // @"selector": [NSValue valueWithPointer:@selector(modifyDeviceName)]}];
  111. //
  112. // }
  113. //}
  114. - (void)prepareViewDidLoad {
  115. [self requestDeviceDetail:@YES];
  116. }
  117. //- (void)modifyDeviceName {
  118. //
  119. // _mpopup = [[ModifyDeviceNamePopupView alloc] initFromNib];
  120. // _mpopup.txtDeviceName.text = _deviceDetail.deviceName;
  121. //
  122. // [_mpopup showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  123. // if (buttonIndex == 0) {//OK
  124. // [self requestDeviceUpdate];
  125. // }
  126. // }];
  127. //}
  128. - (void)changeDeviceName:(NSString *)deviceName {
  129. [self requestDeviceDetail:@YES];
  130. _lblTitle.text = [deviceName isEqualToString:@""] ? _deviceDetail.prdName : deviceName;
  131. }
  132. - (void)updateTitle {
  133. [self setMoreBtnArray];
  134. if ([_deviceDetail.prdName isEqualToString:_deviceDetail.prdUserName] || [_deviceDetail.prdUserName isEqualToString:@""]) {
  135. _lblTitle.text = _deviceDetail.prdName;
  136. } else {
  137. _lblTitle.text = _deviceDetail.prdUserName;
  138. }
  139. _btnUpdate.hidden = !_deviceDetail.isProfileUpdate;
  140. if (![JDFacade facade].loginUser.isHomehubOnline) {
  141. _lblTitle.text = @"홈허브 오프라인";
  142. [_lblTitle setColor:kUITextColor01 text:_lblTitle.text];
  143. return;
  144. }
  145. if (_deviceDetail && !_deviceDetail.isOnline) {
  146. _lblTitle.text = @"장치 상태를 확인하세요";
  147. [_lblTitle setColor:kUITextColor02 text:_lblTitle.text];
  148. return;
  149. }
  150. }
  151. -(NSString *)getDeviceDetailUrl
  152. {
  153. NSMutableArray *arr = [NSMutableArray array];
  154. arr[0] = _refDevice.deviceId;
  155. arr[1] = _refDevice.nodeId;
  156. return [[JDFacade facade] getUrlWithCustAndGroupID:API_GET_NODE_DETAIL arguments:arr];
  157. }
  158. #pragma mark - Main Logic
  159. - (void)requestDeviceDetail:(id)arg {
  160. BOOL showLoadingView = NO;
  161. if (arg) {
  162. showLoadingView = [arg isKindOfClass:[NSTimer class]] ? [((NSTimer *)arg).userInfo boolValue] : [arg boolValue];
  163. }
  164. NSString *path = [NSString stringWithFormat:[self getDeviceDetailUrl], _refDevice.deviceId];
  165. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestGET parameters:nil
  166. modelClass:[DeviceDetailModel class] showLoadingView:showLoadingView completion:^(id responseObject) {
  167. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  168. return;
  169. }
  170. _deviceDetail = (DeviceDetailModel *)responseObject;
  171. NSLog(@"Device Detail : %@", _deviceDetail);
  172. if (_deviceDetail) {//API 성공 ,
  173. [self setDeviceContents];
  174. [self requestPollingDeviceStatusInBackground];
  175. }
  176. //refresh controller
  177. if (self.refreshController && self.refreshController.refreshState == JYRefreshStateLoading) {
  178. [self.refreshController stopRefreshWithAnimated:YES completion:nil];
  179. }
  180. } failure:^(id errorObject) {
  181. [self releaseDeviceTimer];
  182. JDErrorModel *error = (JDErrorModel *)errorObject;
  183. [[JDFacade facade] alert:error.errorMessage];
  184. }];
  185. }
  186. //디바이스 상태를 3초마다 갱신함.
  187. - (void)requestPollingDeviceStatusInBackground {
  188. //schedul timer.
  189. // if (!_deviceBackgroundTimer) {
  190. // _deviceBackgroundTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(requestDeviceDetail:) userInfo:@NO repeats:YES];
  191. // }
  192. }
  193. - (void)setDeviceContents {
  194. [self updateTitle];
  195. _mandatoryNodes = (NSArray<NodeModel> *)[_deviceDetail.cmdclsList filteredArrayUsingPredicateFormat:@"cmdclsMandatoryYn == %@", @"Y"];
  196. _optionalNodes = (NSArray<NodeModel> *)[_deviceDetail.cmdclsList filteredArrayUsingPredicateFormat:@"cmdclsMandatoryYn == %@", @"N"];
  197. [_tableView reloadData];
  198. }
  199. //- (void)requestDeviceUpdate {
  200. // //parameters
  201. // NSDictionary *parameter = @{@"device_name": _mpopup.txtDeviceName.text};
  202. //
  203. // NSString *path = [NSString stringWithFormat:API_GET_DEVICE_UPDATE, _deviceDetail.deviceId];
  204. //
  205. // [[RequestHandler handler] sendAsyncPostRequestAPIPath:path parameters:parameter modelClass:[JDJSONModel class] completion:^(id responseObject) {
  206. //
  207. // _refDevice.deviceName = _deviceDetail.deviceName = _mpopup.txtDeviceName.text;
  208. // [_tableView reloadData];
  209. //
  210. // //리스트를 다시 로드함.
  211. // ThingsViewController *vc = [[JDFacade facade] viewControllerOnNaviationController:[ThingsViewController class]];
  212. // [vc.collectionView reloadData];
  213. //
  214. // } failure:^(id errorObject) {
  215. // JDErrorModel *error = (JDErrorModel *)errorObject;
  216. // [[JDFacade facade] alert:error.errorMessage];
  217. // }];
  218. //}
  219. - (void)requestDeleteDevice {
  220. //parameters
  221. NSString *path = [NSString stringWithFormat:API_DELETE_DEVICE, _deviceDetail.deviceId];
  222. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  223. [[JDFacade facade] toast:NSLocalizedString(@"장치가 삭제되었습니다", @"장치가 삭제되었습니다")];
  224. // if ([JDFacade facade].loginHomeGroup.deviceId && ![[JDFacade facade].loginHomeGroup.deviceId isEmptyString]) {
  225. // if ([[JDFacade facade].loginHomeGroup.deviceId isEqualToString:_deviceDetail.deviceId]) {//현재 홈의 스마튼폰일 경우,
  226. // [JDFacade facade].loginHomeGroup.deviceId = nil;
  227. // [JDFacade facade].loginHomeGroup.deviceAuthorization = nil;
  228. // [JDFacade facade].loginHomeGroup.deviceKey = nil;
  229. // }
  230. // }
  231. //리스트를 다시 로드함.
  232. ThingsViewController *vc = [[JDFacade facade] viewControllerOnNaviationController:[ThingsViewController class]];
  233. [vc prepareViewDidLoad];
  234. [self.navigationController popToRootViewControllerAnimated:YES];
  235. } failure:^(id errorObject) {
  236. JDErrorModel *error = (JDErrorModel *)errorObject;
  237. [[JDFacade facade] alert:error.errorMessage];
  238. }];
  239. }
  240. #pragma mark - UITableView DataSource & Delegate
  241. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  242. return 4;
  243. }
  244. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  245. NSInteger count = 1;
  246. if (section == 1) {
  247. count = _deviceDetail && _deviceDetail.cmdclsList && _deviceDetail.cmdclsList.count > 0;
  248. } else if (section == 2) {//optional nodes
  249. count = _optionalNodes.count; //두번째 이후부터 옵셔널 노드임.
  250. }
  251. return count;
  252. }
  253. - (CGFloat)heightForMandatoryNode {
  254. CGFloat height = 0;
  255. NodeModel *node = _deviceDetail.cmdclsList.firstObject;
  256. if (node.cmdclsType == CmdClsTypeSwitchBinary || node.cmdclsType == CmdClsTypeValve) {
  257. height = 347.0f; //275 || 347
  258. } else {
  259. height = 275.0f;
  260. }
  261. height += _mandatoryNodes.count > 1 ? 75 : 0;
  262. return height;
  263. }
  264. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  265. CGFloat height = 86;
  266. NSInteger section = indexPath.section;
  267. if (section == 0) {
  268. height = 68;
  269. } else if (section == 1) {
  270. // height = [self heightForMandatoryNode] + 35.0f;
  271. height = 322;
  272. } else if (section == 2) {
  273. height = 63;
  274. // if (indexPath.row == _deviceDetail.nodes.count - 2) {
  275. // height += 35;
  276. // }
  277. } else if (section == 3) {
  278. height = 89;
  279. }
  280. return height;
  281. }
  282. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  283. UITableViewCell *cell = nil;
  284. NSInteger section = indexPath.section;
  285. if (section == 0) {//title
  286. ThingsDetailTitleTableViewCell *tcell = (ThingsDetailTitleTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"TitleCellIdentifier"];
  287. // [tcell.imgvDevice sd_setImageWithURL:[NSURL URLWithString:_deviceDetail.imageFileName] placeholderImage:nil options:SDWebImageRefreshCached];
  288. tcell.lblDeviceUpdate.hidden = !_deviceDetail.isProfileUpdate;
  289. cell = tcell;
  290. } else if (section == 1) {//device control
  291. ThingsDetailControlTableViewCell *tcell = (ThingsDetailControlTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"ControlCellIdentifier"];
  292. //뷰를 초기화함.
  293. [[tcell.controlContainer subviews] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
  294. UIView *subview = (UIView *)obj;
  295. [subview removeFromSuperview];
  296. }];
  297. if (_deviceDetail) {
  298. tcell.controlContainer.scrollEnabled = _mandatoryNodes.count > 1;
  299. tcell.controlContainer.contentSize = CGSizeMake(IPHONE_WIDTH * _mandatoryNodes.count, [self heightForMandatoryNode]);
  300. tcell.controlContainer.showsHorizontalScrollIndicator = NO;
  301. if (tcell.controlContainer.scrollEnabled) {
  302. tcell.controlContainer.delegate = self;
  303. }
  304. tcell.pageControl.hidden = !tcell.controlContainer.scrollEnabled;
  305. if (!tcell.pageControl.hidden && !_pageControl) {
  306. _pageControl = tcell.pageControl;
  307. _pageControl.numberOfPages = _mandatoryNodes.count;
  308. }
  309. __block CGFloat width = 0;
  310. for (NodeModel *node in _mandatoryNodes) {
  311. node.refDevice = _refDevice;
  312. CommandClassControlView *controlView = [CommandClassControlDetailView viewForCommandClass:node.cmdclsType];
  313. node.deviceId = _deviceDetail.deviceId;
  314. node.nodeId = _deviceDetail.nodeId;
  315. controlView.node = node;
  316. controlView.isMandatoryNode = [node.cmdclsMandatoryYn boolValue] && _mandatoryNodes.count > 1;
  317. tcell.controlContainer.hidden = !controlView;
  318. if (!tcell.controlContainer.hidden) {
  319. controlView.x = width;
  320. UIView *superview = tcell.controlContainer;
  321. [superview addSubview:controlView];
  322. [controlView mas_makeConstraints:^(MASConstraintMaker *make) {
  323. make.size.mas_equalTo(controlView.frame.size);
  324. make.leading.equalTo(superview).offset(width);
  325. // make.trailing.equalTo(superview).offset(width+IPHONE_WIDTH);
  326. width += IPHONE_WIDTH;
  327. }];
  328. }
  329. }
  330. }
  331. cell = tcell;
  332. } else if (section == 2) {//option control
  333. ThingsDetailOptionTableViewCell *tcell = (ThingsDetailOptionTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"OptionCellIdentifier"];
  334. NodeModel *node = _deviceDetail.cmdclsList[indexPath.row + _mandatoryNodes.count];
  335. tcell.lblNodeName.text = node.cmdclsName;
  336. tcell.lblNodeValue.text = node.contentValueMsg;
  337. cell = tcell;
  338. } else if (section == 3){ // Device Id
  339. ThingsDetailDeviceIdTableViewCell *tcell = (ThingsDetailDeviceIdTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"DeviceIdCellIdentifier"];
  340. tcell.lblDeviceName.text = _deviceDetail.deviceModelId;
  341. tcell.lblDeviceId.text = _deviceDetail.deviceId;
  342. cell = tcell;
  343. }
  344. return cell;
  345. }
  346. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  347. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  348. }
  349. - (void)setMoreBtnArray {
  350. _moreBtnArray = [NSMutableArray array];
  351. if (![[JDFacade facade].loginUser hasHomeHub]) {
  352. [_btnOption setHidden:YES];
  353. }
  354. if([[JDFacade facade].loginUser.gradeCode isEqualToString:KNEET_MEMBER_MASTER]) {
  355. for (int i = 0; i < 3; i++) {
  356. MoreBtnModel *btnModel;
  357. switch (i) {
  358. case 0:
  359. btnModel = [[MoreBtnModel alloc] initWithTyep:NameChange isEnable:YES];
  360. break;
  361. case 1:
  362. btnModel = [[MoreBtnModel alloc] initWithTyep:Del isEnable:YES];
  363. break;
  364. case 2:
  365. btnModel = [[MoreBtnModel alloc] initWithTyep:Refresh isEnable:YES];
  366. break;
  367. default:
  368. break;
  369. }
  370. [_moreBtnArray addObject:btnModel];
  371. }
  372. } else {
  373. MoreBtnModel *btnModel = [[MoreBtnModel alloc] initWithTyep:Refresh isEnable:YES];
  374. [_moreBtnArray addObject:btnModel];
  375. }
  376. }
  377. -(void)deleteDevice
  378. {
  379. // DeviceModel *device =_deviceList[indexPath.row];
  380. if ([_deviceDetail.onlineState isEquestToIgnoreCase:@"OFF"]) {
  381. ThingsForcedDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsForcedDelViewController" storyboardName:@"Things"];
  382. vc.delDevice = _deviceDetail;
  383. [self showTransparencyModalView:vc removeSelf:NO];
  384. } else {
  385. ThingsGeneralDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsGeneralDelViewController" storyboardName:@"Things"];
  386. vc.delDevice = _deviceDetail;
  387. [self showTransparencyModalView:vc removeSelf:NO];
  388. }
  389. }
  390. #pragma mark - MoreButtonDelegate
  391. -(void)moreBtnAction:(id)sender
  392. {
  393. NSInteger tag = [(UIButton *)sender tag];
  394. NSLog(@"MoreBtn Action : %li", (long)tag);
  395. switch (tag) {
  396. case NameChange:
  397. {
  398. ChangeDeviceNamePopupView *popup = [[ChangeDeviceNamePopupView alloc]initFromNib:_deviceDetail];
  399. popup.deviceDetailModel = _deviceDetail;
  400. popup.delegate = self;
  401. [popup show];
  402. }
  403. break;
  404. case Del:
  405. {
  406. NSLog(@"장치 삭제");
  407. }
  408. break;
  409. case Refresh:
  410. {
  411. [self requestDeviceDetail:@YES];
  412. }
  413. break;
  414. default:
  415. break;
  416. }
  417. }
  418. #pragma mark - UI Events
  419. - (IBAction)btnOptionTouched:(id)sender {
  420. // [self toggleOptions:sender];
  421. [self toggleOptionsWithArray:sender btnArray:_moreBtnArray];
  422. }
  423. - (IBAction)btnUpdateTouched:(id)sender {
  424. NSLog(@"업데이트");
  425. }
  426. - (IBAction)btnCloseTouched:(id)sender {
  427. [[JDFacade facade] dismissModalStack:YES completion:nil];
  428. }
  429. #pragma mark - ScrollView Delegate
  430. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  431. CGFloat pageWidth = scrollView.frame.size.width; // you need to have a **iVar** with getter for scrollView
  432. CGFloat fractionalPage = scrollView.contentOffset.x / pageWidth;
  433. NSInteger page = lround(fractionalPage);
  434. _pageControl.currentPage = page; // you need to have a **iVar** with getter for pageControl
  435. }
  436. -(void) receiveSocketData:(NSNotification *)notification {
  437. SocketModel *result = [[SocketModel alloc] initWithDictionary:notification.object error:nil];
  438. // CommandModel *response = [[CommandModel alloc] initWithDictionary:notification.object error:nil];
  439. NSLog(@"Result : %@", result);
  440. if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_CONTENT]) {
  441. ContentModel *response = [[ContentModel alloc] initWithDictionary:notification.object error:nil];
  442. NSLog(@"Response : %@", response);
  443. // [weakSelf requestDeviceDetail:@YES];
  444. if ([_refDevice.deviceId isEqualToString:response.deviceId] && [_refDevice.nodeId isEqualToString:response.nodeId]) {
  445. [self requestDeviceDetail:@NO];
  446. }
  447. }
  448. // else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_COMMAND_RES]) {
  449. //
  450. // }
  451. // else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_REGIST_RES] || [result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_DELETE_RES]) {
  452. // [self refreshDeviceList];
  453. // }
  454. }
  455. -(void)finishDeviveDelete
  456. {
  457. [self btnCloseTouched:nil];
  458. }
  459. #pragma mark - MemoryWarning
  460. - (void)releaseDeviceTimer {
  461. if (_deviceBackgroundTimer) {
  462. [_deviceBackgroundTimer invalidate];
  463. _deviceBackgroundTimer = nil;
  464. }
  465. }
  466. - (void)viewWillDisappear:(BOOL)animated {
  467. [self releaseDeviceTimer];
  468. }
  469. - (void)didReceiveMemoryWarning
  470. {
  471. [super didReceiveMemoryWarning];
  472. // Dispose of any resources that can be recreated.
  473. }
  474. @end