Skip to content

Commit

Permalink
WPNetworkImageView now accepts a default error image resource, also f…
Browse files Browse the repository at this point in the history
…orcing size when showing blavatars in ReaderBlogAdapter
  • Loading branch information
nbradbury committed Feb 10, 2015
1 parent 06e9f21 commit 8436629
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import android.text.TextUtils;

/**
* see https://en.gravatar.com/site/implement/images/
*/
public class GravatarUtils {
/*
* see https://en.gravatar.com/site/implement/images/
*/

public static enum DefaultImage {
MYSTERY_MAN,
Expand Down Expand Up @@ -42,6 +42,9 @@ public String toString() {
* replace it with a new ?s= parameter which requests the avatar at the exact size needed
*/
public static String fixGravatarUrl(final String imageUrl, int avatarSz) {
return fixGravatarUrl(imageUrl, avatarSz, DefaultImage.MYSTERY_MAN);
}
public static String fixGravatarUrl(final String imageUrl, int avatarSz, DefaultImage defaultImage) {
if (TextUtils.isEmpty(imageUrl)) {
return "";
}
Expand All @@ -51,8 +54,8 @@ public static String fixGravatarUrl(final String imageUrl, int avatarSz) {
return PhotonUtils.getPhotonImageUrl(imageUrl, avatarSz, avatarSz);
}

// remove all other params, then add query string for size and "mystery man" default
return UrlUtils.removeQuery(imageUrl) + "?s=" + avatarSz + "&d=mm";
// remove all other params, then add query string for size and default image
return UrlUtils.removeQuery(imageUrl) + "?s=" + avatarSz + "&d=" + defaultImage.toString();
}

public static String gravatarFromEmail(final String email, int size) {
Expand Down

0 comments on commit 8436629

Please sign in to comment.