前往主控台

FirebaseModelManager

public class FirebaseModelManager extends Object

Manages the registration of remote and local models.

Before using a model, register it with FirebaseModelManager. The model name is the key for a model, and a model name can only be registered once.

For the remote model's name, use the same name as the model that's been uploaded to the Firebase console.

This class is thread safe.

Public Method Summary

Task<Void>
downloadRemoteModelIfNeeded(FirebaseRemoteModel remoteModel)
Initiates the download of remoteModel if the download hasn't begun.
synchronized static FirebaseModelManager
getInstance()
Gets an instance of a FirebaseModelManager corresponding to the default FirebaseApp instance.
synchronized boolean
registerLocalModel(FirebaseLocalModel localModel)
Registers a local model.
synchronized boolean
registerRemoteModel(FirebaseRemoteModel remoteModel)
Registers a remote model.

Inherited Method Summary

Public Methods

public Task<Void> downloadRemoteModelIfNeeded (FirebaseRemoteModel remoteModel)

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

The {@code remoteModel} must be first registered with registerRemoteModel(FirebaseRemoteModel). And the download conditions for the model are determined at registration time.

If the model update is enabled in enableModelUpdates(boolean), and there is an update available, the task to download the update will be returned.

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 or update is disabled, the task will immediately succeed.

If remoteModel is not registered with this FirebaseModelManager, the returned task will fail immediately.

Returns
  • The task for the remoteModel download.

public static synchronized FirebaseModelManager getInstance ()

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

public synchronized boolean registerLocalModel (FirebaseLocalModel localModel)

Registers a local model. Local models are keyed by model names, and each model name can be registered at most once.

Returns
  • false if the model name is already registered. True if registration succeeds.
Throws
NullPointerException if localModel is null.

public synchronized boolean registerRemoteModel (FirebaseRemoteModel remoteModel)

Registers a remote model. Upon registration, the remoteModel's download conditions will be remembered by this FirebaseModelManager and cannot be changed. Remote models are the models that are downloaded and used on devices. The remote models are keyed by model names, and each model name can be registered at most once.

For the remote model's name, use the same name as the model that's been uploaded to the Firebase console.

Returns
  • false if the model name is already registered. True if registration succeeds.
Throws
NullPointerException if remoteModel is null.