|
|
@@ -165,6 +165,18 @@
|
|
|
[self prepareViewDidLoadRefreshPopup:NO];
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+- (void)viewWillDisappear:(BOOL)animated {
|
|
|
+
|
|
|
+ if (_deviceCommandsBackgroundTimer) {
|
|
|
+ [_deviceCommandsBackgroundTimer invalidate];
|
|
|
+ _deviceCommandsBackgroundTimer = nil;
|
|
|
+ }
|
|
|
+
|
|
|
+ [self releaseDevicesTimer];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
- (void)initProperties {
|
|
|
_deviceFlag = IS_IPHONE_6P ? 2 : 2;
|
|
|
}
|
|
|
@@ -211,7 +223,12 @@
|
|
|
|
|
|
for (DeviceModel *deviceModel in [JDFacade facade].loginUser.deviceList) {
|
|
|
|
|
|
- if (!deviceModel.isDeviceOnlined) {
|
|
|
+ NSLog(@"isDeviceOnlined : %d, isDeviceConn : %d, is : %d",
|
|
|
+ deviceModel.isDeviceOnlined,
|
|
|
+ deviceModel.isDeviceConn,
|
|
|
+ !deviceModel.isDeviceOnlined || !deviceModel.isDeviceConn);
|
|
|
+
|
|
|
+ if (!deviceModel.isDeviceOnlined || !deviceModel.isDeviceConn) {
|
|
|
offlineCount++;
|
|
|
|
|
|
if (offlineName.length == 0) {
|
|
|
@@ -220,6 +237,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if (offlineCount == 1) {
|
|
|
|
|
|
_lblOffline.text = [NSString stringWithFormat:@"%@ 오프라인", offlineName];
|
|
|
@@ -231,25 +249,30 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
+ NSLog(@"offlineCount : %ld", offlineCount);
|
|
|
|
|
|
showOffline = offlineCount > 0;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
- if (!deviceModel.isDeviceOnlined) {
|
|
|
+ if (!deviceModel.isDeviceOnlined || !deviceModel.isDeviceConn) {
|
|
|
|
|
|
NSString *name = deviceModel.prdUserName != nil ? deviceModel.prdUserName : deviceModel.prdName;
|
|
|
_lblOffline.text = [NSString stringWithFormat:@"%@ 오프라인", name];
|
|
|
}
|
|
|
|
|
|
- showOffline = !deviceModel.isDeviceOnlined;
|
|
|
+ showOffline = !deviceModel.isDeviceOnlined || !deviceModel.isDeviceConn;
|
|
|
+
|
|
|
+
|
|
|
+ NSLog(@"showOffline : %d %d %d", deviceModel.isDeviceOnlined,deviceModel.isDeviceConn, showOffline);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
_viewHeight.constant = showOffline ? 54 : 0;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
- (void)initRefreshController {
|
|
|
//set refresh controls
|
|
|
__weak typeof(self) weakSelf = self;
|
|
|
@@ -284,6 +307,8 @@
|
|
|
//// }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+//버튼 말풍선 셋팅
|
|
|
- (void)setMoreBtnArray {
|
|
|
|
|
|
_moreBtnArray = [NSMutableArray array];
|
|
|
@@ -296,7 +321,7 @@
|
|
|
|
|
|
//멀티이고 하나 선택한 경우
|
|
|
if (_selectHub != nil)
|
|
|
- isOnlineHomeHub = _selectHub.isDeviceOnlined;
|
|
|
+ isOnlineHomeHub = _selectHub.isDeviceOnlined && _selectHub.isDeviceConn;
|
|
|
|
|
|
if([[JDFacade facade].loginUser.gradeCode isEqualToString:KNEET_MEMBER_MASTER]) {
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
@@ -365,6 +390,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
- (void)fetchDevicesFromServer {
|
|
|
|
|
|
[self performSelector:@selector(requestHomeHubList) withObject:nil afterDelay:0.0f];
|
|
|
@@ -412,8 +438,6 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- (void)precessMasterTransfer {
|
|
|
|
|
|
[[JDFacade facade] confirmTitle:@"알림"
|
|
|
@@ -685,7 +709,7 @@
|
|
|
|
|
|
DataSelectModel *data = [[DataSelectModel alloc] init];
|
|
|
data.title = info.deviceName;
|
|
|
- if (![info isDeviceOnlined]) {
|
|
|
+ if (!info.isDeviceOnlined || !info.isDeviceConn) {
|
|
|
data.strColorCode = kUITextColorCode06;
|
|
|
}
|
|
|
|
|
|
@@ -860,10 +884,9 @@
|
|
|
_selectHub = (DeviceModel *)seleced.value;
|
|
|
[JDFacade facade].loginUser.selectedHomeHubID = _selectHub.deviceId;
|
|
|
|
|
|
- NSLog(@"Selected Hub : %@", _selectHub);
|
|
|
-
|
|
|
[self updateTitle];
|
|
|
[self requestDeviceList:@YES];
|
|
|
+
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
@@ -991,12 +1014,12 @@
|
|
|
}
|
|
|
|
|
|
#pragma mark - UICollectionView Delegate
|
|
|
-
|
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
|
|
NSInteger auth = [JDFacade facade].loginUser.level == 90
|
|
|
&& !_isDeleteMode
|
|
|
&& [_nodeListData isCanAddNode]
|
|
|
- && [[JDFacade facade].loginUser onlineHomeHubFromSelectedHub:_selectHub]; //마스터 권한일 경우,
|
|
|
+ && [[JDFacade facade].loginUser onlineHomeHubFromSelectedHub:_selectHub]
|
|
|
+ && [[JDFacade facade].loginUser connectedHomeHubFromSelectedHub:_selectHub];
|
|
|
|
|
|
// NSLog(@"authCount : %ld", auth);
|
|
|
// NSLog(@"[JDFacade facade].loginUser.level : %ld", [JDFacade facade].loginUser.level);
|
|
|
@@ -1109,7 +1132,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (!device.isOnline) {
|
|
|
+ if (!device.isOnline || !device.isDeviceConn) {
|
|
|
|
|
|
cell.lblDeviceStatus.text = @"OFFLINE";
|
|
|
cell.lblDeviceStatus.textColor = kUITextColor01;
|
|
|
@@ -1444,6 +1467,93 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
+-(void)moreBtnAction:(id)sender
|
|
|
+{
|
|
|
+ NSInteger tag = [(UIButton *)sender tag];
|
|
|
+ NSLog(@"MoreBtn Action : %li", (long)tag);
|
|
|
+ switch (tag) {
|
|
|
+ case ReOrder:
|
|
|
+ {
|
|
|
+ [self toggleReOrderMode:YES];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Add:
|
|
|
+ {
|
|
|
+ [self addNewDevice];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Del:
|
|
|
+ {
|
|
|
+ [self toggleEditMode:YES];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Refresh:
|
|
|
+ {
|
|
|
+ [self refreshDeviceList];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+-(void)btnDeviceTouched:(id)sender
|
|
|
+{
|
|
|
+ NSIndexPath *indexPath = (NSIndexPath *) ((CustomButton *)sender).value;
|
|
|
+ //
|
|
|
+ // DeviceModel *device =_deviceList[indexPath.row];
|
|
|
+ // NSLog(@"Device : %@", device);
|
|
|
+ [self moveToDetail:indexPath];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+-(void)btnDeviceDelete:(id)sender
|
|
|
+{
|
|
|
+ NSIndexPath *indexPath = (NSIndexPath *) ((CustomButton *)sender).value;
|
|
|
+
|
|
|
+ DeviceModel *device =_deviceList[indexPath.row];
|
|
|
+
|
|
|
+ if (![device isOnline]) {
|
|
|
+ ThingsForcedDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsForcedDelViewController" storyboardName:@"Things"];
|
|
|
+
|
|
|
+ vc.delDevice = device;
|
|
|
+ // vc.providesPresentationContextTransitionStyle = YES;
|
|
|
+ // vc.definesPresentationContext = YES;
|
|
|
+ //
|
|
|
+ // [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
|
|
|
+ //
|
|
|
+ // [self presentViewController:vc animated:NO completion:nil];
|
|
|
+ [self showTransparencyModalView:vc removeSelf:NO];
|
|
|
+
|
|
|
+ } else {
|
|
|
+ ThingsGeneralDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsGeneralDelViewController" storyboardName:@"Things"];
|
|
|
+
|
|
|
+ vc.delDevice = device;
|
|
|
+ // vc.providesPresentationContextTransitionStyle = YES;
|
|
|
+ // vc.definesPresentationContext = YES;
|
|
|
+ //
|
|
|
+ // [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
|
|
|
+ //
|
|
|
+ // [self presentViewController:vc animated:NO completion:nil];
|
|
|
+ [self showTransparencyModalView:vc removeSelf:NO];
|
|
|
+ }
|
|
|
+
|
|
|
+ // [self requestDeviceList:@NO];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+-(void)finishDeviveDelete
|
|
|
+{
|
|
|
+ NSLog(@"tvc finishDeviveDelete");
|
|
|
+
|
|
|
+ [self toggleEditMode:NO];
|
|
|
+ [self requestDeviceList:@YES];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
#pragma mark - SocketService
|
|
|
- (void) socketDidReceiveMessage:(id)message result:(SocketModel *)result
|
|
|
{
|
|
|
@@ -1510,7 +1620,7 @@
|
|
|
|
|
|
// CommandModel *response = [[CommandModel alloc] initWithDictionary:notification.object error:nil];
|
|
|
|
|
|
- //NSLog(@"Result : %@", result);
|
|
|
+ NSLog(@"Result : %@", result);
|
|
|
|
|
|
if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_CONTENT]) {
|
|
|
ContentModel *response = [[ContentModel alloc] initWithDictionary:notification.object error:nil];
|
|
|
@@ -1535,120 +1645,42 @@
|
|
|
else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_COMMAND_RES]) {
|
|
|
|
|
|
}
|
|
|
- else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_REGIST_RES] || [result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_DELETE_RES]) {
|
|
|
+ else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_REGIST_RES] ||
|
|
|
+ [result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_DELETE_RES]) {
|
|
|
|
|
|
[self requestDeviceList:@NO];
|
|
|
|
|
|
}
|
|
|
- else if([result.messageType isEquestToIgnoreCase:MSG_TYPE_DEVICE_CONTENT]) {
|
|
|
+ else if([result.messageType isEquestToIgnoreCase:MSG_TYPE_DEVICE_CONTENT] ||
|
|
|
+ [result.messageType isEquestToIgnoreCase:MSG_TYPE_DEVICE_CONN]) {
|
|
|
|
|
|
if (_selectHub != nil) {
|
|
|
|
|
|
[JDFacade facade].loginUser.selectedHomeHubID = _selectHub.deviceId;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- [self performSelector:@selector(viewOfflineSetDeviceModel:) withObject:nil afterDelay:1.0f];
|
|
|
- [self performSelector:@selector(setMoreBtnArray) withObject:nil afterDelay:1.0f];
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark - MoreButtonDelegate
|
|
|
--(void)moreBtnAction:(id)sender
|
|
|
-{
|
|
|
- NSInteger tag = [(UIButton *)sender tag];
|
|
|
- NSLog(@"MoreBtn Action : %li", (long)tag);
|
|
|
- switch (tag) {
|
|
|
- case ReOrder:
|
|
|
- {
|
|
|
- [self toggleReOrderMode:YES];
|
|
|
- }
|
|
|
- break;
|
|
|
- case Add:
|
|
|
- {
|
|
|
- [self addNewDevice];
|
|
|
- }
|
|
|
- break;
|
|
|
- case Del:
|
|
|
- {
|
|
|
- [self toggleEditMode:YES];
|
|
|
- }
|
|
|
- break;
|
|
|
- case Refresh:
|
|
|
- {
|
|
|
- [self refreshDeviceList];
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- default:
|
|
|
- break;
|
|
|
+ //소켓 통신을 핸들러와 동시에 받는데 핸들러에서 유저 정보에 디바이스 정보 업데이트 해줌. 그 후에 화면 갱신
|
|
|
+ [self performSelector:@selector(hubStatusChangeRefresh) withObject:nil afterDelay:1.0f];
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-#pragma mark - MemoryWarning
|
|
|
-
|
|
|
-- (void)viewWillDisappear:(BOOL)animated {
|
|
|
+//허브 상태 변경 전체 리프레시
|
|
|
+- (void)hubStatusChangeRefresh {
|
|
|
|
|
|
- if (_deviceCommandsBackgroundTimer) {
|
|
|
- [_deviceCommandsBackgroundTimer invalidate];
|
|
|
- _deviceCommandsBackgroundTimer = nil;
|
|
|
- }
|
|
|
-
|
|
|
- [self releaseDevicesTimer];
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
--(void)btnDeviceTouched:(id)sender
|
|
|
-{
|
|
|
- NSIndexPath *indexPath = (NSIndexPath *) ((CustomButton *)sender).value;
|
|
|
- //
|
|
|
- // DeviceModel *device =_deviceList[indexPath.row];
|
|
|
- // NSLog(@"Device : %@", device);
|
|
|
- [self moveToDetail:indexPath];
|
|
|
-}
|
|
|
-
|
|
|
--(void)btnDeviceDelete:(id)sender
|
|
|
-{
|
|
|
- NSIndexPath *indexPath = (NSIndexPath *) ((CustomButton *)sender).value;
|
|
|
+// NSLog(@"\n\ndeviceList : %@", _deviceList);
|
|
|
+// NSLog(@"\n\ndeviceList : %@", [JDFacade facade].loginUser.deviceList);
|
|
|
+
|
|
|
+ [self viewOfflineSetDeviceModel:nil]; //상단 오프라인 허브 정보 확성화 체크(온라인, 연결상태)
|
|
|
|
|
|
- DeviceModel *device =_deviceList[indexPath.row];
|
|
|
+ [self setMoreBtnArray]; //상단 오른쪽 버튼 팝업 재조회(추가가능여부)
|
|
|
|
|
|
- if (![device isOnline]) {
|
|
|
- ThingsForcedDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsForcedDelViewController" storyboardName:@"Things"];
|
|
|
-
|
|
|
- vc.delDevice = device;
|
|
|
- // vc.providesPresentationContextTransitionStyle = YES;
|
|
|
- // vc.definesPresentationContext = YES;
|
|
|
- //
|
|
|
- // [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
|
|
|
- //
|
|
|
- // [self presentViewController:vc animated:NO completion:nil];
|
|
|
- [self showTransparencyModalView:vc removeSelf:NO];
|
|
|
-
|
|
|
- } else {
|
|
|
- ThingsGeneralDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsGeneralDelViewController" storyboardName:@"Things"];
|
|
|
-
|
|
|
- vc.delDevice = device;
|
|
|
- // vc.providesPresentationContextTransitionStyle = YES;
|
|
|
- // vc.definesPresentationContext = YES;
|
|
|
- //
|
|
|
- // [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
|
|
|
- //
|
|
|
- // [self presentViewController:vc animated:NO completion:nil];
|
|
|
- [self showTransparencyModalView:vc removeSelf:NO];
|
|
|
- }
|
|
|
+ [self requestHomeHubList]; //타이틀 허브 리스트 재조회(온라인, 연결상태)
|
|
|
|
|
|
- // [self requestDeviceList:@NO];
|
|
|
+ [_collectionView reloadData]; //장치추카 셀(온라인, 연결상태)
|
|
|
}
|
|
|
|
|
|
--(void)finishDeviveDelete
|
|
|
-{
|
|
|
- NSLog(@"tvc finishDeviveDelete");
|
|
|
-
|
|
|
- [self toggleEditMode:NO];
|
|
|
- [self requestDeviceList:@YES];
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
@end
|