|
|
@@ -172,6 +172,11 @@ typedef enum {
|
|
|
- (void)logout {
|
|
|
[self.shipArray removeAllObjects];
|
|
|
[self.shipTableView reloadData];
|
|
|
+
|
|
|
+ self.currentKPI = 1;
|
|
|
+ self.monthArray = nil;
|
|
|
+ [self.KPIArray removeAllObjects];
|
|
|
+ [self.KPITableView reloadData];
|
|
|
}
|
|
|
|
|
|
- (void)handlePersonModeChangeNotification:(NSNotification *)notification {
|
|
|
@@ -287,7 +292,7 @@ typedef enum {
|
|
|
[self.KPIArray removeAllObjects];
|
|
|
NSArray *kpiArr = [json objectForKey:@"KPI"];
|
|
|
|
|
|
- [self.KPIArray addObject:[[kpiArr firstObject] mutableCopy]];
|
|
|
+// [self.KPIArray addObject:[[kpiArr firstObject] mutableCopy]];
|
|
|
for (int i = 0; i < kpiArr.count; i++) {
|
|
|
NSMutableDictionary *kpiModel = [[kpiArr objectAtIndex:i] mutableCopy];
|
|
|
NSMutableArray *itemMutArr = [NSMutableArray array];
|
|
|
@@ -301,7 +306,7 @@ typedef enum {
|
|
|
// [self.KPIArray addObjectsFromArray:kpiArr];
|
|
|
[self.KPIArray addObject:kpiModel];
|
|
|
}
|
|
|
- [self.KPIArray addObject:[[kpiArr lastObject] mutableCopy]];
|
|
|
+// [self.KPIArray addObject:[[kpiArr lastObject] mutableCopy]];
|
|
|
|
|
|
|
|
|
[self.KPITableView reloadData];
|
|
|
@@ -535,13 +540,26 @@ typedef enum {
|
|
|
}
|
|
|
|
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
|
|
- return self.KPIArray.count;
|
|
|
+ if (self.KPIArray && self.KPIArray.count > 0) {
|
|
|
+ return self.KPIArray.count + 2;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
KPICell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"KPICell" forIndexPath:indexPath];
|
|
|
- NSMutableDictionary *item = [self.KPIArray objectAtIndex:indexPath.item];
|
|
|
+
|
|
|
+ NSInteger index = indexPath.item;
|
|
|
+ if (indexPath.item == 0) {
|
|
|
+ index = self.KPIArray.count - 1;
|
|
|
+ } else if (indexPath.item == self.KPIArray.count + 1) {
|
|
|
+ index = 0;
|
|
|
+ } else {
|
|
|
+ index = indexPath.item - 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSMutableDictionary *item = [self.KPIArray objectAtIndex:index];
|
|
|
[item setObject:self.monthArray forKey:@"month"];
|
|
|
[cell setInfoDic:item];
|
|
|
cell.delegate = self;
|
|
|
@@ -569,10 +587,17 @@ typedef enum {
|
|
|
UICollectionView *collectionView = (UICollectionView *)scrollView;
|
|
|
CGFloat w = scrollView.bounds.size.width;
|
|
|
CGFloat offsetX = scrollView.contentOffset.x;
|
|
|
- if (offsetX < w && offsetX >= 0) {
|
|
|
- [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:self.KPIArray.count - 2 inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
- } else if (offsetX < (self.KPIArray.count * w) && offsetX >= ((self.KPIArray.count - 1) * w)) {
|
|
|
- [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
+ float f = floorf(offsetX / w);
|
|
|
+ NSInteger index = floorf(f + 0.5);
|
|
|
+ NSInteger cur = index;
|
|
|
+ if (index == 0) {
|
|
|
+ cur = self.KPIArray.count;
|
|
|
+ [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:cur inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
+ } else if (index == self.KPIArray.count + 1) {
|
|
|
+ cur = 1;
|
|
|
+ [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:cur inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
+ } else {
|
|
|
+ cur = index;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -584,14 +609,16 @@ typedef enum {
|
|
|
CGFloat offsetX = scrollView.contentOffset.x;
|
|
|
float f = floorf(offsetX / w);
|
|
|
NSInteger index = floorf(f + 0.5);
|
|
|
+ NSInteger cur = index;
|
|
|
if (index == 0) {
|
|
|
- index = self.KPIArray.count - 2;
|
|
|
- }
|
|
|
- if (index == self.KPIArray.count - 1) {
|
|
|
- index = 1;
|
|
|
+ cur = self.KPIArray.count;
|
|
|
+ } else if (index == self.KPIArray.count + 1) {
|
|
|
+ cur = 1;
|
|
|
+ } else {
|
|
|
+ cur = index;
|
|
|
}
|
|
|
- self.currentKPI = index;
|
|
|
- NSString *str = [NSString stringWithFormat:@"%ld / %ld",index,self.KPIArray.count - 2];
|
|
|
+ self.currentKPI = cur;
|
|
|
+ NSString *str = [NSString stringWithFormat:@"%ld / %ld",self.currentKPI,self.KPIArray.count];
|
|
|
self.parentViewController.title = str;
|
|
|
}
|
|
|
}
|