瀏覽代碼

- 장치목록 순서변경후 저장 / 저장안함 기능 적

KaRam Kim 8 年之前
父節點
當前提交
dab49891e2
共有 1 個文件被更改,包括 18 次插入7 次删除
  1. 18 7
      OneCable/Classes/ViewControllers/ThingsScreens/ThingsViewController.m

+ 18 - 7
OneCable/Classes/ViewControllers/ThingsScreens/ThingsViewController.m

@@ -92,8 +92,8 @@
 
 
 @interface ThingsViewController () <UICollectionViewDataSource, UICollectionViewDelegate> {
-    NSMutableArray<DeviceModel> *_deviceList;
-    NSMutableArray<DeviceModel> *_deviceReOrderList;
+    NSMutableArray *_deviceList;
+    NSMutableArray *_deviceReOrderList;
     NSString *_pagingId, *_pagingType;
     BOOL _isNotFirstLoading, _isReOrderMode, _isDeleteMode;
     
@@ -415,7 +415,8 @@
         NodeListModel *deviceList = (NodeListModel *)responseObject;
 
         if (deviceList && deviceList.nodes && deviceList.nodes.count) {
-            _deviceReOrderList = _deviceList = deviceList.nodes;
+            _deviceList = deviceList.nodes;
+            _deviceReOrderList = [[NSMutableArray alloc] initWithArray:_deviceList];
             [self updateTitle];
         } else {
             if (!_deviceList.count) {//이미 로드된 데이터가 있을 경우는 출력하지 않음.
@@ -600,6 +601,11 @@
             cell.btnDevice.enabled = NO;
             cell.btnDeviceControl.hidden = YES;
         }
+        else
+        {
+            cell.btnDevice.enabled = YES;
+            cell.btnDeviceControl.hidden = NO;
+        }
         
         [cell.btnChangeOrder addGestureRecognizer:drag];
         cell.btnChangeOrder.value = indexPath;
@@ -830,11 +836,15 @@
     NSLog(@"From Index : %li", (long)atIndexPath.item);
     NSLog(@"To Index : %li", (long)toIndexPath.item);
     
-//    DeviceModel *device =_deviceList[atIndexPath.item];
+    DeviceModel *device =_deviceReOrderList[atIndexPath.item];
     
-//    [_deviceList removeObject:device];
-//    [_deviceList insertObject:device atIndex:toIndexPath.item];
-//    
+    NSLog(@"DeviceModel : %@", device);
+
+    
+    
+    [_deviceReOrderList removeObjectAtIndex:atIndexPath.item];
+    [_deviceReOrderList insertObject:device atIndex:toIndexPath.item];
+//
 //    [_collectionView reloadData];
 //    UIImage *image = [_photosArray objectAtIndex:fromIndexPath.item];
 //    [_photosArray removeObjectAtIndex:fromIndexPath.item];
@@ -875,6 +885,7 @@
     [[JDFacade facade] confirmTitle:@"알림" message:@"현재 편집된 장치 목록 순서를\n저장하시겠습니까?" btnOKLabel:@"확인" btnCancelLabel:@"취소" completion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
         if (buttonIndex == 0) {
             // TODO : 데이터 업데이트 하기
+            _deviceList = [[NSMutableArray alloc] initWithArray:_deviceReOrderList];
             [self enterReOrderMode:NO];
         }
     }];