Commit 5cc9773c6d0a86e66862d362f0ce9c3874b0b04c
1 parent
73a5aaa681
Exists in
master
and in
1 other branch
Move fill data code from parent table view to child tableview cell
Showing 5 changed files with 41 additions and 63 deletions Side-by-side Diff
LifeLog/LifeLog/GroupDetailViewController.m
... | ... | @@ -151,33 +151,11 @@ |
151 | 151 | SNSRecentTopicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecentTopicCell"]; |
152 | 152 | if(isMemberList) { |
153 | 153 | MemberObject *object = [_curDataList objectAtIndex:indexPath.row]; |
154 | - if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
155 | - [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
156 | - } | |
157 | - else { | |
158 | - [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
159 | - } | |
160 | - cell.lblUsername.text = @""; | |
161 | - cell.lblDateTime.text = @""; | |
162 | - cell.lblDes.text = object.userName; | |
163 | - cell.lblMode.text = @""; | |
164 | - cell.lblDistance.text = @""; | |
165 | - cell.lblDuration.text = @""; | |
154 | + [cell setMemberData:object]; | |
166 | 155 | } |
167 | 156 | else { |
168 | 157 | TweetObject *object = [_curDataList objectAtIndex:indexPath.row]; |
169 | - if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
170 | - [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
171 | - } | |
172 | - else { | |
173 | - [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
174 | - } | |
175 | - cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm" locale:@""]; | |
176 | - cell.lblUsername.text = object.userName; | |
177 | - cell.lblDes.text = object.content; | |
178 | - cell.lblMode.text = object.mode; | |
179 | - cell.lblDistance.text = [NSString stringWithFormat:@"%.0f m", object.distance]; | |
180 | - cell.lblDuration.text = object.time; | |
158 | + [cell setTweetsData:object]; | |
181 | 159 | } |
182 | 160 | |
183 | 161 | return cell; |
LifeLog/LifeLog/MyGroupViewController.m
... | ... | @@ -7,7 +7,6 @@ |
7 | 7 | // |
8 | 8 | |
9 | 9 | #import "MyGroupViewController.h" |
10 | -#import <SDWebImage/UIImageView+WebCache.h> | |
11 | 10 | |
12 | 11 | #import "Utilities.h" |
13 | 12 | #import "ServerAPI.h" |
14 | 13 | |
... | ... | @@ -85,33 +84,11 @@ |
85 | 84 | SNSRecentTopicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecentTopicCell"]; |
86 | 85 | if(isMemberList) { |
87 | 86 | MemberObject *object = [_curDataList objectAtIndex:indexPath.row]; |
88 | - if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
89 | - [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
90 | - } | |
91 | - else { | |
92 | - [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
93 | - } | |
94 | - cell.lblUsername.text = @""; | |
95 | - cell.lblDateTime.text = @""; | |
96 | - cell.lblDes.text = object.userName; | |
97 | - cell.lblMode.text = @""; | |
98 | - cell.lblDistance.text = @""; | |
99 | - cell.lblDuration.text = @""; | |
87 | + [cell setMemberData:object]; | |
100 | 88 | } |
101 | 89 | else { |
102 | 90 | TweetObject *object = [_curDataList objectAtIndex:indexPath.row]; |
103 | - if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
104 | - [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
105 | - } | |
106 | - else { | |
107 | - [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
108 | - } | |
109 | - cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm" locale:@""]; | |
110 | - cell.lblUsername.text = object.userName; | |
111 | - cell.lblDes.text = object.content; | |
112 | - cell.lblMode.text = object.mode; | |
113 | - cell.lblDistance.text = [NSString stringWithFormat:@"%.0f m", object.distance]; | |
114 | - cell.lblDuration.text = object.time; | |
91 | + [cell setTweetsData:object]; | |
115 | 92 | } |
116 | 93 | return cell; |
117 | 94 | } |
LifeLog/LifeLog/SNSRecentTopicTableViewCell.h
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | // |
8 | 8 | |
9 | 9 | #import <UIKit/UIKit.h> |
10 | +#import "Entities.h" | |
10 | 11 | |
11 | 12 | @interface SNSRecentTopicTableViewCell : UITableViewCell |
12 | 13 | |
... | ... | @@ -18,5 +19,7 @@ |
18 | 19 | @property (weak, nonatomic) IBOutlet UILabel *lblDistance; |
19 | 20 | @property (weak, nonatomic) IBOutlet UILabel *lblDuration; |
20 | 21 | |
22 | +-(void) setMemberData : (MemberObject *) object; | |
23 | +-(void) setTweetsData : (TweetObject *) object; | |
21 | 24 | @end |
LifeLog/LifeLog/SNSRecentTopicTableViewCell.m
... | ... | @@ -7,7 +7,10 @@ |
7 | 7 | // |
8 | 8 | |
9 | 9 | #import "SNSRecentTopicTableViewCell.h" |
10 | +#import <SDWebImage/UIImageView+WebCache.h> | |
10 | 11 | |
12 | +#import "Utilities.h" | |
13 | + | |
11 | 14 | @implementation SNSRecentTopicTableViewCell |
12 | 15 | |
13 | 16 | - (void)awakeFromNib { |
... | ... | @@ -19,6 +22,36 @@ |
19 | 22 | [super setSelected:selected animated:animated]; |
20 | 23 | |
21 | 24 | // Configure the view for the selected state |
25 | +} | |
26 | + | |
27 | +-(void) setMemberData : (MemberObject *) object { | |
28 | + if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
29 | + [self.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
30 | + } | |
31 | + else { | |
32 | + [self.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
33 | + } | |
34 | + self.lblUsername.text = @""; | |
35 | + self.lblDateTime.text = @""; | |
36 | + self.lblDes.text = object.userName; | |
37 | + self.lblMode.text = @""; | |
38 | + self.lblDistance.text = @""; | |
39 | + self.lblDuration.text = @""; | |
40 | +} | |
41 | + | |
42 | +-(void) setTweetsData : (TweetObject *) object { | |
43 | + if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
44 | + [self.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
45 | + } | |
46 | + else { | |
47 | + [self.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
48 | + } | |
49 | + self.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm" locale:@""]; | |
50 | + self.lblUsername.text = object.userName; | |
51 | + self.lblDes.text = object.content; | |
52 | + self.lblMode.text = object.mode; | |
53 | + self.lblDistance.text = [NSString stringWithFormat:@"%.0f m", object.distance]; | |
54 | + self.lblDuration.text = object.time; | |
22 | 55 | } |
23 | 56 | |
24 | 57 | @end |
LifeLog/LifeLog/SNSViewController.m
... | ... | @@ -8,8 +8,6 @@ |
8 | 8 | |
9 | 9 | #import "SNSViewController.h" |
10 | 10 | |
11 | -#import <SDWebImage/UIImageView+WebCache.h> | |
12 | - | |
13 | 11 | #import "ServerAPI.h" |
14 | 12 | #import "Utilities.h" |
15 | 13 | |
... | ... | @@ -55,18 +53,7 @@ |
55 | 53 | - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
56 | 54 | SNSRecentTopicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecentTopicCell"]; |
57 | 55 | TweetObject *object = [_curDataList objectAtIndex:indexPath.row]; |
58 | - if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
59 | - [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
60 | - } | |
61 | - else { | |
62 | - [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
63 | - } | |
64 | - cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm" locale:@""]; | |
65 | - cell.lblUsername.text = object.userName; | |
66 | - cell.lblDes.text = object.content; | |
67 | - cell.lblMode.text = object.mode; | |
68 | - cell.lblDistance.text = [NSString stringWithFormat:@"%.0f m", object.distance]; | |
69 | - cell.lblDuration.text = object.time; | |
56 | + [cell setTweetsData:object]; | |
70 | 57 | return cell; |
71 | 58 | } |
72 | 59 |