Class DatasetDownloadService

java.lang.Object
gaiasky.gui.datasets.DatasetDownloadService

public class DatasetDownloadService extends Object
Headless dataset download service. Contains the full download-install pipeline (disk space check, download with progress, checksum verification, extraction), decoupled from any UI. It publishes the Event#DATASET_DOWNLOAD_* events, consumed by the dataset manager window, and additionally Event.UPDATE_LOAD_PROGRESS events, consumed by the load progress interface, so that downloads started outside the dataset manager window (e.g. through a gaiasky:// URL) still show progress feedback.

UI-specific reactions (status updates in the dataset table, etc.) are delegated to a DatasetDownloadService.DownloadCallback provided by the caller.

  • Constructor Details

    • DatasetDownloadService

      public DatasetDownloadService(Map<String, Pair<Dataset, com.badlogic.gdx.Net.HttpRequest>> currentDownloads)
      Creates a new dataset download service.
      Parameters:
      currentDownloads - Map of downloads in progress, keyed by dataset key. Owned by the caller (typically the dataset manager window), and updated by this service.
  • Method Details

    • downloadDataset

      public void downloadDataset(Dataset dataset, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, com.badlogic.gdx.scenes.scene2d.Stage stage, Runnable successRunnable, DatasetDownloadService.DownloadCallback callback)
      Downloads and installs the given dataset. This is the full pipeline: disk space check, download with progress reporting, checksum verification and extraction. Progress is published through the Event.DATASET_DOWNLOAD_PROGRESS_INFO and Event.UPDATE_LOAD_PROGRESS events. UI-specific reactions are delegated to the given callback.
      Parameters:
      dataset - The dataset to download and install.
      skin - The UI skin, for error dialogs. May be null.
      stage - The UI stage, for error dialogs. May be null.
      successRunnable - Runnable to run after a successful install, before the callback. May be null.
      callback - The callback for UI-specific reactions. May be null.