/** * Retrieves at most one AVObject that satisfies this query from the server in a background * thread. This is preferable to using getFirst(), unless your code is already running in a * background thread. This mutates the AVQuery. * * @param callback callback.done(object, e) is called when the find completes. */ public void getFirstInBackground(GetCallback<T> callback) { getFirstInBackground(false, callback); }
/** * Retrieves at most one AVObject that satisfies this query from the server in a background * thread. This is preferable to using getFirst(), unless your code is already running in a * background thread. This mutates the AVQuery. * * @param callback callback.done(object, e) is called when the find completes. */ public void getFirstInBackground(GetCallback<T> callback) { getFirstInBackground(false, callback); }
/** * Retrieves at most one AVObject that satisfies this query. Uses the network and/or the cache, * depending on the cache policy. This mutates the AVQuery. * * @return A AVObject obeying the conditions set in this query, or null if none found. */ @SuppressWarnings("unchecked") public T getFirst() throws AVException { final Object[] result = {null}; getFirstInBackground(true, new GetCallback<T>() { @Override public void done(AVObject object, AVException e) { if (e == null) { result[0] = object; } else { AVExceptionHolder.add(e); } } @Override protected boolean mustRunOnUIThread() { return false; } }); if (AVExceptionHolder.exists()) { throw AVExceptionHolder.remove(); } return (T) result[0]; }
/** * Retrieves at most one AVObject that satisfies this query. Uses the network and/or the cache, * depending on the cache policy. This mutates the AVQuery. * * @return A AVObject obeying the conditions set in this query, or null if none found. */ @SuppressWarnings("unchecked") public T getFirst() throws AVException { final Object[] result = {null}; getFirstInBackground(true, new GetCallback<T>() { @Override public void done(AVObject object, AVException e) { if (e == null) { result[0] = object; } else { AVExceptionHolder.add(e); } } @Override protected boolean mustRunOnUIThread() { return false; } }); if (AVExceptionHolder.exists()) { throw AVExceptionHolder.remove(); } return (T) result[0]; }