Google is committed to advancing racial equity for Black communities. See how.

FirebaseModelManager

public class FirebaseModelManager extends Object

Manages the remote models.

Before using a remote model, download it with FirebaseModelManager. The model name is the key for a model. The model name should be consistent with the name of the model that has been uploaded to the Firebase console.

This class is thread safe.

Public Method Summary

Task<Void>
deleteDownloadedModel(FirebaseRemoteModel remoteModel)
Deletes the given remoteModel from disk.
Task<Void>
download(FirebaseRemoteModel remoteModel, FirebaseModelDownloadConditions downloadConditions)
Initiates the download of remoteModel if the download hasn't begun.
<T extends FirebaseRemoteModel> Task<Set<T>>
getDownloadedModels(Class<T> modelType)
Returns the set of all currently downloaded models of the given modelType.
synchronized static FirebaseModelManager
getInstance()
Gets an instance of a FirebaseModelManager corresponding to the default FirebaseApp instance.
synchronized static FirebaseModelManager
getInstance(FirebaseApp firebaseApp)
Gets an instance of a FirebaseModelManager corresponding to the given FirebaseApp instance.
Task<File>
getLatestModelFile(FirebaseRemoteModel remoteModel)
Returns the File containing the latest model for the remote model name.
Task<Boolean>
isModelDownloaded(FirebaseRemoteModel remoteModel)
Returns whether the given remoteModel is currently downloaded.

Inherited Method Summary

Public Methods

public Task<Void> deleteDownloadedModel (FirebaseRemoteModel remoteModel)

Deletes the given remoteModel from disk. Does nothing if the model is not downloaded.

public Task<Void> download (FirebaseRemoteModel remoteModel, FirebaseModelDownloadConditions downloadConditions)

Initiates the download of remoteModel if the download hasn't begun.

If the model's download is already in progress, the current download task will be returned.

If the model is already downloaded to the device, and there is no update, the task will immediately succeed.

If the model is already downloaded to the device, and there is update, a download for the updated version will be attempted.

Returns
  • The task for the remoteModel download.

public Task<Set<T>> getDownloadedModels (Class<T> modelType)

Returns the set of all currently downloaded models of the given modelType.

public static synchronized FirebaseModelManager getInstance ()

Gets an instance of a FirebaseModelManager corresponding to the default FirebaseApp instance.

public static synchronized FirebaseModelManager getInstance (FirebaseApp firebaseApp)

Gets an instance of a FirebaseModelManager corresponding to the given FirebaseApp instance.

public Task<File> getLatestModelFile (FirebaseRemoteModel remoteModel)

Returns the File containing the latest model for the remote model name. If no model file was downloaded yet then the file will be null.

public Task<Boolean> isModelDownloaded (FirebaseRemoteModel remoteModel)

Returns whether the given remoteModel is currently downloaded.