Class Geodatabase
- java.lang.Object
-
- com.esri.arcgisruntime.data.Geodatabase
-
- All Implemented Interfaces:
Loadable
public final class Geodatabase extends java.lang.Object implements Loadable
A mobile geodatabase containing offline feature data.The Geodatabase class is used for opening and accessing the contents of a mobile geodatabase. A geodatabase is either an offline copy of data from an ArcGIS service (created as a result of a GeodatabaseSyncTask), or can be created using ArcMap or ArcGIS Pro. The geodatabase contains one or more GeodatabaseFeatureTables. Each
GeodatabaseFeatureTable
contains attribute data. For spatial features, it also stores the geometry and rendering information.A GeodatabaseFeatureTable containing point, polyline or polygon features can be used to create a
FeatureLayer
. A GeodatabaseFeatureTable containing annotation features can be used to create anAnnotationLayer
. Both of these layer types can be added to a map and viewed with a map view.Geodatabase implements the loadable interface; the geodatabase feature tables can be accessed after the geodatabase has been loaded.
- Since:
- 100.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Geodatabase.TransactionStatusChangedEvent<S extends Geodatabase>
An event indicating that the transaction status has changed.static interface
Geodatabase.TransactionStatusChangedListener
Listens for the transaction status change when a transaction starts or ends (either committed or rolled back).
-
Constructor Summary
Constructors Constructor Description Geodatabase(java.lang.String geodatabasePath)
Creates a new Geodatabase instance from a geodatabase at the given path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDoneLoadingListener(java.lang.Runnable listener)
Adds a listener to the loadable resource that is invoked when loading has completed.void
addLoadStatusChangedListener(LoadStatusChangedListener listener)
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.void
addTransactionStatusChangedListener(Geodatabase.TransactionStatusChangedListener listener)
Adds aGeodatabase.TransactionStatusChangedListener
to the Geodatabase.void
beginTransaction()
Starts a new transaction on the geodatabase.void
cancelLoad()
Cancels loading metadata for the object.void
close()
Closes this geodatabase.void
commitTransaction()
Commits the current transaction on the geodatabase.static ListenableFuture<Geodatabase>
createAsync(java.lang.String path)
Creates an empty mobile geodatabase at the specified path.ListenableFuture<Domain>
createDomainAsync(DomainDescription domainDescription)
Creates a new domain in the geodatabase.ListenableFuture<GeodatabaseFeatureTable>
createTableAsync(TableDescription tableDescription)
Creates a new table in the geodatabase.ListenableFuture<java.lang.Void>
deleteDomainAsync(java.lang.String domainName)
Deletes the domain with the specified name from the geodatabase.ListenableFuture<java.lang.Void>
deleteTableAsync(java.lang.String tableName)
Deletes an existing table from the geodatabase.ListenableList<Domain>
getDomains()
Returns a list of the domains that exist in the geodatabase.Envelope
getGenerateGeodatabaseExtent()
Deprecated.As of 100.7.0, replaced bygetGenerateGeodatabaseGeometry()
.Geometry
getGenerateGeodatabaseGeometry()
GeodatabaseFeatureTable
getGeodatabaseAnnotationTable(java.lang.String name)
Gets a feature table containing annotation features from the geodatabase, as specified by the given name.GeodatabaseFeatureTable
getGeodatabaseAnnotationTableByServiceLayerId(int layerId)
Gets a feature table containing annotation features from the geodatabase, as specified by the given service layer ID.java.util.List<GeodatabaseFeatureTable>
getGeodatabaseAnnotationTables()
Gets an unmodifiable list of the geodatabase feature tables that contain annotation features.GeodatabaseFeatureTable
getGeodatabaseDimensionTable(long serviceLayerId)
Returns a feature table containing dimension features from the geodatabase, as specified by the given feature service layer ID.GeodatabaseFeatureTable
getGeodatabaseDimensionTable(java.lang.String tableName)
Returns a feature table containing dimension features from the geodatabase, as specified by the given tableName.java.util.List<GeodatabaseFeatureTable>
getGeodatabaseDimensionTables()
Gets the geodatabase feature tables that contain dimension features.GeodatabaseFeatureTable
getGeodatabaseFeatureTable(java.lang.String name)
Gets a feature table containing point, line or polygon features from the geodatabase, as specified by the given name.GeodatabaseFeatureTable
getGeodatabaseFeatureTableByServiceLayerId(int layerId)
Gets a feature table from the geodatabase containing point, line or polygon features, as specified by the given service layer ID.java.util.List<GeodatabaseFeatureTable>
getGeodatabaseFeatureTables()
Gets an unmodifiable list of the geodatabase feature tables that contain geometries such as points, lines or polygons.ArcGISRuntimeException
getLoadError()
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.LoadStatus
getLoadStatus()
Returns theLoadStatus
of the loadable resource.long
getMinServerGeneration()
Returns the minimum server generation number for the geodatabase.java.lang.String
getPath()
Returns the geodatabase path.java.lang.String
getServiceUrl()
Gets the URL of the service the geodatabase was created from.java.util.UUID
getSyncId()
Gets the sync ID of the geodatabase.SyncModel
getSyncModel()
Gets the sync model of the geodatabase.UtilityNetwork
getUtilityNetwork(java.lang.String utilityNetworkName)
Returns anUtilityNetwork
from the geodatabase with the specified utility network name.java.util.List<UtilityNetwork>
getUtilityNetworks()
Gets an unmodifiable list ofUtilityNetwork
objects that are packaged within the Geodatabase.boolean
hasLocalEdits()
Indicates if the geodatabase has local edits.boolean
isInTransaction()
Gets whether a transaction is active on the geodatabase.boolean
isSyncEnabled()
Indicates if sync is enabled for the geodatabase.void
loadAsync()
Loads the metadata of the loadable resource asynchronously.boolean
removeDoneLoadingListener(java.lang.Runnable listener)
Removes a done loading listener from the loadable resource.boolean
removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Removes aLoadStatusChangedListener
from the loadable resource.boolean
removeTransactionStatusChangedListener(Geodatabase.TransactionStatusChangedListener listener)
Removes theGeodatabase.TransactionStatusChangedListener
from the Geodatabase.void
retryLoadAsync()
Loads or retries loading metadata for the object asynchronously.void
rollbackTransaction()
Rollback the current transaction on the geodatabase.
-
-
-
Constructor Detail
-
Geodatabase
public Geodatabase(java.lang.String geodatabasePath)
Creates a new Geodatabase instance from a geodatabase at the given path.- Parameters:
geodatabasePath
- path to geodatabase to be opened- Throws:
java.lang.IllegalArgumentException
- if geodatabasePath is null- Since:
- 100.0.0
-
-
Method Detail
-
getGeodatabaseFeatureTables
public java.util.List<GeodatabaseFeatureTable> getGeodatabaseFeatureTables()
Gets an unmodifiable list of the geodatabase feature tables that contain geometries such as points, lines or polygons.The results will not include feature tables containing annotation or dimension features. The list will be empty if the Geodatabase itself is not loaded.
- Returns:
- the geodatabase feature tables that contain geometries
- Since:
- 100.0.0
- See Also:
getGeodatabaseAnnotationTables()
-
getGeodatabaseFeatureTable
public GeodatabaseFeatureTable getGeodatabaseFeatureTable(java.lang.String name)
Gets a feature table containing point, line or polygon features from the geodatabase, as specified by the given name.- Parameters:
name
- the name of the geodatabase feature table- Returns:
- the specified geodatabase feature table, or null if the specified table does not exist or contains annotation or dimension feature data
- Since:
- 100.0.0
- See Also:
getGeodatabaseAnnotationTable(String)
-
getGeodatabaseFeatureTableByServiceLayerId
public GeodatabaseFeatureTable getGeodatabaseFeatureTableByServiceLayerId(int layerId)
Gets a feature table from the geodatabase containing point, line or polygon features, as specified by the given service layer ID. The ID must matchArcGISFeatureLayerInfo.getServiceLayerId()
.- Parameters:
layerId
- the service layer ID of the geodatabase feature table- Returns:
- the specified geodatabase feature table, or null if the specified table does not exist or contains annotation or dimension feature data
- Since:
- 100.0.0
- See Also:
getGeodatabaseAnnotationTableByServiceLayerId(int)
-
getGeodatabaseAnnotationTables
public java.util.List<GeodatabaseFeatureTable> getGeodatabaseAnnotationTables()
Gets an unmodifiable list of the geodatabase feature tables that contain annotation features.The results will not include feature tables that contain geometries such as points, lines or polygons. The list will be empty if the Geodatabase itself is not loaded.
- Returns:
- the geodatabase feature tables that contain annotation features
- Since:
- 100.6.0
- See Also:
getGeodatabaseFeatureTables()
-
getGeodatabaseAnnotationTable
public GeodatabaseFeatureTable getGeodatabaseAnnotationTable(java.lang.String name)
Gets a feature table containing annotation features from the geodatabase, as specified by the given name.- Parameters:
name
- the name of the geodatabase feature table- Returns:
- the specified geodatabase feature table, or null if the specified table does not exist or does not contain annotation feature data
- Since:
- 100.6.0
- See Also:
getGeodatabaseFeatureTable(String)
-
getGeodatabaseAnnotationTableByServiceLayerId
public GeodatabaseFeatureTable getGeodatabaseAnnotationTableByServiceLayerId(int layerId)
Gets a feature table containing annotation features from the geodatabase, as specified by the given service layer ID. The ID must matchArcGISFeatureLayerInfo.getServiceLayerId()
.- Parameters:
layerId
- the service layer ID of the geodatabase feature table- Returns:
- the specified geodatabase feature table, or null if the specified table does not exist or does not contain annotation feature data
- Since:
- 100.6.0
- See Also:
getGeodatabaseFeatureTableByServiceLayerId(int)
-
hasLocalEdits
public boolean hasLocalEdits()
Indicates if the geodatabase has local edits.For mobile geodatabases created by ArcGIS Pro, this method returns false because there is no concept of uploading or applying edits. For tables from mobile geodatabases, use
GeodatabaseFeatureTable.hasLocalEditsSince(Calendar)
.- Returns:
- true if there are local edits, false otherwise
- Since:
- 100.0.0
-
getServiceUrl
public java.lang.String getServiceUrl()
Gets the URL of the service the geodatabase was created from.- Returns:
- URL of the service the geodatabase was created from
- Since:
- 100.0.0
-
getSyncId
public java.util.UUID getSyncId()
Gets the sync ID of the geodatabase. The geodatabase's sync ID is the same as the replica ID described in the REST documentation. This is used by the service that created the geodatabase to uniquely identify it when carrying out sync operations. It can also be used when unregistering the geodatabase if it has already been deleted locally.- Returns:
- Sync ID of the given geodatabase or null if there is an error. Will also return null if this is not a sync enabled geodatabase or if the geodatabase is not loaded.
- Since:
- 100.6.0
- See Also:
GeodatabaseSyncTask.unregisterGeodatabaseAsync(UUID)
-
getSyncModel
public SyncModel getSyncModel()
Gets the sync model of the geodatabase. This was set when the geodatabase was created and determines how updates can be synced with the service. If the sync model is PER_GEODATABASE, layers cannot be synced independently: the whole geodatabase must be synced in one operation.If the sync model is PER_LAYER, layers can be synced independently of one another.
- Returns:
- the geodatabase's sync model
- Since:
- 100.0.0
-
isSyncEnabled
public boolean isSyncEnabled()
Indicates if sync is enabled for the geodatabase. If this is true, the geodatabase can be synced with the service it was created from.- Returns:
- true if sync is enabled, false otherwise
- Since:
- 100.0.0
-
getDomains
public ListenableList<Domain> getDomains()
Returns a list of the domains that exist in the geodatabase.The returned list will be empty if the geodatabase itself is not loaded.
- Returns:
- returns a list of the domains that exist in the geodatabase
- Since:
- 100.14.0
-
getGenerateGeodatabaseExtent
@Deprecated public Envelope getGenerateGeodatabaseExtent()
Deprecated.As of 100.7.0, replaced bygetGenerateGeodatabaseGeometry()
. A geodatabase can be generated using geometry including anEnvelope
or aPolygon
- this property will always return the bounding envelope. ThegetGenerateGeodatabaseGeometry()
property will return the underlying geometry.Gets the extent used to generate the sync enabled geodatabase.Use this to restrict editing of layers to within this extent.
- Returns:
- the extent used to generate the sync enabled geodatabase, or null if the geodatabase is not sync enabled
- Since:
- 100.0.0
-
getGenerateGeodatabaseGeometry
public Geometry getGenerateGeodatabaseGeometry()
The geometry (for example, anEnvelope
orPolygon
used to generate a sync enabled geodatabase.Edits made to a sync enabled
Geodatabase
must intersect the geometry used to generate the geodatabase. If an edit is made outside this extent, or area of interest, it will be rejected.This method will return the geometry which was used to create this geodatabase. For example, if the geodatabase was created using a
GenerateGeodatabaseJob
, this method reflectsGenerateGeodatabaseParameters.getExtent()
. If the geometry was created using anGenerateOfflineMapJob
, this method reflectsGenerateOfflineMapParameters.getAreaOfInterest()
. If the geodatabase was downloaded as part of aPreplannedMapArea
, this method will match the geometry used by the web map author when the map area was created.If no geometry was used to create the geodatabase (for example if it was authored using ArcGIS Pro), this method may return null. It will also be null until the geodatabase is loaded and
getLoadStatus()
returnsLoadStatus.LOADED
.- Returns:
- the geometry used to generate a sync enabled geodatabase, or null if the geodatabase is not sync enabled
- Since:
- 100.7.0
-
getPath
public java.lang.String getPath()
Returns the geodatabase path.- Returns:
- the geodatabase path
- Since:
- 100.2.0
-
getUtilityNetworks
public java.util.List<UtilityNetwork> getUtilityNetworks()
Gets an unmodifiable list ofUtilityNetwork
objects that are packaged within the Geodatabase.The returned array will be empty if the geodatabase itself is not loaded or if no utility networks exist in the geodatabase.
- Returns:
- the
UtilityNetwork
objects that are packaged within the Geodatabase - Since:
- 100.11.0
-
getUtilityNetwork
public UtilityNetwork getUtilityNetwork(java.lang.String utilityNetworkName)
Returns anUtilityNetwork
from the geodatabase with the specified utility network name.- Parameters:
utilityNetworkName
- the name of the utility network- Returns:
- if the specified utility network is not found, then null is returned
- Throws:
java.lang.IllegalArgumentException
- if utilityNetworkName is null- Since:
- 100.11.0
-
close
public void close()
Closes this geodatabase.After closing, the geodatabase file can be safely deleted or moved.
Any operation on a closed geodatabase will result in undefined behavior - it may succeed or throw exceptions. So make sure that a closed geodatabase is no longer in use from, for example, feature layers, feature tables, geodatabase sync tasks, etc.
- Since:
- 100.1.0
-
isInTransaction
public boolean isInTransaction()
Gets whether a transaction is active on the geodatabase.- Returns:
- true if a transaction is active on the geodatabase, otherwise false
- Since:
- 100.2.0
-
createAsync
public static ListenableFuture<Geodatabase> createAsync(java.lang.String path)
Creates an empty mobile geodatabase at the specified path.The path must be non-empty, available, allow read/write access, and end in ".geodatabase". If any of these restrictions are violated, the task will not succeed and a task error will be set.
- Parameters:
path
- the path at which the mobile geodatabase should be created- Returns:
- a
ListenableFuture
that returns a Geodatabase in a loaded state, if one was able to be created at the specified path - Throws:
java.lang.IllegalArgumentException
- if path is null- Since:
- 100.14.0
-
createDomainAsync
public ListenableFuture<Domain> createDomainAsync(DomainDescription domainDescription)
Creates a new domain in the geodatabase.Creating domains is only supported in mobile geodatabases (either created in Pro or via
createAsync(String)
). TheField.Type
of the domain cannot be unknown. The domain name must not already exist in the geodatabase. For additional domain name constraints, seeDomainDescription.getName()
.- Parameters:
domainDescription
- the description of the domain to create- Returns:
- a
ListenableFuture
that returns aDomain
if one was able to be created - Throws:
java.lang.IllegalArgumentException
- if domainDescription is null- Since:
- 100.14.0
-
deleteDomainAsync
public ListenableFuture<java.lang.Void> deleteDomainAsync(java.lang.String domainName)
Deletes the domain with the specified name from the geodatabase.Deleting domains is only supported in mobile geodatabases (either created in Pro or via
createAsync(String)
). The domain with the specified name must exist in the geodatabase. The domain must not be in use by any fields in existing tables.- Parameters:
domainName
- the name of the domain to delete- Returns:
- a
ListenableFuture
with no return value. If there is no error, the domain was deleted successfully. - Throws:
java.lang.IllegalArgumentException
- if domainName is null- Since:
- 100.14.0
-
createTableAsync
public ListenableFuture<GeodatabaseFeatureTable> createTableAsync(TableDescription tableDescription)
Creates a new table in the geodatabase.Creating tables is only supported in mobile geodatabases (either created in Pro or via
createAsync(String)
). The table name must not already exist in the geodatabase. For additional table name constraints, seeTableDescription.getTableName()
.- Parameters:
tableDescription
- the description of the table to create- Returns:
- a
ListenableFuture
that returns aGeodatabaseFeatureTable
in a loaded state, if one was able to be created - Throws:
java.lang.IllegalArgumentException
- if tableDescription is null- Since:
- 100.14.0
-
deleteTableAsync
public ListenableFuture<java.lang.Void> deleteTableAsync(java.lang.String tableName)
Deletes an existing table from the geodatabase.Deleting tables is only supported in mobile geodatabases (either created in Pro or via
createAsync(String)
). A table with the specified name must exist in the geodatabase. Attempting further use of a deleted table, such as rendering it in a feature layer or querying it, may result in errors. Only spatial and non-spatial tables can be deleted.- Parameters:
tableName
- the name of the table to delete- Returns:
- a
ListenableFuture
with no return value. If there is no error, the table was deleted successfully. - Throws:
java.lang.IllegalArgumentException
- if tableName is null- Since:
- 100.14.0
-
beginTransaction
public void beginTransaction()
Starts a new transaction on the geodatabase.An exception will be thrown if another transaction is already active on the geodatabase. A geodatabase cannot be synchronized while a transaction is active.
- Since:
- 100.2.0
-
commitTransaction
public void commitTransaction()
Commits the current transaction on the geodatabase.Commit changes in the current transaction to the geodatabase. This will also end the transaction. An exception will be thrown if a transaction has not been started on the geodatabase.
- Since:
- 100.2.0
-
rollbackTransaction
public void rollbackTransaction()
Rollback the current transaction on the geodatabase.Discard changes in the current transaction from the geodatabase. This will also end the transaction. An exception will be thrown if a transaction has not been started on the geodatabase.
- Since:
- 100.2.0
-
addTransactionStatusChangedListener
public void addTransactionStatusChangedListener(Geodatabase.TransactionStatusChangedListener listener)
Adds aGeodatabase.TransactionStatusChangedListener
to the Geodatabase.- Parameters:
listener
- the TransactionStatusChangedListener to add- Throws:
java.lang.IllegalArgumentException
- if the listener is null- Since:
- 100.2.0
-
removeTransactionStatusChangedListener
public boolean removeTransactionStatusChangedListener(Geodatabase.TransactionStatusChangedListener listener)
Removes theGeodatabase.TransactionStatusChangedListener
from the Geodatabase.- Parameters:
listener
- the TransactionStatusChangedListener to remove- Returns:
- true if listener has been removed, otherwise false
- Since:
- 100.2.0
-
getMinServerGeneration
public long getMinServerGeneration()
Returns the minimum server generation number for the geodatabase.Server generation numbers indicate the state of a geodatabase (or individual layers) with respect to changes which have been synced with the online service. The number increases as new changes from the online feature service are synced to the local geodatabase. If
getSyncModel()
isSyncModel.PER_GEODATABASE
, the value will indicate the server generation number for the entire geodatabase. If thegetSyncModel()
isSyncModel.PER_LAYER
, the value will be the lowest server generation number for all of the layers in the geodatabase. This property will be -1 if the geodatabase does not support sync (SyncModel.NONE
).This property will be -1 until the geodatabase is
LoadStatus.LOADED
.Note that this property is only required when using advanced workflows to manually apply pre-generated changes and not when performing a sync directly against the online service.
- Returns:
- the minimum server generation number for the geodatabase
- Since:
- 100.6.0
-
getGeodatabaseDimensionTables
public java.util.List<GeodatabaseFeatureTable> getGeodatabaseDimensionTables()
Gets the geodatabase feature tables that contain dimension features. AList
ofGeodatabaseFeatureTable
objects.The results will not include feature tables that contain geometries such as points, lines or polygons, or annotation features. The returned list will be empty if the geodatabase itself is not loaded.
- Returns:
- a list of GeodatabaseFeatureTable objects that contain dimension features
- Since:
- 100.13.0
-
getGeodatabaseDimensionTable
public GeodatabaseFeatureTable getGeodatabaseDimensionTable(long serviceLayerId)
Returns a feature table containing dimension features from the geodatabase, as specified by the given feature service layer ID.- Parameters:
serviceLayerId
- the service layer ID of the geodatabase feature table containing dimension features- Returns:
- a GeodatabaseFeatureTable object or null if the specified table does not contain dimension feature data
- Since:
- 100.13.0
-
getGeodatabaseDimensionTable
public GeodatabaseFeatureTable getGeodatabaseDimensionTable(java.lang.String tableName)
Returns a feature table containing dimension features from the geodatabase, as specified by the given tableName.- Parameters:
tableName
- the name of the geodatabase feature table containing dimension- Returns:
- a GeodatabaseFeatureTable object or null if the specified table does not contain dimension feature data
- Throws:
java.lang.IllegalArgumentException
- if tableName is null or empty- Since:
- 100.13.0
-
getLoadStatus
public LoadStatus getLoadStatus()
Description copied from interface:Loadable
Returns theLoadStatus
of the loadable resource.- Specified by:
getLoadStatus
in interfaceLoadable
- Returns:
- the LoadStatus of the loadable resource
-
getLoadError
public ArcGISRuntimeException getLoadError()
Description copied from interface:Loadable
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.If the resource subsequently transitions to
LoadStatus.LOADED
(for example, if a call toretryLoadAsync
completes successfully) the error is cleared out.- Specified by:
getLoadError
in interfaceLoadable
- Returns:
- the most recent error that was encountered when the loadable resource transitioned to the
LoadStatus.FAILED_TO_LOAD
state.
-
cancelLoad
public void cancelLoad()
Description copied from interface:Loadable
Cancels loading metadata for the object.Cancels loading the metadata if the object is loading, and always invokes the done loading listener.
A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by calling this method and the resource will transition fromLoadStatus.LOADING
toLoadStatus.FAILED_TO_LOAD
state. If the load operation was successfully cancelled, a CancellationException will be returned fromLoadable.getLoadError()
.Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.
This method does nothing if the resource is not in
LoadStatus.LOADING
state.- Specified by:
cancelLoad
in interfaceLoadable
-
loadAsync
public void loadAsync()
Description copied from interface:Loadable
Loads the metadata of the loadable resource asynchronously.The load status changes from
LoadStatus.NOT_LOADED
toLoadStatus.LOADING
. A listener can be added viaLoadable.addDoneLoadingListener(java.lang.Runnable)
that is invoked upon completion of the asynchronous load operation.If the load operation completes successfully, the load status will be
LoadStatus.LOADED
, which means the resource has loaded its metadata.If the load operation failed, the load status will be
LoadStatus.FAILED_TO_LOAD
and the error can be retrieved by callingLoadable.getLoadError()
.This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (
LoadStatus.LOADING
state) whenloadAsync
is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED
orLoadStatus.FAILED_TO_LOAD
state) whenloadAsync
is called, the done loading listener is immediately invoked when added to the loadable resource.If a loadable resource has failed to load, calling
loadAsync
on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource,Loadable.retryLoadAsync()
needs to be used.A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by callingLoadable.cancelLoad()
.
-
retryLoadAsync
public void retryLoadAsync()
Description copied from interface:Loadable
Loads or retries loading metadata for the object asynchronously.Will retry loading the metadata if the object's load status is
LoadStatus.FAILED_TO_LOAD
. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.For more details on the load process see
Loadable.loadAsync()
.- Specified by:
retryLoadAsync
in interfaceLoadable
-
addDoneLoadingListener
public void addDoneLoadingListener(java.lang.Runnable listener)
Description copied from interface:Loadable
Adds a listener to the loadable resource that is invoked when loading has completed.The listener may be added at any point, whether the loadable resource has already completed loading or not.
- For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.
Alternatively, to be notified when there is any change in the load status, use the
Loadable.addLoadStatusChangedListener(LoadStatusChangedListener)
method instead.- Specified by:
addDoneLoadingListener
in interfaceLoadable
- Parameters:
listener
- a Runnable that is invoked upon completion of the load operation
-
removeDoneLoadingListener
public boolean removeDoneLoadingListener(java.lang.Runnable listener)
Description copied from interface:Loadable
Removes a done loading listener from the loadable resource.- Specified by:
removeDoneLoadingListener
in interfaceLoadable
- Parameters:
listener
- the listener to be removed- Returns:
- true if the listener was removed, otherwise false
-
addLoadStatusChangedListener
public void addLoadStatusChangedListener(LoadStatusChangedListener listener)
Description copied from interface:Loadable
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the
Loadable.addDoneLoadingListener(Runnable)
method.- Specified by:
addLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be added
-
removeLoadStatusChangedListener
public boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Description copied from interface:Loadable
Removes aLoadStatusChangedListener
from the loadable resource.- Specified by:
removeLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be removed- Returns:
- true if the listener was removed, otherwise false
-
-