HomeHubViewController.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. //
  2. // HomeHubViewController.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 10/28/15.
  6. // Copyright © 2015 ntels. All rights reserved.
  7. //
  8. #import "HomeHubViewController.h"
  9. #import "RequestHandler.h"
  10. #import "DeviceModel.h"
  11. #import "CustomTableView.h"
  12. #import "CustomButton.h"
  13. #import "Reachability.h"
  14. @implementation HomeHubTableViewCell
  15. @end
  16. @implementation HomeHubRegistTableViewCell
  17. @end
  18. @implementation HomeHubInfoTableViewCell
  19. @end
  20. @interface HomeHubViewController () {
  21. }
  22. @end
  23. #pragma mark - Class Definition
  24. @implementation HomeHubViewController
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. // Do any additional setup after loading the view.
  28. [self initUI];
  29. [self prepareViewDidLoad];
  30. }
  31. - (void)initUI {
  32. [self initTableViewAsDefaultStyle:_tableView];
  33. }
  34. - (void)prepareViewDidLoad {
  35. }
  36. - (void)updateHomeHubStatus {
  37. [_tableView reloadData];
  38. }
  39. #pragma mark - UITableView DataSource & Delegate
  40. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  41. return 1;
  42. }
  43. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  44. return 3;
  45. }
  46. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  47. CGFloat height = 86.0f;
  48. if (indexPath.row == 0) {
  49. height = 185.0f;
  50. } else if (indexPath.row == 1){
  51. height = 181.0f;
  52. } else if (indexPath.row == 2){
  53. height = 164.0f;
  54. }
  55. return height;
  56. }
  57. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  58. UITableViewCell *cell = nil;
  59. if (indexPath.row == 0) {
  60. HomeHubTableViewCell *tcell = (HomeHubTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"HubCellIdentifier"];
  61. if (!([[Reachability reachabilityForInternetConnection]currentReachabilityStatus] == NotReachable)) {
  62. tcell.lblNetworkStatus.text = @"정상";
  63. tcell.lblBrokenTime.text = @"";
  64. tcell.lblNetworkStatus.textColor = kUITextColor04;
  65. tcell.imgvStatus.hidden = YES;
  66. } else {
  67. tcell.lblNetworkStatus.text = @"오프라인";
  68. tcell.lblBrokenTime.text = @"2017.04.04 15:33:30";
  69. tcell.lblNetworkStatus.textColor = kUITextColor07;
  70. tcell.lblBrokenTime.textColor = kUITextColor07;
  71. tcell.imgvStatus.hidden = NO;
  72. // tcell.imgvStatus.image = [UIImage imageNamed:@"common_bullet_alert_on"];
  73. }
  74. if([JDFacade facade].loginUser.isHomehubOnline){
  75. tcell.lblDeviceStatus.text = @"정상";
  76. tcell.lblDeviceStatus.textColor = kUITextColor04;
  77. } else {
  78. tcell.lblDeviceStatus.text = @"단절";
  79. tcell.lblDeviceStatus.textColor = kUITextColor07;
  80. }
  81. cell = tcell;
  82. } else if (indexPath.row == 1) {
  83. HomeHubRegistTableViewCell *tcell = (HomeHubRegistTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"RegistCellIdentifier"];
  84. // tcell.lblDate.text = [CommonUtil formattedDate3:[JDFacade facade].loginUser.homehubCreateDatetime];
  85. if (![tcell.btnFirmUpdate actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  86. [tcell.btnFirmUpdate addTarget:self action:@selector(btnFirmwareUpdateTouched:) forControlEvents:UIControlEventTouchUpInside];
  87. }
  88. if (![tcell.btnSoftUpdate actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  89. [tcell.btnSoftUpdate addTarget:self action:@selector(btnSofrwareUpdateTouched:) forControlEvents:UIControlEventTouchUpInside];
  90. }
  91. cell = tcell;
  92. } else if (indexPath.row == 2) {
  93. HomeHubInfoTableViewCell *tcell = (HomeHubInfoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"HubInfoCellIdentifier"];
  94. cell = tcell;
  95. }
  96. return cell;
  97. }
  98. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  99. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  100. }
  101. - (void)btnFirmwareUpdateTouched:(id)sender{
  102. NSLog(@"펌웨어 업데이트");
  103. }
  104. - (void)btnSofrwareUpdateTouched:(id)sender{
  105. NSLog(@"소프트웨어 업데이트");
  106. }
  107. #pragma mark - UI Events
  108. - (IBAction)btnSecureTouched:(id)sender {
  109. }
  110. - (IBAction)btnEditTitleTouched:(id)sender {
  111. NSLog(@"타이틀 변경");
  112. }
  113. - (void)btnCloseTouched:(id)sender {
  114. [self dismissViewControllerAnimated:YES completion:nil];
  115. }
  116. - (IBAction)btnSetTouched:(id)sender {
  117. NSLog(@"설정");
  118. }
  119. #pragma mark - MemoryWarning
  120. - (void)didReceiveMemoryWarning
  121. {
  122. [super didReceiveMemoryWarning];
  123. // Dispose of any resources that can be recreated.
  124. }
  125. @end