/** * Constructs a AVObject whose id is already known by fetching data from the server in a * background thread. This does not use caching. This is preferable to using the * AVObject(className, objectId) constructor, unless your code is already running in a background * thread. * * @param objectId Object id of the AVObject to fetch * @param callback callback.done(object, e) will be called when the fetch completes. */ public void getInBackground(String objectId, GetCallback<T> callback) { final GetCallback<T> internalCallback = callback; this.getInBackground(objectId, false, new GetCallback<T>() { @Override public void done(T object, AVException e) { if (internalCallback != null) { internalCallback.internalDone(object, e); } } }); }
/** * Constructs a AVObject whose id is already known by fetching data from the server in a * background thread. This does not use caching. This is preferable to using the * AVObject(className, objectId) constructor, unless your code is already running in a background * thread. * * @param objectId Object id of the AVObject to fetch * @param callback callback.done(object, e) will be called when the fetch completes. */ public void getInBackground(String objectId, GetCallback<T> callback) { final GetCallback<T> internalCallback = callback; this.getInBackground(objectId, false, new GetCallback<T>() { @Override public void done(T object, AVException e) { if (internalCallback != null) { internalCallback.internalDone(object, e); } } }); }
/** * Retrieve a AVFile object by object id from AVOSCloud in background.If the file is not found,it * will call the callback with java.io.FileNotFoundException. * * @param objectId The file object id. * @param cb The GetFileCallback instance. * @since 2.0.2 */ public static void withObjectIdInBackground(final String objectId, final GetFileCallback<AVFile> cb) { AVQuery<AVObject> query = new AVQuery<AVObject>("_File"); query.getInBackground(objectId, new GetCallback<AVObject>() { @Override public void done(AVObject object, AVException e) { if (e != null) { cb.internalDone(null, e); return; } if (object != null && !AVUtils.isBlankString(object.getObjectId())) { AVFile file = createFileFromAVObject(object); if (cb != null) { cb.internalDone(file, null); } } else { cb.internalDone(null, new AVException(AVException.OBJECT_NOT_FOUND, "Could not find file object by id:" + objectId)); } } }); }
final GetFileCallback<AVFile> cb) { AVQuery<AVObject> query = new AVQuery<AVObject>("_File"); query.getInBackground(objectId, new GetCallback<AVObject>() {
/** * Constructs a AVObject whose id is already known by fetching data from the server. This mutates * the AVQuery. * * @param theObjectId Object id of the AVObject to fetch. */ @SuppressWarnings("unchecked") public T get(String theObjectId) throws AVException { final Object[] result = {null}; this.getInBackground(theObjectId, true, new GetCallback<T>() { @Override public void done(T 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]; }
/** * Constructs a AVObject whose id is already known by fetching data from the server. This mutates * the AVQuery. * * @param theObjectId Object id of the AVObject to fetch. */ @SuppressWarnings("unchecked") public T get(String theObjectId) throws AVException { final Object[] result = {null}; this.getInBackground(theObjectId, true, new GetCallback<T>() { @Override public void done(T 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]; }