@Override protected ParseHttpBody newBody(final ProgressCallback progressCallback) { // TODO(mengyan): Delete ParseByteArrayHttpBody when we change input byte array to staged file // in ParseFileController if (progressCallback == null) { return data != null ? new ParseByteArrayHttpBody(data, contentType) : new ParseFileHttpBody(file, contentType); } return data != null ? new ParseCountingByteArrayHttpBody(data, contentType, progressCallback) : new ParseCountingFileHttpBody(file, contentType, progressCallback); }
@Override /* package */ void updateBeforeSave() { super.updateBeforeSave(); if (getCurrentInstallationController().isCurrent(ParseInstallation.this)) { updateTimezone(); updateVersionInfo(); updateDeviceInfo(); updateLocaleIdentifier(); } }
@Override public <T extends ParseObject> Task<Integer> countAsync( ParseQuery.State<T> state, ParseUser user, Task<Void> cancellationToken) { if (state.isFromLocalDatastore()) { return offlineStore.countFromPinAsync(state.pinName(), state, user); } else { return networkController.countAsync(state, user, cancellationToken); } } }
@Override public <T extends ParseObject> Task<List<T>> findAsync( ParseQuery.State<T> state, ParseUser user, Task<Void> cancellationToken) { if (state.isFromLocalDatastore()) { return offlineStore.findFromPinAsync(state.pinName(), state, user); } else { return networkController.findAsync(state, user, cancellationToken); } }
@Override public void clearFromDisk() { synchronized (mutex) { currentInstallation = null; } try { installationId.clear(); ParseTaskUtils.wait(store.deleteAsync()); } catch (ParseException e) { // ignored } }
/** * 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); }
/** * 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()); }
private static <T extends ParseObject> boolean matches( OfflineQueryLogic logic, ParseQuery.State<T> query, T object, ParseUser user) throws ParseException { Task<Boolean> task = logic.createMatcher(query, user).matchesAsync(object, null); return ParseTaskUtils.wait(task); }
public static ParseInstallation getCurrentInstallation() { try { return ParseTaskUtils.wait( getCurrentInstallationController().getAsync()); } catch (ParseException e) { // In order to have backward compatibility, we swallow the exception silently. return null; } }
private synchronized void saveStateToDisk() { try { ParseFileUtils.writeJSONObjectToFile(diskState, toJSON()); } catch (IOException | JSONException e) { PLog.e(TAG, "Unexpected error when serializing push state to " + diskState, e); } }
private void setState(State newState, boolean notifyIfObjectIdChanges) { synchronized (mutex) { String oldObjectId = state.objectId(); String newObjectId = newState.objectId(); state = newState; if (notifyIfObjectIdChanges && !ParseTextUtils.equals(oldObjectId, newObjectId)) { notifyObjectIdChanged(oldObjectId, newObjectId); } rebuildEstimatedData(); } }
/** * 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); }
Task<JSONObject> saveAsync( ParseHttpClient client, final ParseOperationSet operationSet, String sessionToken) { final ParseRESTCommand command = currentSaveEventuallyCommand(operationSet, PointerEncoder.get(), sessionToken); return command.executeAsync(client); }
/** * Set whether users belonging to the given role are allowed to read this object. The role must * already be saved on the server and its data must have been fetched in order to use this method. * * @param role The role to assign access. * @param allowed Whether the given role can read this object. */ public void setRoleReadAccess(ParseRole role, boolean allowed) { validateRoleState(role); setRoleReadAccess(role.getName(), allowed); }
/** * Set whether users belonging to the given role are allowed to write this object. The role must * already be saved on the server and its data must have been fetched in order to use this method. * * @param role The role to assign access. * @param allowed Whether the given role can write this object. */ public void setRoleWriteAccess(ParseRole role, boolean allowed) { validateRoleState(role); setRoleWriteAccess(role.getName(), allowed); }
@Override public ParseConfig call() { synchronized (currentConfigMutex) { if (currentConfig == null) { ParseConfig config = getFromDisk(); currentConfig = (config != null) ? config : new ParseConfig(); } } return currentConfig; } }, ParseExecutors.io());
@Override public Task<Void> then(Task<Void> task) { return getCurrentInstallationController().setAsync(ParseInstallation.this); } });
@Override public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { return new ParseIncrementOperation((Number) decoder.decode(source)); } });
@Override public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { return new ParseSetOperation(decoder.decode(source)); } });