Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contributer image fix #2209

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/src/main/assets/contributors/face_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/contributors/face_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/contributors/face_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/contributors/face_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/contributors/face_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/contributors/face_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/assets/contributors/face_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ private static void appendCategory(StringBuilder output, String name, String con
.append("\"\n\t\tlink=\"").append(link).append("\" />");
}

public static String setPlaceholderImage() {
Random random = new Random();
int randomImage = random.nextInt(1, 3);
return "assets://contributors/face_" + randomImage + ".png";

public static String setPlaceholderImage(int temp) {
//set random image to last digit of temp
int lastDigit = Math.abs(temp % 10);
return "assets://contributors/face_" + lastDigit + ".png";
}

public static void extractImageUrls(StringBuilder output, String contributorsXml, String assetsDir) {
Expand All @@ -109,7 +108,7 @@ public static void extractImageUrls(StringBuilder output, String contributorsXml
imageURL = link + ".png";
}
if (imageURL.isEmpty()) {
imageURL = setPlaceholderImage();
imageURL = setPlaceholderImage(temp);
appendCategory(output, name, contribution, imageURL, link);
} else if (link.startsWith("assets://")) {
appendCategory(output, name, contribution, imageURL, link);
Expand All @@ -121,7 +120,7 @@ public static void extractImageUrls(StringBuilder output, String contributorsXml
saveImage(image, imageName, assetsDir);
appendCategory(output, name, contribution, imageURL, link);
} else {
imageURL = setPlaceholderImage();
imageURL = setPlaceholderImage(temp);
appendCategory(output, name, contribution, imageURL, link);
}
}
Expand Down