Commit fcfef587834b053465a872d4fbf1a6dcc7f93244
1 parent
03a8708ee3
Exists in
master
and in
1 other branch
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
- LifeLog/LifeLog/Assets.xcassets/History/arrow_down.imageset/Contents.json
- LifeLog/LifeLog/Assets.xcassets/History/arrow_down.imageset/arrow_down.png
- LifeLog/LifeLog/GroupDetailViewController.xib
- LifeLog/LifeLog/GroupObject.h
- LifeLog/LifeLog/GroupObject.m
- LifeLog/LifeLog/MyGroupViewController.h
- LifeLog/LifeLog/MyGroupViewController.m
- LifeLog/LifeLog/MyGroupViewController.xib
- LifeLog/LifeLog/SNSViewController.m
- LifeLog/LifeLog/ServerAPI.h
- LifeLog/LifeLog/ServerAPI.m
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"> | |