com.parse.ParseConfigController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of parse-android Show documentation
Show all versions of parse-android Show documentation
A library that gives you access to the powerful Parse cloud platform from your Android app.
/*
* Copyright (c) 2015-present, Parse, LLC.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.parse;
import org.json.JSONObject;
import bolts.Continuation;
import bolts.Task;
/** package */ class ParseConfigController {
private ParseCurrentConfigController currentConfigController;
private final ParseHttpClient restClient;
public ParseConfigController(ParseHttpClient restClient,
ParseCurrentConfigController currentConfigController) {
this.restClient = restClient;
this.currentConfigController = currentConfigController;
}
/* package */ ParseCurrentConfigController getCurrentConfigController() {
return currentConfigController;
}
public Task getAsync(String sessionToken) {
final ParseRESTCommand command = ParseRESTConfigCommand.fetchConfigCommand(sessionToken);
command.enableRetrying();
return command.executeAsync(restClient).onSuccessTask(new Continuation>() {
@Override
public Task then(Task task) throws Exception {
JSONObject result = task.getResult();
final ParseConfig config = ParseConfig.decode(result, ParseDecoder.get());
return currentConfigController.setCurrentConfigAsync(config).continueWith(new Continuation() {
@Override
public ParseConfig then(Task task) throws Exception {
return config;
}
});
}
});
}
}