/** * Synchronously gets the data from cache if available or fetches its content from the network. * You probably want to use {@link #getDataInBackground()} instead unless you're already in a * background thread. */ public byte[] getData() throws ParseException { return ParseTaskUtils.wait(getDataInBackground()); }
/** * 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); }
/** * Fetches a new configuration object from the server. * * @return The {@code ParseConfig} that was fetched. * @throws ParseException Throws an exception if the server is inaccessible. */ public static ParseConfig get() throws ParseException { return ParseTaskUtils.wait(getInBackground()); }
/** * 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); }
/** * Removes the object and every object it points to in the local datastore, recursively. * * @see #pin(String) */ public void unpin(String name) throws ParseException { ParseTaskUtils.wait(unpinInBackground(name)); }
/** * 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); }
@Override public void clearFromDisk() { synchronized (mutex) { currentUser = null; currentUserMatchesDisk = false; } try { ParseTaskUtils.wait(store.deleteAsync()); } catch (ParseException e) { // ignored } }
/** * 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); }
/** * Fetches all the objects that don't have data in the provided list. * * @param objects The list of objects to fetch. * @return The list passed in for convenience. * @throws ParseException Throws an exception if the server returns an error or is inaccessible. */ public static <T extends ParseObject> List<T> fetchAllIfNeeded(List<T> objects) throws ParseException { return ParseTaskUtils.wait(fetchAllIfNeededInBackground(objects)); }
/** * 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); }
/** * Deletes this object on the server. This does not delete or destroy the object locally. * * @throws ParseException Throws an error if the object does not exist or if the internet fails. */ public final void delete() throws ParseException { ParseTaskUtils.wait(deleteInBackground()); }
/** * 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); }
/** * Loads data from the local datastore into this object, if it has not been fetched from the * server already. If the object is not stored in the local datastore, this method with throw a * CACHE_MISS exception. * * @throws ParseException exception if fails */ public void fetchFromLocalDatastore() throws ParseException { ParseTaskUtils.wait(fetchFromLocalDatastoreAsync()); }
/** * 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); }
/** * Synchronously gets the file pointer from cache if available or fetches its content from the * network. You probably want to use {@link #getFileInBackground()} instead unless you're already * in a background thread. * <strong>Note: </strong> The {@link File} location may change without notice and should not be * stored to be accessed later. */ public File getFile() throws ParseException { return ParseTaskUtils.wait(getFileInBackground()); }
/** * 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); }
/** * Counts the number of objects that match this query. This does not use caching. * * @throws ParseException Throws an exception when the network connection fails or when the query is invalid. */ public int count() throws ParseException { return ParseTaskUtils.wait(countInBackground()); }
/** * 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); }
/** * Saves each object in the provided list. This is faster than saving each object individually * because it batches the requests. * * @param objects The objects to save. * @throws ParseException Throws an exception if the server returns an error or is inaccessible. */ public static <T extends ParseObject> void saveAll(List<T> objects) throws ParseException { ParseTaskUtils.wait(saveAllInBackground(objects)); }
/** * 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); }