public class Main
extends java.lang.Object
Constructor | Description |
---|---|
Main() |
Modifier and Type | Method | Description |
---|---|---|
private static java.lang.String |
buildJSONUrl(java.lang.String baseUrl) |
This method builds the full JSON url by adding the formatted date to the base url
|
private static void |
changeDesktopBackground(java.lang.String path) |
This method changes the user's desktop background to the image located at
the specified path
|
private static int |
chooseImageSize(int[] sizeOptions) |
This method chooses an appropriate image size from a list of options
based on which is closest to the user's display resolution.
|
private static java.lang.String |
createFilePath() |
This method determines the exact file path of the downloaded image
primarily based on the current date.
|
private static java.lang.String |
downloadImage(java.lang.String strImageUrl) |
This method takes the url of the image and downloads it to the user's
filesystem in a specified location.
|
private static java.lang.String |
getUrl(java.lang.String jsonUrl,
int displayWidth) |
This methods downloads and parses the provided JSON file, and locates the
url of the appropriate image.
|
static void |
main(java.lang.String[] args) |
The constructor method calls all other methods in the program
|
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- Unusedjava.lang.Exception
- on connection errorprivate static java.lang.String buildJSONUrl(java.lang.String baseUrl)
baseUrl
- The base of the url without the dateprivate static int chooseImageSize(int[] sizeOptions)
sizeOptions
- The available options for image sizeprivate static java.lang.String getUrl(java.lang.String jsonUrl, int displayWidth) throws java.lang.Exception
jsonUrl
- The base url stringdisplayWidth
- The width of user's displayjava.lang.Exception
- on connection errorprivate static java.lang.String downloadImage(java.lang.String strImageUrl)
strImageUrl
- The url location of the imageprivate static void changeDesktopBackground(java.lang.String path)
path
- The path of the image to be usedprivate static java.lang.String createFilePath()