Skip to content

Commit eb88534

Browse files
committed
Added gravtar loading
1 parent 1d6a135 commit eb88534

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

Demo/Demo/RootViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ - (UIImage*)thumbnailGridView:(VCThumbnailGridView*)thumbnailGridView imageAtInd
101101
return [UIImage imageNamed:@"Icon.png"];
102102
}
103103

104+
- (NSString*)thumbnailGridView:(VCThumbnailGridView*)thumbnailGridView imageUrlAtIndex:(NSInteger)index
105+
{
106+
return [NSString stringWithString:@"http://gravatar.com/avatar/dbdebfdea3fb580bf9402c202f1fbcc9"];
107+
}
108+
104109
#pragma mark - VCThumbnailGridViewDelegate
105110

106111
- (void)thumbnailGridView:(VCThumbnailGridView*)thumbnailGridView didSelectThumbnailAtIndex:(NSInteger)index

VCThumbnailGridView/VCThumbnailButton.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ - (void)setImageUrl:(NSString*)url {
9797

9898
if (shouldShowActivityIndicator) {
9999
if (!activityIndicator) {
100-
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
100+
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
101101
activityIndicator.hidesWhenStopped = YES;
102102
activityIndicator.userInteractionEnabled = NO;
103103
}
@@ -162,6 +162,8 @@ - (void)setEditing:(BOOL)editing animated:(BOOL)animated
162162
#pragma mark - VCResponseFetchServiceDelegate Methods
163163

164164
-(void)didSucceedReceiveResponse:(NSObject<VCDataProcessorDelegate> *)response {
165+
[activityIndicator stopAnimating];
166+
165167
if ([response isKindOfClass:[VCImageResponseProcessor class]]) {
166168
UIImage *image = [(VCImageResponseProcessor*)response image];
167169
[imageButton setBackgroundImage:image
@@ -171,7 +173,7 @@ -(void)didSucceedReceiveResponse:(NSObject<VCDataProcessorDelegate> *)response {
171173
}
172174

173175
-(void)didFailReceiveResponse:(NSObject<VCDataProcessorDelegate> *)response {
174-
176+
[activityIndicator stopAnimating];
175177
}
176178

177179

VCThumbnailGridView/VCThumbnailGridView.m

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,30 +104,46 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
104104
}
105105

106106
// Configure the cell...
107-
NSInteger indexOfImage = indexPath.row * 4;
107+
int indexOfImage = indexPath.row * 4;
108108
if ([self.dataSource respondsToSelector:@selector(thumbnailGridView:imageAtIndex:)]) {
109109
if (indexOfImage < _numberOfThumbnails) {
110-
[cell.imageView1 setImage:[self.dataSource thumbnailGridView:self imageAtIndex:indexOfImage++]];
111-
cell.imageView1.tag = indexOfImage;
110+
[cell.imageView1 setImage:[self.dataSource thumbnailGridView:self imageAtIndex:indexOfImage]];
111+
cell.imageView1.tag = indexOfImage++;
112112
[cell.imageView1 addTarget:self withSelector:@selector(didTapImageThumbnail:)];
113113
}
114114
if (indexOfImage < _numberOfThumbnails) {
115-
[cell.imageView2 setImage:[self.dataSource thumbnailGridView:self imageAtIndex:indexOfImage++]];
116-
cell.imageView2.tag = indexOfImage;
115+
[cell.imageView2 setImage:[self.dataSource thumbnailGridView:self imageAtIndex:indexOfImage]];
116+
cell.imageView2.tag = indexOfImage++;
117117
[cell.imageView2 addTarget:self withSelector:@selector(didTapImageThumbnail:)];
118118
}
119119
if (indexOfImage < _numberOfThumbnails) {
120-
[cell.imageView3 setImage:[self.dataSource thumbnailGridView:self imageAtIndex:indexOfImage++]];
121-
cell.imageView3.tag = indexOfImage;
120+
[cell.imageView3 setImage:[self.dataSource thumbnailGridView:self imageAtIndex:indexOfImage]];
121+
cell.imageView3.tag = indexOfImage++;
122122
[cell.imageView3 addTarget:self withSelector:@selector(didTapImageThumbnail:)];
123123
}
124124
if (indexOfImage < _numberOfThumbnails) {
125-
[cell.imageView4 setImage:[self.dataSource thumbnailGridView:self imageAtIndex:indexOfImage++]];
126-
cell.imageView4.tag = indexOfImage;
125+
[cell.imageView4 setImage:[self.dataSource thumbnailGridView:self imageAtIndex:indexOfImage]];
126+
cell.imageView4.tag = indexOfImage++;
127127
[cell.imageView4 addTarget:self withSelector:@selector(didTapImageThumbnail:)];
128128
}
129129
}
130130

131+
indexOfImage = indexPath.row * 4;
132+
if ([self.dataSource respondsToSelector:@selector(thumbnailGridView:imageUrlAtIndex:)]) {
133+
if (indexOfImage < _numberOfThumbnails) {
134+
[cell.imageView1 setImageUrl:[self.dataSource thumbnailGridView:self imageUrlAtIndex:indexOfImage++]];
135+
}
136+
if (indexOfImage < _numberOfThumbnails) {
137+
[cell.imageView2 setImageUrl:[self.dataSource thumbnailGridView:self imageUrlAtIndex:indexOfImage++]];
138+
}
139+
if (indexOfImage < _numberOfThumbnails) {
140+
[cell.imageView3 setImageUrl:[self.dataSource thumbnailGridView:self imageUrlAtIndex:indexOfImage++]];
141+
}
142+
if (indexOfImage < _numberOfThumbnails) {
143+
[cell.imageView4 setImageUrl:[self.dataSource thumbnailGridView:self imageUrlAtIndex:indexOfImage++]];
144+
}
145+
}
146+
131147
return cell;
132148
}
133149

0 commit comments

Comments
 (0)