Commit fcfef587834b053465a872d4fbf1a6dcc7f93244

Authored by nvtu11790@gmail.com
1 parent 03a8708ee3

Add my group screen, add API get group list and update member list or tweet list when change group

Showing 12 changed files with 633 additions and 5 deletions Side-by-side Diff

LifeLog/LifeLog.xcodeproj/project.pbxproj
... ... @@ -60,6 +60,8 @@
60 60 E9497FD51F46EC1100E6AF8D /* MemberObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E9497FD41F46EC1100E6AF8D /* MemberObject.m */; };
61 61 E95F4CED1F475C6A00D27E80 /* CreateGroupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E95F4CEB1F475C6A00D27E80 /* CreateGroupViewController.m */; };
62 62 E95F4CEE1F475C6A00D27E80 /* CreateGroupViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E95F4CEC1F475C6A00D27E80 /* CreateGroupViewController.xib */; };
  63 + E95F4CF31F48B39200D27E80 /* MyGroupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E95F4CF11F48B39200D27E80 /* MyGroupViewController.m */; };
  64 + E95F4CF41F48B39200D27E80 /* MyGroupViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E95F4CF21F48B39200D27E80 /* MyGroupViewController.xib */; };
63 65 E9682E2E1F39675A00FE05A2 /* RankingTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E9682E2C1F39675A00FE05A2 /* RankingTableViewCell.m */; };
64 66 E9682E2F1F39675A00FE05A2 /* RankingTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E9682E2D1F39675A00FE05A2 /* RankingTableViewCell.xib */; };
65 67 E968550A1F3C444900317CEF /* AutoTransButton.m in Sources */ = {isa = PBXBuildFile; fileRef = E96855091F3C444900317CEF /* AutoTransButton.m */; };
... ... @@ -189,6 +191,9 @@
189 191 E95F4CEA1F475C6A00D27E80 /* CreateGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CreateGroupViewController.h; sourceTree = "<group>"; };
190 192 E95F4CEB1F475C6A00D27E80 /* CreateGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CreateGroupViewController.m; sourceTree = "<group>"; };
191 193 E95F4CEC1F475C6A00D27E80 /* CreateGroupViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CreateGroupViewController.xib; sourceTree = "<group>"; };
  194 + E95F4CF01F48B39200D27E80 /* MyGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyGroupViewController.h; sourceTree = "<group>"; };
  195 + E95F4CF11F48B39200D27E80 /* MyGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyGroupViewController.m; sourceTree = "<group>"; };
  196 + E95F4CF21F48B39200D27E80 /* MyGroupViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MyGroupViewController.xib; sourceTree = "<group>"; };
192 197 E9682E2B1F39675A00FE05A2 /* RankingTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankingTableViewCell.h; sourceTree = "<group>"; };
193 198 E9682E2C1F39675A00FE05A2 /* RankingTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankingTableViewCell.m; sourceTree = "<group>"; };
194 199 E9682E2D1F39675A00FE05A2 /* RankingTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RankingTableViewCell.xib; sourceTree = "<group>"; };
... ... @@ -441,6 +446,7 @@
441 446 6E84E3AC1F27A954001EB88E /* SNS */ = {
442 447 isa = PBXGroup;
443 448 children = (
  449 + E95F4CEF1F48B37100D27E80 /* MyGroup */,
444 450 E95F4CE91F475C4B00D27E80 /* CreateGroup */,
445 451 E933E6751F4050E6002926F5 /* GroupDetail */,
446 452 E933E6671F3E0479002926F5 /* SeachGroup */,
... ... @@ -597,6 +603,16 @@
597 603 name = CreateGroup;
598 604 sourceTree = "<group>";
599 605 };
  606 + E95F4CEF1F48B37100D27E80 /* MyGroup */ = {
  607 + isa = PBXGroup;
  608 + children = (
  609 + E95F4CF01F48B39200D27E80 /* MyGroupViewController.h */,
  610 + E95F4CF11F48B39200D27E80 /* MyGroupViewController.m */,
  611 + E95F4CF21F48B39200D27E80 /* MyGroupViewController.xib */,
  612 + );
  613 + name = MyGroup;
  614 + sourceTree = "<group>";
  615 + };
600 616 E99E13A71F336F0C00C78787 /* CustomView */ = {
601 617 isa = PBXGroup;
602 618 children = (
... ... @@ -745,6 +761,7 @@
745 761 6EF1630A1F29069300DA306C /* Localizable.strings in Resources */,
746 762 6E84E3B11F27A975001EB88E /* HomeViewController.xib in Resources */,
747 763 6E84E3B61F27A98B001EB88E /* HistoryViewController.xib in Resources */,
  764 + E95F4CF41F48B39200D27E80 /* MyGroupViewController.xib in Resources */,
748 765 E933E66C1F3E04A6002926F5 /* SearchGroupViewController.xib in Resources */,
749 766 E96855121F3C5D9A00317CEF /* SNSRecentTopicTableViewCell.xib in Resources */,
750 767 E933E67A1F40513C002926F5 /* GroupDetailViewController.xib in Resources */,
... ... @@ -861,6 +878,7 @@
861 878 6E84E3761F27A701001EB88E /* main.m in Sources */,
862 879 E933E6701F3E09B6002926F5 /* SearchGroupTableViewCell.m in Sources */,
863 880 6E84E3B51F27A98B001EB88E /* HistoryViewController.m in Sources */,
  881 + E95F4CF31F48B39200D27E80 /* MyGroupViewController.m in Sources */,
864 882 E9373E4D1F361A230059355A /* HistoryGraphObject.m in Sources */,
865 883 E933E66B1F3E04A6002926F5 /* SearchGroupViewController.m in Sources */,
866 884 6E84E3BF1F27A9B1001EB88E /* SNSViewController.m in Sources */,
LifeLog/LifeLog/Assets.xcassets/History/arrow_down.imageset/Contents.json
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "filename" : "arrow_down.png",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
LifeLog/LifeLog/Assets.xcassets/History/arrow_down.imageset/arrow_down.png

527 Bytes

LifeLog/LifeLog/GroupDetailViewController.xib
... ... @@ -89,7 +89,7 @@
89 89 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
90 90 <nil key="highlightedColor"/>
91 91 </label>
92   - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bdy-dI-j47">
  92 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bdy-dI-j47">
93 93 <rect key="frame" x="15" y="160" width="345" height="80"/>
94 94 <constraints>
95 95 <constraint firstAttribute="height" constant="80" id="jgH-57-Bae"/>
LifeLog/LifeLog/GroupObject.h
... ... @@ -34,6 +34,7 @@
34 34  
35 35 @property (nonatomic, strong) NSDate * createDate;
36 36  
  37 +-(id) initWithShortData : (NSDictionary *) dict;
37 38 -(id) initWithData : (NSDictionary *) dict;
38 39 -(id) initWithData : (NSDictionary *) dict andGroupID : (int) groupID;
39 40 -(void) updateDate : (GroupObject *) obj;
LifeLog/LifeLog/GroupObject.m
... ... @@ -10,6 +10,17 @@
10 10 #import "Utilities.h"
11 11  
12 12 @implementation GroupObject
  13 +
  14 +-(id) initWithShortData : (NSDictionary *) dict {
  15 + if([dict objectForKey:@"id"] != nil) {
  16 + self.groupID = [dict[@"id"] intValue];
  17 + }
  18 + if([dict objectForKey:@"group_name"] != nil) {
  19 + self.name = dict[@"group_name"];
  20 + }
  21 + return self;
  22 +}
  23 +
13 24 -(id) initWithData : (NSDictionary *) dict {
14 25 if([dict objectForKey:@"group_id"] != nil) {
15 26 self.groupID = [dict[@"group_id"] intValue];
LifeLog/LifeLog/MyGroupViewController.h
  1 +//
  2 +// MyGroupViewController.h
  3 +// LifeLog
  4 +//
  5 +// Created by nvtu on 8/20/17.
  6 +// Copyright ยฉ 2017 PhongNV. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +#import "BaseTableViewController.h"
  11 +#import "AutoTransButton.h"
  12 +#import "Entities.h"
  13 +
  14 +@interface MyGroupViewController : BaseTableViewController {
  15 + NSMutableArray *_curListGrp;
  16 + GroupObject *_curGroup;
  17 + BOOL isMemberList;
  18 +}
  19 +
  20 +@property (weak, nonatomic) IBOutlet UITableView *tableGrp;
  21 +
  22 +@property (weak, nonatomic) IBOutlet UILabel *lblGroupName;
  23 +@property (weak, nonatomic) IBOutlet UILabel *lblActiveMode;
  24 +@property (weak, nonatomic) IBOutlet UILabel *lblGoal;
  25 +@property (weak, nonatomic) IBOutlet UIButton *btShowGrp;
  26 +@property (weak, nonatomic) IBOutlet AutoTransButton *btSwitch;
  27 +
  28 +- (IBAction)clickBack:(id)sender;
  29 +- (IBAction)clickShowGrp:(id)sender;
  30 +- (IBAction)clickSwitch:(id)sender;
  31 +
  32 +@end
LifeLog/LifeLog/MyGroupViewController.m
  1 +//
  2 +// MyGroupViewController.m
  3 +// LifeLog
  4 +//
  5 +// Created by nvtu on 8/20/17.
  6 +// Copyright ยฉ 2017 PhongNV. All rights reserved.
  7 +//
  8 +
  9 +#import "MyGroupViewController.h"
  10 +#import <SDWebImage/UIImageView+WebCache.h>
  11 +
  12 +#import "Utilities.h"
  13 +#import "ServerAPI.h"
  14 +#import "SNSRecentTopicTableViewCell.h"
  15 +
  16 +@interface MyGroupViewController ()
  17 +
  18 +@end
  19 +
  20 +@implementation MyGroupViewController
  21 +
  22 +- (void)viewDidLoad {
  23 + [super viewDidLoad];
  24 + isMemberList = false;
  25 + _curListGrp = [[NSMutableArray alloc] init];
  26 + [self.tableBase registerNib:[UINib nibWithNibName:@"SNSRecentTopicTableViewCell" bundle:nil] forCellReuseIdentifier:@"RecentTopicCell"];
  27 +
  28 + [self requestGroupList];
  29 + // Do any additional setup after loading the view from its nib.
  30 +}
  31 +
  32 +- (void)didReceiveMemoryWarning {
  33 + [super didReceiveMemoryWarning];
  34 + // Dispose of any resources that can be recreated.
  35 +}
  36 +
  37 +- (void)setupView {
  38 + if(_curGroup != nil) {
  39 + [self.lblGoal setText:_curGroup.goal];
  40 + NSString *mode = @"";
  41 + if(_curGroup.runMode) {
  42 + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.running", nil)];
  43 + mode = [mode stringByAppendingString:@"\n"];
  44 + }
  45 + if(_curGroup.walkMode) {
  46 + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.walking", nil)];
  47 + mode = [mode stringByAppendingString:@"\n"];
  48 + }
  49 + if(_curGroup.bikeMode) {
  50 + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.bike", nil)];
  51 + mode = [mode stringByAppendingString:@"\n"];
  52 + }
  53 + if(_curGroup.stepMode) {
  54 + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.step", nil)];
  55 + mode = [mode stringByAppendingString:@"\n"];
  56 + }
  57 + if(_curGroup.beginMode) {
  58 + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.begin", nil)];
  59 + mode = [mode stringByAppendingString:@"\n"];
  60 + }
  61 + if(_curGroup.gymMode) {
  62 + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.gym", nil)];
  63 + mode = [mode stringByAppendingString:@"\n"];
  64 + }
  65 + NSRange range = [mode rangeOfString:@"\n" options:NSBackwardsSearch];
  66 + if(range.length > 0) {
  67 + mode = [mode stringByReplacingOccurrencesOfString:@"\n" withString:@"" options:NSBackwardsSearch range:range];
  68 + }
  69 + self.lblActiveMode.text = mode;
  70 + }
  71 +}
  72 +
  73 +#pragma mark IBAction
  74 +
  75 +- (IBAction)clickBack:(id)sender {
  76 + [self.navigationController popViewControllerAnimated:true];
  77 +}
  78 +
  79 +- (IBAction)clickShowGrp:(id)sender {
  80 + self.tableGrp.hidden = !self.tableGrp.isHidden;
  81 +}
  82 +
  83 +- (IBAction)clickSwitch:(id)sender {
  84 + isMemberList = !isMemberList;
  85 + if(isMemberList) {
  86 + [sender setTitle:NSLocalizedString(@"lifelog.grDetail.bt.viewTweet", nil) forState:UIControlStateNormal];
  87 + }
  88 + else {
  89 + [sender setTitle:NSLocalizedString(@"lifelog.grDetail.bt.viewMem", nil) forState:UIControlStateNormal];
  90 + }
  91 + [sender setUserInteractionEnabled:false];
  92 + [self resetData];
  93 +}
  94 +
  95 +#pragma mark UITableView Delegate
  96 +-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
  97 + if(tableView == self.tableGrp)
  98 + return 1;
  99 + else
  100 + return [super numberOfSectionsInTableView:tableView];
  101 +}
  102 +
  103 +- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  104 + if(tableView == self.tableGrp)
  105 + return _curListGrp.count;
  106 + else
  107 + return [super tableView:tableView numberOfRowsInSection:section];
  108 +}
  109 +
  110 +- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  111 + if(tableView == self.tableGrp) {
  112 + UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"GroupCell"];
  113 + if(cell == nil) {
  114 + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"GroupCell"];
  115 + }
  116 + GroupObject *object = [_curListGrp objectAtIndex:indexPath.row];
  117 + cell.textLabel.text = object.name;
  118 + return cell;
  119 + }
  120 + else {
  121 + SNSRecentTopicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecentTopicCell"];
  122 + if(isMemberList) {
  123 + MemberObject *object = [_curDataList objectAtIndex:indexPath.row];
  124 + if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) {
  125 + [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]];
  126 + }
  127 + else {
  128 + [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]];
  129 + }
  130 + cell.lblUsername.text = @"";
  131 + cell.lblDateTime.text = @"";
  132 + cell.lblDes.text = object.userName;
  133 + cell.lblMode.text = @"";
  134 + cell.lblDistance.text = @"";
  135 + cell.lblDuration.text = @"";
  136 + }
  137 + else {
  138 + TweetObject *object = [_curDataList objectAtIndex:indexPath.row];
  139 + if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) {
  140 + [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]];
  141 + }
  142 + else {
  143 + [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]];
  144 + }
  145 + cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm"];
  146 + cell.lblUsername.text = object.userName;
  147 + cell.lblDes.text = object.content;
  148 + cell.lblMode.text = object.mode;
  149 + cell.lblDistance.text = [NSString stringWithFormat:@"%.0f m", object.distance];
  150 + cell.lblDuration.text = object.time;
  151 + }
  152 + return cell;
  153 + }
  154 +}
  155 +
  156 +- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  157 + if(tableView == self.tableGrp) {
  158 + return;
  159 + }
  160 + [super tableView:tableView willDisplayCell:cell forRowAtIndexPath:indexPath];
  161 +}
  162 +
  163 +-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  164 + if(tableView == self.tableGrp) {
  165 + [tableView setHidden:true];
  166 + [self resetGroupData:indexPath.row];
  167 + }
  168 +}
  169 +
  170 +#pragma mark Private Function
  171 +
  172 +- (void) resetGroupData : (int) index {
  173 + _curGroup = [_curListGrp objectAtIndex:index];
  174 + self.lblGroupName.text = _curGroup.name;
  175 + [_curDataList removeAllObjects];
  176 + [self.tableBase reloadData];
  177 + [self requestGroupDetail];
  178 +}
  179 +
  180 +- (void) requestGroupList {
  181 + NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
  182 + MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
  183 + [[ServerAPI server] requestGroupList:token CompletionHandler:^(NSArray *array, NSError *error) {
  184 + if(error == nil) {
  185 + [_curListGrp removeAllObjects];
  186 + [_curListGrp addObjectsFromArray:array];
  187 + MyGroupViewController __weak *weakSelf = self;
  188 + dispatch_async(dispatch_get_main_queue(), ^{
  189 + [hudView hideAnimated:true];
  190 + [self.tableGrp reloadData];
  191 + if(_curListGrp.count > 0) {
  192 + [weakSelf resetGroupData:0];
  193 + }
  194 + else {
  195 + weakSelf.lblGroupName.text = @"No Group";
  196 + }
  197 + [weakSelf.btShowGrp setEnabled:(_curListGrp.count > 0)];
  198 + });
  199 + }
  200 + }];
  201 +}
  202 +
  203 +- (void) requestGroupDetail {
  204 + NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
  205 + MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
  206 + [[ServerAPI server] getGroupDetail:token withGroupID:_curGroup.groupID CompletionHandler:^(GroupObject *object, NSError *error) {
  207 + MyGroupViewController __weak *weakSelf = self;
  208 + [_curGroup updateDate:object];
  209 + dispatch_async(dispatch_get_main_queue(), ^{
  210 + [hudView hideAnimated:true];
  211 + [weakSelf setupView];
  212 + [weakSelf callRequestToUpdateData];
  213 + });
  214 + }];
  215 +}
  216 +
  217 +-(void) callRequestToUpdateData {
  218 + [super callRequestToUpdateData];
  219 +
  220 + NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
  221 + MBProgressHUD *hudView = nil;
  222 + if(_curPage == 1 && !self.refreshControl.isRefreshing) {
  223 + hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
  224 + }
  225 + if(isMemberList) {
  226 + [[ServerAPI server] requestMemberList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){
  227 + dispatch_async(dispatch_get_main_queue(), ^{
  228 + if(hudView != nil) {
  229 + [hudView hideAnimated:true];
  230 + }
  231 + });
  232 + MyGroupViewController __weak *weakSelf = self;
  233 + [weakSelf updateTableData:array error:error];
  234 + [weakSelf.btSwitch setUserInteractionEnabled:true];
  235 + }];
  236 + }
  237 + else {
  238 + [[ServerAPI server] requestTweetsList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){
  239 + dispatch_async(dispatch_get_main_queue(), ^{
  240 + if(hudView != nil) {
  241 + [hudView hideAnimated:true];
  242 + }
  243 + });
  244 + MyGroupViewController __weak *weakSelf = self;
  245 + [weakSelf updateTableData:array error:error];
  246 + [weakSelf.btSwitch setUserInteractionEnabled:true];
  247 + }];
  248 + }
  249 +}
  250 +
  251 +@end
LifeLog/LifeLog/MyGroupViewController.xib
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12118" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
  3 + <device id="retina4_7" orientation="portrait">
  4 + <adaptation id="fullscreen"/>
  5 + </device>
  6 + <dependencies>
  7 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
  8 + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
  9 + </dependencies>
  10 + <objects>
  11 + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MyGroupViewController">
  12 + <connections>
  13 + <outlet property="btShowGrp" destination="MvK-5R-njL" id="bcb-N7-jbu"/>
  14 + <outlet property="btSwitch" destination="eBu-7L-nsx" id="od6-v0-6eh"/>
  15 + <outlet property="lblActiveMode" destination="P1r-ft-imP" id="WRV-YQ-1IY"/>
  16 + <outlet property="lblGoal" destination="ftA-wa-19F" id="Ziv-cg-at5"/>
  17 + <outlet property="lblGroupName" destination="xXv-SO-m4h" id="yGe-lh-RC3"/>
  18 + <outlet property="tableBase" destination="ubS-v9-zCa" id="gea-9H-gpI"/>
  19 + <outlet property="tableGrp" destination="dtD-J5-dze" id="ahq-Cd-85X"/>
  20 + <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
  21 + </connections>
  22 + </placeholder>
  23 + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
  24 + <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
  25 + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
  26 + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
  27 + <subviews>
  28 + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vxT-xe-7mV" userLabel="ViewHeader">
  29 + <rect key="frame" x="0.0" y="0.0" width="375" height="46"/>
  30 + <subviews>
  31 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SNS" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Txe-1I-61m" customClass="AutoTransLabel">
  32 + <rect key="frame" x="0.0" y="0.0" width="375" height="46"/>
  33 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  34 + <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  35 + <nil key="highlightedColor"/>
  36 + <userDefinedRuntimeAttributes>
  37 + <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.grDetail.title"/>
  38 + </userDefinedRuntimeAttributes>
  39 + </label>
  40 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DjI-qB-WTG">
  41 + <rect key="frame" x="0.0" y="5" width="70" height="36"/>
  42 + <constraints>
  43 + <constraint firstAttribute="width" constant="70" id="Q1G-tI-sgx"/>
  44 + </constraints>
  45 + <state key="normal" image="today_back_button"/>
  46 + <connections>
  47 + <action selector="clickBack:" destination="-1" eventType="touchUpInside" id="93y-uZ-J2W"/>
  48 + </connections>
  49 + </button>
  50 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7gh-nf-sKZ">
  51 + <rect key="frame" x="330" y="0.0" width="45" height="46"/>
  52 + <constraints>
  53 + <constraint firstAttribute="width" constant="45" id="Vw3-60-kvV"/>
  54 + </constraints>
  55 + <state key="normal" image="icon_menu"/>
  56 + </button>
  57 + </subviews>
  58 + <color key="backgroundColor" red="0.098039215690000001" green="0.098039215690000001" blue="0.098039215690000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
  59 + <constraints>
  60 + <constraint firstAttribute="trailing" secondItem="7gh-nf-sKZ" secondAttribute="trailing" id="2JD-YU-WS2"/>
  61 + <constraint firstItem="Txe-1I-61m" firstAttribute="leading" secondItem="vxT-xe-7mV" secondAttribute="leading" id="30c-J3-6ba"/>
  62 + <constraint firstAttribute="bottom" secondItem="7gh-nf-sKZ" secondAttribute="bottom" id="61g-Gv-ka0"/>
  63 + <constraint firstAttribute="bottom" secondItem="Txe-1I-61m" secondAttribute="bottom" id="BZZ-wj-MGj"/>
  64 + <constraint firstItem="7gh-nf-sKZ" firstAttribute="top" secondItem="vxT-xe-7mV" secondAttribute="top" id="DKT-Ea-U3k"/>
  65 + <constraint firstAttribute="trailing" secondItem="Txe-1I-61m" secondAttribute="trailing" id="WA1-1W-49C"/>
  66 + <constraint firstItem="DjI-qB-WTG" firstAttribute="leading" secondItem="vxT-xe-7mV" secondAttribute="leading" id="tA3-JF-Kjj"/>
  67 + <constraint firstAttribute="bottom" secondItem="DjI-qB-WTG" secondAttribute="bottom" constant="5" id="uFc-I1-M2c"/>
  68 + <constraint firstItem="Txe-1I-61m" firstAttribute="top" secondItem="vxT-xe-7mV" secondAttribute="top" id="ucO-rK-wAV"/>
  69 + <constraint firstItem="DjI-qB-WTG" firstAttribute="top" secondItem="vxT-xe-7mV" secondAttribute="top" constant="5" id="vR3-xv-3hD"/>
  70 + <constraint firstAttribute="height" constant="46" id="yIJ-Mu-bPA"/>
  71 + </constraints>
  72 + </view>
  73 + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hhh-nO-yn5">
  74 + <rect key="frame" x="15" y="54" width="345" height="36"/>
  75 + <subviews>
  76 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MvK-5R-njL">
  77 + <rect key="frame" x="289" y="0.0" width="56" height="36"/>
  78 + <constraints>
  79 + <constraint firstAttribute="width" constant="56" id="l8Q-On-RNy"/>
  80 + </constraints>
  81 + <state key="normal" backgroundImage="arrow_down"/>
  82 + <connections>
  83 + <action selector="clickShowGrp:" destination="-1" eventType="touchUpInside" id="yfd-Yu-fTF"/>
  84 + </connections>
  85 + </button>
  86 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xXv-SO-m4h">
  87 + <rect key="frame" x="5" y="0.0" width="284" height="36"/>
  88 + <fontDescription key="fontDescription" type="system" pointSize="16"/>
  89 + <nil key="textColor"/>
  90 + <nil key="highlightedColor"/>
  91 + </label>
  92 + </subviews>
  93 + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  94 + <constraints>
  95 + <constraint firstAttribute="trailing" secondItem="MvK-5R-njL" secondAttribute="trailing" id="IS8-5J-ypb"/>
  96 + <constraint firstAttribute="bottom" secondItem="MvK-5R-njL" secondAttribute="bottom" id="IVS-f9-RjH"/>
  97 + <constraint firstAttribute="bottom" secondItem="xXv-SO-m4h" secondAttribute="bottom" id="Ino-7v-CKz"/>
  98 + <constraint firstItem="MvK-5R-njL" firstAttribute="top" secondItem="hhh-nO-yn5" secondAttribute="top" id="NlH-tz-ByC"/>
  99 + <constraint firstAttribute="height" constant="36" id="O8T-vH-tg6"/>
  100 + <constraint firstItem="MvK-5R-njL" firstAttribute="leading" secondItem="xXv-SO-m4h" secondAttribute="trailing" id="V51-fg-KCf"/>
  101 + <constraint firstItem="xXv-SO-m4h" firstAttribute="leading" secondItem="hhh-nO-yn5" secondAttribute="leading" constant="5" id="eY6-uq-qWx"/>
  102 + <constraint firstItem="xXv-SO-m4h" firstAttribute="top" secondItem="hhh-nO-yn5" secondAttribute="top" id="l3a-Th-4Kb"/>
  103 + </constraints>
  104 + <userDefinedRuntimeAttributes>
  105 + <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
  106 + <integer key="value" value="5"/>
  107 + </userDefinedRuntimeAttribute>
  108 + </userDefinedRuntimeAttributes>
  109 + </view>
  110 + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SNe-1B-nwV">
  111 + <rect key="frame" x="15" y="105" width="345" height="105"/>
  112 + <subviews>
  113 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ใ‚ฐใƒซใƒผใƒ— VMAP ใ‚ขใƒกใƒชใ‚ซใƒซใƒผใƒˆ๏ผ–๏ผ‘ๅฎŒ่ตฐ" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hyY-rU-WJx">
  114 + <rect key="frame" x="8" y="8" width="329" height="20"/>
  115 + <constraints>
  116 + <constraint firstAttribute="height" constant="20" id="dx4-Lw-gRP"/>
  117 + </constraints>
  118 + <fontDescription key="fontDescription" type="system" pointSize="15"/>
  119 + <nil key="textColor"/>
  120 + <nil key="highlightedColor"/>
  121 + </label>
  122 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="P1r-ft-imP">
  123 + <rect key="frame" x="8" y="36" width="155" height="61"/>
  124 + <constraints>
  125 + <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="61" id="6m3-4u-yjQ"/>
  126 + <constraint firstAttribute="width" constant="155" id="bJa-4P-B84"/>
  127 + </constraints>
  128 + <fontDescription key="fontDescription" type="system" pointSize="15"/>
  129 + <nil key="textColor"/>
  130 + <nil key="highlightedColor"/>
  131 + </label>
  132 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fXA-Zh-ABB" customClass="AutoTransButton">
  133 + <rect key="frame" x="171" y="67" width="166" height="30"/>
  134 + <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
  135 + <constraints>
  136 + <constraint firstAttribute="height" constant="30" id="4bu-TU-hhR"/>
  137 + <constraint firstAttribute="width" constant="166" id="hcm-Nd-TE4"/>
  138 + </constraints>
  139 + <state key="normal" title="VMAP">
  140 + <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  141 + </state>
  142 + <userDefinedRuntimeAttributes>
  143 + <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
  144 + <integer key="value" value="10"/>
  145 + </userDefinedRuntimeAttribute>
  146 + </userDefinedRuntimeAttributes>
  147 + </button>
  148 + </subviews>
  149 + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  150 + <constraints>
  151 + <constraint firstItem="P1r-ft-imP" firstAttribute="leading" secondItem="SNe-1B-nwV" secondAttribute="leading" constant="8" id="PCO-gJ-aUC"/>
  152 + <constraint firstItem="P1r-ft-imP" firstAttribute="top" secondItem="hyY-rU-WJx" secondAttribute="bottom" constant="8" id="TFE-rm-YuC"/>
  153 + <constraint firstItem="hyY-rU-WJx" firstAttribute="leading" secondItem="SNe-1B-nwV" secondAttribute="leading" constant="8" id="Urc-sV-0AF"/>
  154 + <constraint firstAttribute="bottom" secondItem="P1r-ft-imP" secondAttribute="bottom" constant="8" id="YYl-bN-XH2"/>
  155 + <constraint firstItem="hyY-rU-WJx" firstAttribute="top" secondItem="SNe-1B-nwV" secondAttribute="top" constant="8" id="a68-ja-X4x"/>
  156 + <constraint firstAttribute="trailing" secondItem="fXA-Zh-ABB" secondAttribute="trailing" constant="8" id="hNz-cE-JQc"/>
  157 + <constraint firstAttribute="trailing" secondItem="hyY-rU-WJx" secondAttribute="trailing" constant="8" id="tHp-Xw-Emj"/>
  158 + <constraint firstAttribute="bottom" secondItem="fXA-Zh-ABB" secondAttribute="bottom" constant="8" id="vRs-Al-kct"/>
  159 + </constraints>
  160 + </view>
  161 + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ftA-wa-19F">
  162 + <rect key="frame" x="15" y="218" width="345" height="100"/>
  163 + <constraints>
  164 + <constraint firstAttribute="height" constant="100" id="sns-tn-c0d"/>
  165 + </constraints>
  166 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  167 + <nil key="textColor"/>
  168 + <nil key="highlightedColor"/>
  169 + </label>
  170 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eBu-7L-nsx" customClass="AutoTransButton">
  171 + <rect key="frame" x="194" y="328" width="166" height="30"/>
  172 + <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
  173 + <constraints>
  174 + <constraint firstAttribute="width" constant="166" id="Rrn-lf-raV"/>
  175 + <constraint firstAttribute="height" constant="30" id="y2E-RH-aan"/>
  176 + </constraints>
  177 + <state key="normal" title="ใƒกใƒณใƒใƒผ">
  178 + <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  179 + </state>
  180 + <userDefinedRuntimeAttributes>
  181 + <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
  182 + <integer key="value" value="10"/>
  183 + </userDefinedRuntimeAttribute>
  184 + </userDefinedRuntimeAttributes>
  185 + <connections>
  186 + <action selector="clickSwitch:" destination="-1" eventType="touchUpInside" id="B7a-Hl-IlY"/>
  187 + </connections>
  188 + </button>
  189 + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="100" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="ubS-v9-zCa">
  190 + <rect key="frame" x="0.0" y="373" width="375" height="244"/>
  191 + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
  192 + <connections>
  193 + <outlet property="dataSource" destination="-1" id="HIG-w5-mXN"/>
  194 + <outlet property="delegate" destination="-1" id="GIa-bX-Av9"/>
  195 + </connections>
  196 + </tableView>
  197 + <tableView hidden="YES" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="35" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="dtD-J5-dze">
  198 + <rect key="frame" x="15" y="91" width="345" height="140"/>
  199 + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
  200 + <constraints>
  201 + <constraint firstAttribute="height" constant="140" id="CrG-Ni-f6b"/>
  202 + </constraints>
  203 + <connections>
  204 + <outlet property="dataSource" destination="-1" id="2bH-mm-vKH"/>
  205 + <outlet property="delegate" destination="-1" id="9tr-mh-5Ir"/>
  206 + </connections>
  207 + </tableView>
  208 + </subviews>
  209 + <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
  210 + <constraints>
  211 + <constraint firstItem="ftA-wa-19F" firstAttribute="top" secondItem="SNe-1B-nwV" secondAttribute="bottom" constant="8" id="4iN-BW-Eaa"/>
  212 + <constraint firstItem="vxT-xe-7mV" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="5np-jI-7iK"/>
  213 + <constraint firstAttribute="trailing" secondItem="eBu-7L-nsx" secondAttribute="trailing" constant="15" id="AkN-Cv-ULu"/>
  214 + <constraint firstItem="SNe-1B-nwV" firstAttribute="top" secondItem="hhh-nO-yn5" secondAttribute="bottom" constant="15" id="BL0-Cv-jlz"/>
  215 + <constraint firstItem="ubS-v9-zCa" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="Dt8-xl-lI8"/>
  216 + <constraint firstAttribute="trailing" secondItem="SNe-1B-nwV" secondAttribute="trailing" constant="15" id="QiL-ts-ryc"/>
  217 + <constraint firstItem="dtD-J5-dze" firstAttribute="top" secondItem="hhh-nO-yn5" secondAttribute="bottom" constant="1" id="QzJ-aS-NQ0"/>
  218 + <constraint firstItem="SNe-1B-nwV" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="15" id="T4b-fq-Gc8"/>
  219 + <constraint firstAttribute="trailing" secondItem="hhh-nO-yn5" secondAttribute="trailing" constant="15" id="YB3-2b-4yx"/>
  220 + <constraint firstAttribute="bottom" secondItem="ubS-v9-zCa" secondAttribute="bottom" constant="50" id="ZNH-0B-rWz"/>
  221 + <constraint firstItem="ftA-wa-19F" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="15" id="bnx-K2-jVS"/>
  222 + <constraint firstAttribute="trailing" secondItem="ubS-v9-zCa" secondAttribute="trailing" id="bsK-wi-RYU"/>
  223 + <constraint firstAttribute="trailing" secondItem="vxT-xe-7mV" secondAttribute="trailing" id="eld-fc-V95"/>
  224 + <constraint firstItem="hhh-nO-yn5" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="15" id="gDN-Hr-2vm"/>
  225 + <constraint firstItem="vxT-xe-7mV" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="iBy-99-6Ky"/>
  226 + <constraint firstItem="dtD-J5-dze" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="15" id="ie5-ll-WkY"/>
  227 + <constraint firstAttribute="trailing" secondItem="ftA-wa-19F" secondAttribute="trailing" constant="15" id="jaz-L9-glj"/>
  228 + <constraint firstItem="eBu-7L-nsx" firstAttribute="top" secondItem="ftA-wa-19F" secondAttribute="bottom" constant="10" id="lF2-iL-Xa6"/>
  229 + <constraint firstItem="ubS-v9-zCa" firstAttribute="top" secondItem="eBu-7L-nsx" secondAttribute="bottom" constant="15" id="ofF-9P-pq9"/>
  230 + <constraint firstItem="hhh-nO-yn5" firstAttribute="top" secondItem="vxT-xe-7mV" secondAttribute="bottom" constant="8" id="qIL-RX-3zl"/>
  231 + <constraint firstAttribute="trailing" secondItem="dtD-J5-dze" secondAttribute="trailing" constant="15" id="uHa-ot-bT0"/>
  232 + </constraints>
  233 + <point key="canvasLocation" x="24.5" y="52.5"/>
  234 + </view>
  235 + </objects>
  236 + <resources>
  237 + <image name="arrow_down" width="28" height="18"/>
  238 + <image name="icon_menu" width="30" height="30"/>
  239 + <image name="today_back_button" width="73" height="37"/>
  240 + </resources>
  241 +</document>
LifeLog/LifeLog/SNSViewController.m
... ... @@ -14,6 +14,7 @@
14 14 #import "Utilities.h"
15 15  
16 16 #import "SNSRecentTopicTableViewCell.h"
  17 +#import "MyGroupViewController.h"
17 18 #import "SearchGroupViewController.h"
18 19 #import "GroupDetailViewController.h"
19 20  
... ... @@ -46,8 +47,8 @@
46 47 }
47 48  
48 49 - (IBAction)clickMyGroup:(id)sender {
49   -// GroupDetailViewController * detail = [[GroupDetailViewController alloc] init];
50   -// [self.navigationController pushViewController:detail animated:true];
  50 + MyGroupViewController * myGrp = [[MyGroupViewController alloc] init];
  51 + [self.navigationController pushViewController:myGrp animated:true];
51 52 }
52 53  
53 54 #pragma mark UITableView Delegate
LifeLog/LifeLog/ServerAPI.h
... ... @@ -35,6 +35,7 @@
35 35 - (void) requestHistoryList:(NSString *)token withType:(int)type andMode:(int) mode AtPage:(int) page CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
36 36 - (void) requestJoinGroup:(NSString *)token groupID: (int) groupID CompletionHandler:(void (^)(NSError *)) completion;
37 37 -(void) requestCreateGroup:(NSString *)token withGroup:(GroupObject *)group CompletionHandler:(void (^)(GroupObject *, NSError *)) completion;
  38 +- (void) requestGroupList:(NSString *)token CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
38 39  
39 40 #pragma mark - SNS Screen Function
40 41 /*
LifeLog/LifeLog/ServerAPI.m
... ... @@ -814,8 +814,7 @@
814 814 NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/join"];
815 815 NSLog(@"requestJoinGroup link %@", url);
816 816  
817   - searchTask = [self _request:url method:@"POST" token:token paras:@{@"group_id": [NSNumber numberWithInt:groupID]} completion:^(NSData *data, NSError *error) {
818   - searchTask = nil;
  817 + [self _request:url method:@"POST" token:token paras:@{@"group_id": [NSNumber numberWithInt:groupID]} completion:^(NSData *data, NSError *error) {
819 818 if (completion == NULL) {
820 819 return ;
821 820 }
... ... @@ -854,6 +853,58 @@
854 853 }];
855 854 }
856 855  
  856 +- (void) requestGroupList:(NSString *)token CompletionHandler:(void (^)(NSArray *, NSError *)) completion {
  857 + NSString *url = [kServerAddress stringByAppendingFormat:@"api/groups/list"];
  858 + NSLog(@"requestGroupList link %@", url);
  859 +
  860 + [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
  861 + if (completion == NULL) {
  862 + return ;
  863 + }
  864 +
  865 + if (error == nil)
  866 + {
  867 + NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
  868 + NSLog(@"%@", dataResult);
  869 + int status = [dataResult[@"status"] intValue];
  870 + if (status == 1) { // status = 1 success
  871 + if(dataResult[@"result"] != nil) {
  872 + NSArray * array = dataResult[@"result"];
  873 + NSMutableArray * arrayGroup = [[NSMutableArray alloc] init];
  874 + for(NSDictionary * dict in array) {
  875 + GroupObject * object = [[GroupObject alloc] initWithShortData:dict];
  876 + [arrayGroup addObject:object];
  877 + }
  878 + completion(arrayGroup, nil);
  879 + }
  880 + else {
  881 + NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
  882 + completion(nil, errorObject);
  883 + }
  884 + }
  885 + else {
  886 + NSString *message = dataResult[@"message"];
  887 + if (message == nil) {
  888 + message = @"Unknown error";
  889 + }
  890 +
  891 + if ([message isEqualToString:@"Token is invalid"]) {
  892 + [self performSelectorOnMainThread:@selector(checkToken) withObject:nil waitUntilDone:YES];
  893 + NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
  894 + [self requestGroupList:tokenNew CompletionHandler:completion];
  895 + }
  896 + else {
  897 + NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
  898 + completion(nil, errorObject);
  899 + }
  900 + }
  901 + }
  902 + else
  903 + {
  904 + completion(nil, error);
  905 + }
  906 + }];
  907 +}
857 908 #pragma mark - Common API
858 909 - (void)refreshToken: (NSString *)userID CompletionHandler:(void (^)(NSString *, NSError *))completion {
859 910 [self _request:[kServerAddress stringByAppendingFormat: @"refreshToken"] method:@"POST" token:@"" paras:@{@"userId":userID} completion:^(NSData *data, NSError *error) {