/** * Calls the callback after a task completes on the main thread, returning a Task that completes * with the same result as the input task after the callback has been run. */ /* package */ static Task<Void> callbackOnMainThreadAsync(Task<Void> task, final ParseCallback1<ParseException> callback) { return callbackOnMainThreadAsync(task, callback, false); }
/** * Calls the callback after a task completes on the main thread, returning a Task that completes * with the same result as the input task after the callback has been run. */ /* package */ static <T> Task<T> callbackOnMainThreadAsync(Task<T> task, final ParseCallback2<T, ParseException> callback) { return callbackOnMainThreadAsync(task, callback, false); }
/** * Asynchronously gets the data from cache if available or fetches its content from the network. * A {@code GetDataCallback} will be called when the get completes. * * @param dataCallback A {@code GetDataCallback} that is called when the get completes. */ public void getDataInBackground(GetDataCallback dataCallback) { ParseTaskUtils.callbackOnMainThreadAsync(getDataInBackground(), dataCallback); }
/** * Removes 'channel' from the 'channels' list in the current {@link ParseInstallation} and saves * it in a background thread. * * @param channel The channel to unsubscribe from. * @param callback The SaveCallback that is called after the Installation is saved. */ public static void unsubscribeInBackground(String channel, SaveCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(unsubscribeInBackground(channel), callback); }
/** * Sends this push notification in a background thread. This is preferable to using * <code>send()</code>, unless your code is already running from a background thread. * * @param callback callback.done(e) is called when the send completes. */ public void sendInBackground(SendCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(sendInBackground(), callback); }
/** * Tracks the occurrence of a custom event. Parse will store a data point at the time of * invocation with the given event name. * * @param name The name of the custom event to report to Parse as having happened. * @param callback callback.done(e) is called when the event has been tracked by Parse. */ public static void trackEventInBackground(String name, SaveCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(trackEventInBackground(name), callback); }
/** * Fetches a new configuration object from the server in a background thread. This is preferable * to using {@link #get()}, unless your code is already running from a background thread. * * @param callback callback.done(config, e) is called when the fetch completes. */ public static void getInBackground(ConfigCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(getInBackground(), callback); }
/** * Saves the file to the Parse cloud in a background thread. * `progressCallback` is guaranteed to be called with 100 before saveCallback is called. * * @param saveCallback A SaveCallback that gets called when the save completes. * @param progressCallback A ProgressCallback that is called periodically with progress updates. */ public void saveInBackground(final SaveCallback saveCallback, ProgressCallback progressCallback) { ParseTaskUtils.callbackOnMainThreadAsync(saveInBackground(progressCallback), saveCallback); }
/** * Asynchronously gets the data stream from cached file if available or fetches its content from * the network, saves the content as cached file and returns the data stream of the cached file. * The {@code GetDataStreamCallback} will be called when the get completes. * * @param dataStreamCallback A {@code GetDataStreamCallback} that is called when the get completes. */ public void getDataStreamInBackground(GetDataStreamCallback dataStreamCallback) { ParseTaskUtils.callbackOnMainThreadAsync(getDataStreamInBackground(), dataStreamCallback); }
/** * Get the current {@code ParseSession} object related to the current user. * * @param callback A callback that returns a {@code ParseSession} object or {@code null} if not * valid or logged in. */ public static void getCurrentSessionInBackground(GetCallback<ParseSession> callback) { ParseTaskUtils.callbackOnMainThreadAsync(getCurrentSessionInBackground(), callback); }
/** * Logs out the currently logged in user session. This will remove the session from disk, log out * of linked services, and future calls to {@link #getCurrentUser()} will return {@code null}. * <p/> * This is preferable to using {@link #logOut}, unless your code is already running from a * background thread. */ public static void logOutInBackground(LogOutCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(logOutInBackground(), callback); }
/** * Saves each object in the provided list to the server in a background thread. This is preferable * to using saveAll, unless your code is already running from a background thread. * * @param objects The objects to save. * @param callback {@code callback.done(e)} is called when the save completes. */ public static <T extends ParseObject> void saveAllInBackground(List<T> objects, SaveCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(saveAllInBackground(objects), callback); }
/** * Fetches all the objects in the provided list in the background. * * @param objects The list of objects to fetch. * @param callback {@code callback.done(result, e)} is called when the fetch completes. */ public static <T extends ParseObject> void fetchAllInBackground(List<T> objects, FindCallback<T> callback) { ParseTaskUtils.callbackOnMainThreadAsync(fetchAllInBackground(objects), callback); }
/** * Creates an anonymous user in the background. * * @param callback The callback to execute when anonymous user creation is complete. */ public static void logIn(LogInCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(logInInBackground(), callback); }
/** * Tracks this application being launched (and if this happened as the result of the user opening * a push notification, this method sends along information to correlate this open with that * push). * * @param intent The {@code Intent} that started an {@code Activity}, if any. Can be null. * @param callback callback.done(e) is called when the event has been tracked by Parse. */ public static void trackAppOpenedInBackground(Intent intent, SaveCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(trackAppOpenedInBackground(intent), callback); }
/** * Removes the objects and every object they point to in the local datastore, recursively. * * @param name the name * @param objects the objects * @param callback the callback * @see #pinAllInBackground(String, java.util.List, SaveCallback) */ public static <T extends ParseObject> void unpinAllInBackground(String name, List<T> objects, DeleteCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(unpinAllInBackground(name, objects), callback); }
/** * Fetches this object with the data from the server in a background thread. This is preferable to * using fetch(), unless your code is already running from a background thread. * * @param callback {@code callback.done(object, e)} is called when the fetch completes. */ public final <T extends ParseObject> void fetchInBackground(GetCallback<T> callback) { ParseTaskUtils.callbackOnMainThreadAsync(this.<T>fetchInBackground(), callback); }
/** * If this {@code ParseObject} has not been fetched (i.e. {@link #isDataAvailable()} returns {@code false}), * fetches this object with the data from the server in a background thread. This is preferable to * using {@link #fetchIfNeeded()}, unless your code is already running from a background thread. * * @param callback {@code callback.done(object, e)} is called when the fetch completes. */ public final <T extends ParseObject> void fetchIfNeededInBackground(GetCallback<T> callback) { ParseTaskUtils.callbackOnMainThreadAsync(this.<T>fetchIfNeededInBackground(), callback); }
/** * Saves the file to the Parse cloud in a background thread. * * @param callback A SaveCallback that gets called when the save completes. */ public void saveInBackground(SaveCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(saveInBackground(), callback); }
/** * Asynchronously gets the file pointer from cache if available or fetches its content from the * network. The {@code GetFileCallback} will be called when the get completes. * <strong>Note: </strong> The {@link File} location may change without notice and should not be * stored to be accessed later. * * @param fileCallback A {@code GetFileCallback} that is called when the get completes. */ public void getFileInBackground(GetFileCallback fileCallback) { ParseTaskUtils.callbackOnMainThreadAsync(getFileInBackground(), fileCallback); }