All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.parse.ParseConfigController Maven / Gradle / Ivy

Go to download

A library that gives you access to the powerful Parse cloud platform from your Android app.

There is a newer version: 1.17.3
Show newest version
/*
 * 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;
          }
        });
      }
    });
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy