|
|
@@ -93,6 +93,7 @@
|
|
|
|
|
|
@interface ThingsViewController () <UICollectionViewDataSource, UICollectionViewDelegate> {
|
|
|
NSMutableArray<DeviceModel> *_deviceList;
|
|
|
+ NSMutableArray<DeviceModel> *_deviceReOrderList;
|
|
|
NSString *_pagingId, *_pagingType;
|
|
|
BOOL _isNotFirstLoading, _isReOrderMode, _isDeleteMode;
|
|
|
|
|
|
@@ -142,6 +143,8 @@
|
|
|
_collectionView.backgroundColor = [UIColor clearColor];
|
|
|
_collectionView.alwaysBounceVertical = YES;
|
|
|
|
|
|
+ _lblEditMode.hidden = YES;
|
|
|
+
|
|
|
[self viewOfflineSetHidden:YES];
|
|
|
|
|
|
[_btnClose setHidden:YES];
|
|
|
@@ -412,7 +415,7 @@
|
|
|
NodeListModel *deviceList = (NodeListModel *)responseObject;
|
|
|
|
|
|
if (deviceList && deviceList.nodes && deviceList.nodes.count) {
|
|
|
- _deviceList = deviceList.nodes;
|
|
|
+ _deviceReOrderList = _deviceList = deviceList.nodes;
|
|
|
[self updateTitle];
|
|
|
} else {
|
|
|
if (!_deviceList.count) {//이미 로드된 데이터가 있을 경우는 출력하지 않음.
|
|
|
@@ -592,11 +595,14 @@
|
|
|
cell.btnDelete.hidden = !_isDeleteMode;
|
|
|
cell.btnChangeOrder.hidden = !_isReOrderMode;
|
|
|
|
|
|
+ if(_isDeleteMode || _isReOrderMode)
|
|
|
+ {
|
|
|
+ cell.btnDevice.enabled = NO;
|
|
|
+ cell.btnDeviceControl.hidden = YES;
|
|
|
+ }
|
|
|
+
|
|
|
[cell.btnChangeOrder addGestureRecognizer:drag];
|
|
|
-// [cell.btnChangeOrder setTag:indexPath.row];
|
|
|
cell.btnChangeOrder.value = indexPath;
|
|
|
- [cell.btnChangeOrder addTarget:self action:@selector(btnChangeOrderTouched:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
- [cell.btnChangeOrder addTarget:self action:@selector(btnChangeOrderTouchDown:) forControlEvents:UIControlEventTouchDown];
|
|
|
|
|
|
|
|
|
if (!cell.controlContainer.hidden) {//커맨드 클래스 타입별 컨트롤 호출
|
|
|
@@ -821,7 +827,15 @@
|
|
|
-(void)updateDataSource:(NSIndexPath *)atIndexPath toIndexPath:(NSIndexPath *)toIndexPath
|
|
|
{
|
|
|
NSLog(@"Update Data");
|
|
|
+ NSLog(@"From Index : %li", (long)atIndexPath.item);
|
|
|
+ NSLog(@"To Index : %li", (long)toIndexPath.item);
|
|
|
|
|
|
+// DeviceModel *device =_deviceList[atIndexPath.item];
|
|
|
+
|
|
|
+// [_deviceList removeObject:device];
|
|
|
+// [_deviceList insertObject:device atIndex:toIndexPath.item];
|
|
|
+//
|
|
|
+// [_collectionView reloadData];
|
|
|
// UIImage *image = [_photosArray objectAtIndex:fromIndexPath.item];
|
|
|
// [_photosArray removeObjectAtIndex:fromIndexPath.item];
|
|
|
// [_photosArray insertObject:image atIndex:toIndexPath.item];
|
|
|
@@ -848,6 +862,49 @@
|
|
|
[self toggleOptionsWithArray:sender btnArray:_moreBtnArray];
|
|
|
}
|
|
|
|
|
|
+- (IBAction)btnReFreshTouched:(id)sender {
|
|
|
+ [[JDFacade facade] confirmTitle:@"알림" message:@"장치 목록의 순서를\n장치가 등록된 순으로 초괴화합니다." btnOKLabel:@"확인" btnCancelLabel:@"취소" completion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
|
|
|
+ if (buttonIndex == 0) {
|
|
|
+ // TODO : 서버에서 장치 목록 순서 다시 가져오기
|
|
|
+ [self enterReOrderMode:NO];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (IBAction)btnConfirmTouched:(id)sender {
|
|
|
+ [[JDFacade facade] confirmTitle:@"알림" message:@"현재 편집된 장치 목록 순서를\n저장하시겠습니까?" btnOKLabel:@"확인" btnCancelLabel:@"취소" completion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
|
|
|
+ if (buttonIndex == 0) {
|
|
|
+ // TODO : 데이터 업데이트 하기
|
|
|
+ [self enterReOrderMode:NO];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+// _deviceList = _deviceReOrderList;
|
|
|
+// [self enterReOrderMode:NO];
|
|
|
+}
|
|
|
+
|
|
|
+- (IBAction)btnCloseTouched:(id)sender {
|
|
|
+ [[JDFacade facade] confirmTitle:@"알림" message:@"장치 목록 순서를 저장하지 않고\n이전화면으로 이동합니다." btnOKLabel:@"확인" btnCancelLabel:@"취소" completion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
|
|
|
+ if (buttonIndex == 0) {
|
|
|
+ [self enterReOrderMode:NO];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+// [self enterReOrderMode:NO];
|
|
|
+}
|
|
|
+
|
|
|
+-(void)enterReOrderMode:(Boolean)isReOrder
|
|
|
+{
|
|
|
+ _isReOrderMode = isReOrder;
|
|
|
+ _viewEditMode.hidden = !isReOrder;
|
|
|
+ _btnOption.hidden = isReOrder;
|
|
|
+ [_collectionView reloadData];
|
|
|
+
|
|
|
+ _viewTitle.hidden = isReOrder;
|
|
|
+ _lblEditMode.hidden = !isReOrder;
|
|
|
+
|
|
|
+ _lblEditMode.text = @"장치 목록 순서 편집";
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - SocketService
|
|
|
- (void) socketDidReceiveMessage:(id)message info:(NSDictionary *)info
|
|
|
{
|
|
|
@@ -889,10 +946,7 @@
|
|
|
switch (tag) {
|
|
|
case ReOrder:
|
|
|
{
|
|
|
- // TODO : 순서 변경 모드로 진입
|
|
|
- _isReOrderMode = YES;
|
|
|
- [_collectionView reloadData];
|
|
|
- _viewEditMode.hidden = NO;
|
|
|
+ [self enterReOrderMode:YES];
|
|
|
}
|
|
|
break;
|
|
|
case Add:
|
|
|
@@ -935,19 +989,10 @@
|
|
|
// Dispose of any resources that can be recreated.
|
|
|
}
|
|
|
|
|
|
-- (void)btnDeviceTouched:(id)sender {
|
|
|
- CustomButton *btn = (CustomButton *)sender;
|
|
|
-
|
|
|
-// [_collectionView selectItemAtIndexPath:btn.value animated:YES scrollPosition:UICollectionViewScrollPositionNone];
|
|
|
- [self collectionView:_collectionView didSelectItemAtIndexPath:btn.value];
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
+-(void)btnDeviceTouched:(id)sender
|
|
|
+{
|
|
|
|
|
|
--(void)btnChangeOrderTouchDown:(id)sender {
|
|
|
- CustomButton *info = (CustomButton *)sender;
|
|
|
- NSLog(@"%@", info.value);
|
|
|
- _dragIndexPath = info.value;
|
|
|
}
|
|
|
|
|
|
@end
|