| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- //
- // HomeHubSearchSuccessViewController.m
- // OneCable
- //
- // Created by nComz on 2017. 5. 11..
- // Copyright © 2017년 ntels. All rights reserved.
- //
- #import "HomeHubSearchSuccessViewController.h"
- #import "CustomTableView.h"
- #import "CustomCheckBox.h"
- #import "HomeHubConnectWifiViewController.h"
- @interface HomeHubSearchSuccessViewController ()<CustomCheckBoxDelegate> {
-
- BLEServiceHandler *bleService;
- NSMutableArray *devices;
- NSArray *_tableZombieValues;
- BTLEDeivceModel *selectedModel;
- }
- @end
- @implementation HomeHubSearchTableViewCell
- @end
- @implementation HomeHubSearchSuccessViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self initUI];
- [self prepareViewDidLoad];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
-
- bleService.delegate = self;
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
-
- bleService.delegate = nil;
- }
- - (void)initUI {
- _btnNext.enabled = NO;
- [self initTableViewAsDefaultStyle:_tableView];
- }
- - (void)prepareViewDidLoad {
-
- //ble
- bleService = [BLEServiceHandler sharedManager];
-
- devices = [bleService getDeviceList];
-
- [_tableView reloadData];
- }
- #pragma mark - UITableView DataSource & Delegate
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-
- return devices.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- return 108.0f;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- HomeHubSearchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HubSearchCellIdentifier"];
- BTLEDeivceModel *bleModel = [devices objectAtIndex:indexPath.row];
-
- cell.lblHubName.text = bleModel.peripheralRef.name;
- cell.lblSerialNum.text = [NSString stringWithFormat:@"S/N : %@",bleModel.peripheralRef.identifier];
- cell.chkBtn.selected = [selectedModel isEqual:bleModel];
-
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [super tableView:tableView didSelectRowAtIndexPath:indexPath];
-
- selectedModel = [devices objectAtIndex:indexPath.row];
- _btnNext.enabled = YES;
- [tableView reloadData];
- }
- #pragma mark - User Event
- - (IBAction)btnNextTouched:(id)sender {
-
- NSLog(@"selectedModel : %@", selectedModel);
-
- if (selectedModel != nil) {
-
- [bleService setConDevice:selectedModel];
-
- HomeHubConnectWifiViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubConnectWifiViewController" storyboardName:@"HomeHub"];
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- - (IBAction)btnCloseTouched:(id)sender {
- [self.navigationController popToRootViewControllerAnimated:YES];
- }
- @end
|