Skip to content

Commit

Permalink
Load gravatars with a size suitable for high-resolution displays
Browse files Browse the repository at this point in the history
  • Loading branch information
aharren authored and Dennis Blöte committed Aug 22, 2010
1 parent 111567e commit fe826f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Classes/AppConstants.h
Expand Up @@ -65,6 +65,9 @@
#define kIssueBodyParamName @"body"
#define kIssueCommentCommentParamName @"comment"

// Images
#define kImageGravatarMaxLogicalSize 44

// Following/Watching
#define kFollow @"follow"
#define kUnFollow @"unfollow"
Expand Down
11 changes: 9 additions & 2 deletions Classes/GHUser.m
Expand Up @@ -167,6 +167,13 @@ - (void)parseXMLWithToken:(NSString *)token {
[pool release];
}

- (NSInteger)gravatarSize {
UIScreen *mainScreen = [UIScreen mainScreen];
CGFloat deviceScale = ([mainScreen respondsToSelector:@selector(scale)]) ? [mainScreen scale] : 1.0;
NSInteger size = kImageGravatarMaxLogicalSize * MAX(deviceScale, 1.0);
return size;
}

- (void)loadedUsers:(id)theResult {
if ([theResult isKindOfClass:[NSError class]]) {
self.error = theResult;
Expand All @@ -184,8 +191,8 @@ - (void)loadedUsers:(id)theResult {
self.publicRepoCount = user.publicRepoCount;
self.privateRepoCount = user.privateRepoCount;
self.isAuthenticated = user.isAuthenticated;
if (gravatarHash) [gravatarLoader loadHash:gravatarHash withSize:44];
else if (email) [gravatarLoader loadEmail:email withSize:44];
if (gravatarHash) [gravatarLoader loadHash:gravatarHash withSize:[self gravatarSize]];
else if (email) [gravatarLoader loadEmail:email withSize:[self gravatarSize]];
}
self.loadingStatus = GHResourceStatusLoaded;
}
Expand Down
1 change: 0 additions & 1 deletion IBFiles/User.xib
Expand Up @@ -118,7 +118,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bytes key="NSWhite">MQA</bytes>
</object>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<int key="IBUIContentMode">4</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
Expand Down

0 comments on commit fe826f6

Please sign in to comment.