Class DownloadHelper
java.lang.Object
gaiasky.util.DownloadHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckInternetConnection(Runnable success, Runnable fail) Checks for an internet connection and runs the appropriate runnable depending on the outcome.static com.badlogic.gdx.Net.HttpRequestdownloadFile(String url, com.badlogic.gdx.files.FileHandle to, boolean offlineMode, ProgressRunnable progressDownload, ProgressRunnable progressHashResume, Consumer<String> finish, Runnable fail, Runnable cancel) Spawns a new thread which downloads the file from the given location, running the progressProgressRunnablewhile downloading, and running the finishRunnablewhen finished.static voidsendRequest(com.badlogic.gdx.Net.HttpRequest request, String url, boolean resume, com.badlogic.gdx.files.FileHandle to, long startSize, ProgressRunnable progressDownload, ProgressRunnable progressHashResume, Consumer<String> finish, Runnable fail, Runnable cancel) Send the givenNet.HttpRequestwith the given parameters.
-
Constructor Details
-
DownloadHelper
public DownloadHelper()
-
-
Method Details
-
checkInternetConnection
-
downloadFile
public static com.badlogic.gdx.Net.HttpRequest downloadFile(String url, com.badlogic.gdx.files.FileHandle to, boolean offlineMode, ProgressRunnable progressDownload, ProgressRunnable progressHashResume, Consumer<String> finish, Runnable fail, Runnable cancel) Spawns a new thread which downloads the file from the given location, running the progressProgressRunnablewhile downloading, and running the finishRunnablewhen finished. -
sendRequest
public static void sendRequest(com.badlogic.gdx.Net.HttpRequest request, String url, boolean resume, com.badlogic.gdx.files.FileHandle to, long startSize, ProgressRunnable progressDownload, ProgressRunnable progressHashResume, Consumer<String> finish, Runnable fail, Runnable cancel) Send the givenNet.HttpRequestwith the given parameters.- Parameters:
request- The request.url- The URL.resume- Whether to resume past downloads.to- File to save the response.startSize- Partial start size.progressDownload- Runnable to run during download progress.progressHashResume- Runnable to run during hashing progress.finish- Runnable to run if the download finished successfully.fail- Runnable to run if the download failed.cancel- Runnable to run if the download was cancelled.
-