Class DownloadHelper

java.lang.Object
gaiasky.util.DownloadHelper

public class DownloadHelper extends Object
  • Constructor Details

    • DownloadHelper

      public DownloadHelper()
  • Method Details

    • checkInternetConnection

      public static void checkInternetConnection(Runnable success, Runnable fail)
      Checks for an internet connection and runs the appropriate runnable depending on the outcome.
      Parameters:
      success - Success runnable.
      fail - Failure runnable.
    • 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 progress ProgressRunnable while downloading, and running the finish Runnable when 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 given Net.HttpRequest with 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.