/** * 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 do * nothing. */ @SuppressWarnings("unchecked") <T extends ParseObject> Task<T> fetchFromLocalDatastoreAsync() { if (!Parse.isLocalDatastoreEnabled()) { throw new IllegalStateException("Method requires Local Datastore. " + "Please refer to `Parse#enableLocalDatastore(Context)`."); } return Parse.getLocalDatastore().fetchLocallyAsync((T) this); }
private void addParseObjectToSet(ParseObject obj, Set<ParseObject> set) { if (Parse.getLocalDatastore() != null || obj.getObjectId() == null) { // There's no way there could be duplicate instances. set.add(obj); return; } // We have to do this the hard way. for (ParseObject existingObject : set) { if (obj.getObjectId().equals(existingObject.getObjectId())) { set.remove(existingObject); } } set.add(obj); }
private void removeParseObjectFromSet(ParseObject obj, Set<ParseObject> set) { if (Parse.getLocalDatastore() != null || obj.getObjectId() == null) { // There's no way there could be duplicate instances. set.remove(obj); return; } // We have to do this the hard way. for (ParseObject existingObject : set) { if (obj.getObjectId().equals(existingObject.getObjectId())) { set.remove(existingObject); } } }
/** * Removes the objects and every object they point to in the local datastore, recursively. * * @param name the name * @return A {@link bolts.Task} that is resolved when unpinning all completes. * @see #pinAll(String, java.util.List) */ public static Task<Void> unpinAllInBackground(String name) { if (!Parse.isLocalDatastoreEnabled()) { throw new IllegalStateException("Method requires Local Datastore. " + "Please refer to `Parse#enableLocalDatastore(Context)`."); } if (name == null) { name = DEFAULT_PIN; } return Parse.getLocalDatastore().unpinAllObjectsAsync(name); }
/** * Removes the objects and every object they point to in the local datastore, recursively. * * @param name the name * @param objects the objects * @return A {@link bolts.Task} that is resolved when unpinning all completes. * @see #pinAllInBackground(String, java.util.List) */ public static <T extends ParseObject> Task<Void> unpinAllInBackground(String name, List<T> objects) { if (!Parse.isLocalDatastoreEnabled()) { throw new IllegalStateException("Method requires Local Datastore. " + "Please refer to `Parse#enableLocalDatastore(Context)`."); } if (name == null) { name = DEFAULT_PIN; } return Parse.getLocalDatastore().unpinAllObjectsAsync(name, objects); }
OfflineStore store = Parse.getLocalDatastore(); try { if (objectId == null) {
private void notifyObjectIdChanged(String oldObjectId, String newObjectId) { synchronized (mutex) { // The offline store may throw if this object already had a different objectId. OfflineStore store = Parse.getLocalDatastore(); if (store != null) { store.updateObjectId(this, oldObjectId, newObjectId); } if (localId != null) { getLocalIdManager().setObjectId(localId, newObjectId); localId = null; } } }
/** * Handles the result of {@code delete}. * <p> * Should only be called on success. */ Task<Void> handleDeleteResultAsync() { Task<Void> task = Task.forResult(null); synchronized (mutex) { isDeleted = true; } final OfflineStore store = Parse.getLocalDatastore(); if (store != null) { task = task.continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { synchronized (mutex) { if (isDeleted) { store.unregisterObject(ParseObject.this); return store.deleteDataForObjectAsync(ParseObject.this); } else { return store.updateDataForObjectAsync(ParseObject.this); } } } }); } return task; }
public ParseQueryController getQueryController() { if (queryController.get() == null) { NetworkQueryController networkController = new NetworkQueryController( ParsePlugins.get().restClient()); ParseQueryController controller; // TODO(grantland): Do not rely on Parse global if (Parse.isLocalDatastoreEnabled()) { controller = new OfflineQueryController( Parse.getLocalDatastore(), networkController); } else { controller = new CacheQueryController(networkController); } queryController.compareAndSet(null, controller); } return queryController.get(); }
OfflineStore store = Parse.getLocalDatastore(); if (store != null) { store.registerNewObject(this);
final OfflineStore store = Parse.getLocalDatastore(); if (store != null) { task = task.onSuccessTask(new Continuation<Void, Task<Void>>() {
final OfflineStore store = Parse.getLocalDatastore(); if (store != null) { task = task.onSuccessTask(new Continuation<Void, Task<Void>>() {