All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.easimart.FindCallback Maven / Gradle / Ivy

package co.easimart;

import java.util.List;

/**
 * A {@code FindCallback} is used to run code after a {@link EasimartQuery} is used to fetch a list of
 * {@link EasimartObject}s in a background thread.
 * 

* The easiest way to use a {@code FindCallback} is through an anonymous inner class. Override the * {@code done} function to specify what the callback should do after the fetch is complete. * The {@code 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 all objects of class {@code "MyClass"}. It calls a * different function depending on whether the fetch succeeded or not. *

*

 * EasimartQuery<EasimartObject> query = EasimartQuery.getQuery("MyClass");
 * query.findInBackground(new FindCallback<EasimartObject>() {
 *   public void done(List<EasimartObject> objects, EasimartException e) {
 *     if (e == null) {
 *       objectsWereRetrievedSuccessfully(objects);
 *     } else {
 *       objectRetrievalFailed();
 *     }
 *   }
 * });
 * 
*/ public interface FindCallback extends EasimartCallback2, EasimartException> { /** * Override this function with the code you want to run after the fetch is complete. * * @param objects * The objects that were retrieved, or null if it did not succeed. * @param e * The exception raised by the save, or null if it succeeded. */ @Override public void done(List objects, EasimartException e); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy