-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdminRecomViewController.m
230 lines (185 loc) · 6.67 KB
/
AdminRecomViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
//
// AdminRecomViewController.m
// ImIn
//
// Created by Myungjin Choi on 11. 1. 18..
// Copyright 2011 KTH. All rights reserved.
//
#import "AdminRecomViewController.h"
#import "AdminRecomList.h"
#import "HomeInfo.h"
#import "UIImageView+WebCache.h"
//#import "MyFriendSetController.h"
#import "FriendSetViewController.h"
#import "ImInAppDelegate.h"
#import "UINeighborsViewController.h"
@implementation AdminRecomViewController
enum RECOM_VIEW {
RECOM_VIEW_1 = 1000,
RECOM_VIEW_2,
RECOM_VIEW_3
};
enum RECOM_INSIDE_VIEW {
RECOM_INSIDE_VIEW_PROFILE = 100,
RECOM_INSIDE_VIEW_NICKNAME,
RECOM_INSIDE_VIEW_NEIGHBORCNT,
RECOM_INSIDE_VIEW_POICNT,
RECOM_INSIDE_VIEW_NEIGHBORADDBTN
};
@synthesize profileImageURL, nickname, neigborCnt, poiCnt, snsId;
@synthesize adminRecomList, homeInfo;
@synthesize resultData;
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization.
}
return self;
}
*/
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationController setNavigationBarHidden:YES animated:NO];
NSNotificationCenter* dnc = [NSNotificationCenter defaultCenter];
[dnc addObserver:self selector:@selector(friendSettingChanged:) name:@"FriendSetSaved" object:savedData];
self.adminRecomList = [[[AdminRecomList alloc] init] autorelease];
adminRecomList.delegate = self;
[adminRecomList request];
}
- (void) viewWillAppear:(BOOL)animated
{
}
- (void) apiDidLoad: (NSDictionary*) result
{
if ([[result objectForKey:@"func"] isEqualToString:@"adminRecomList"]) {
NSInteger viewTag = 1000;
NSArray* dataList = [result objectForKey:@"data"];
self.resultData = dataList;
for (NSDictionary *data in dataList)
{
UIView* aView = [self.view viewWithTag:viewTag++];
UIImageView* profileImg = (UIImageView*)[aView viewWithTag:RECOM_INSIDE_VIEW_PROFILE];
NSString* profileUrl = [data objectForKey:@"profileImg"];
[profileImg setImageWithURL:[NSURL URLWithString:profileUrl]
placeholderImage:[UIImage imageNamed:@"delay_nosum70.png"]];
UILabel* nickName = (UILabel*)[aView viewWithTag:RECOM_INSIDE_VIEW_NICKNAME];
nickName.text = [data objectForKey:@"nickname"];
UILabel* neigborCount = (UILabel*)[aView viewWithTag:RECOM_INSIDE_VIEW_NEIGHBORCNT];
neigborCount.text = [NSString stringWithFormat:@"이웃 %@", [data objectForKey:@"totalNeighborCnt"]];
UILabel* poiCount = (UILabel*)[aView viewWithTag:RECOM_INSIDE_VIEW_POICNT];
poiCount.text = [NSString stringWithFormat:@"발도장 %@", [data objectForKey:@"totalPoiCnt"]];
}
}
if ([[result objectForKey:@"func"] isEqualToString:@"homeInfo"]) {
NSString *whoIs = [result objectForKey:@"isPerm"];
NSString* profileUrl = [result objectForKey:@"profileImg"];
// 서로 이웃인지 여부를 확인해서 표시한다.
if( [whoIs isEqualToString:@"FRIEND"] ){
friendCodeInt = FR_TRUE;
}else if( [whoIs isEqualToString:@"NEIGHBOR_YOU"] ){ // 당신이 그를 친구로 등록했다.
friendCodeInt = FR_ME;
}else if( [whoIs isEqualToString:@"NEIGHBOR_ME"] ){
friendCodeInt = FR_YOU;
}else{
friendCodeInt = FR_NONE;
}
FriendSetViewController *friendSetViewController = [[FriendSetViewController alloc] initWithName:self.nickname
friendSnsId:self.snsId
friendCode:friendCodeInt
friendImage:profileUrl];
friendSetViewController.referCode = @"0002";
[friendSetViewController setHidesBottomBarWhenPushed:YES];
[self.navigationController pushViewController:friendSetViewController animated:YES];
[friendSetViewController release];
}
}
- (void) friendSettingChanged:(NSNotification*) noti
{
MY_LOG(@"노티왔다");
NSDictionary* saveResult = [noti userInfo];
MY_LOG(@"bool: %@ snsid: %@", [saveResult objectForKey:@"isFollowing"], [saveResult objectForKey:@"snsId"]);
for (int i=0; i < 3; i++) {
NSDictionary* data = [resultData objectAtIndex:i];
if ([[data objectForKey:@"snsId"] isEqualToString:[saveResult objectForKey:@"snsId"]]) {
UIButton* aButton;
switch (i % 3) {
case 0:
aButton = firstNeigborAdd;
break;
case 1:
aButton = secondNeigborAdd;
break;
case 2:
aButton = thirdNeigborAdd;
break;
default:
break;
}
if ([[saveResult objectForKey:@"isFollowing"] boolValue]) {
[aButton setImage:[UIImage imageNamed:@"friend_friend_admin.png"] forState:UIControlStateNormal];
} else {
[aButton setImage:[UIImage imageNamed:@"friend_friend_admin.png"] forState:UIControlStateNormal];
}
}
}
}
- (void) apiFailed {
MY_LOG(@"API 에러");
}
- (IBAction) pushFriendSetting:(UIButton*) sender
{
GA3(@"이런이웃", @"이웃추가버튼", @"이런이웃내");
NSDictionary* data = [resultData objectAtIndex: sender.tag - 10];
self.snsId = [data objectForKey:@"snsId"];
self.nickname = [data objectForKey:@"nickname"];
self.homeInfo = [[[HomeInfo alloc] init] autorelease];
homeInfo.delegate = self;
homeInfo.snsId = snsId;
[homeInfo request];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc. that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
NSNotificationCenter* dnc = [NSNotificationCenter defaultCenter];
[dnc removeObserver:self name:@"FriendSetSaved" object:savedData];
[profileImageURL release];
[snsId release];
[nickname release];
[neigborCnt release];
[poiCnt release];
[adminRecomList release];
[homeInfo release];
[resultData release];
[super dealloc];
}
-(IBAction) closeVC
{
GA3(@"이런이웃", @"건너뛰기", nil);
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction) goNeighbor
{
GA3(@"이런이웃", @"더많은이웃만들기", nil);
[ViewControllers sharedViewControllers].tabBarController.selectedIndex = 1;
UINeighborsViewController* neighborVC = (UINeighborsViewController*)([ViewControllers sharedViewControllers].neighbersViewController);
neighborVC.selectedSegInt = 2;
[self dismissModalViewControllerAnimated:YES];
}
@end