public interface GetCallback<T extends com.eyro.mesosfer.CoreObject>
GetCallback
is used to run code after a MesosferQuery
is used to fetch a
MesosferData
in a background thread.
The easiest way to use a GetCallback
is through an anonymous inner class. Override the
done
function to specify what the callback should do after the fetch is complete.
The done
function will be run in the UI thread, while the fetch happens in a
background thread. This ensures that the UI does not freeze while the fetch happens.
For example, this sample code fetches an object of class "MyBucket"
and id
myId
. It calls a different function depending on whether the fetch succeeded or not.
MesosferData data = MesosferData.createWithObjectId("myId"); data.fetchAsync(new GetCallback<MesosferData>() { public void done(MesosferData object, MesosferException e) { if (e == null) { objectWasRetrievedSuccessfully(object); } else { objectRetrievalFailed(); } } });
Modifier and Type | Method and Description |
---|---|
void |
done(T object,
MesosferException e)
Override this function with the code you want to run after the fetch is complete.
|
void done(T object, MesosferException e)
object
- The object that was retrieved, or null
if it did not succeed.e
- The exception raised by the fetch, or null
if it succeeded.