示例#1
0
 public Dialog makeSimpleDialog(String title, String text) {
   if (mActivity == null) {
     logError("*** makeSimpleDialog failed: no current Activity!");
     return null;
   }
   return makeSimpleDialog(mActivity, title, text);
 }
示例#2
0
  /**
   * Creates a GoogleApiClient.Builder for use with @link{#setup}. Normally, you do not have to do
   * this; use this method only if you need to make nonstandard setup (e.g. adding extra scopes for
   * other APIs) on the GoogleApiClient.Builder before calling @link{#setup}.
   */
  public GoogleApiClient.Builder createApiClientBuilder() {
    if (mSetupDone) {
      String error =
          "GameHelper: you called GameHelper.createApiClientBuilder() after "
              + "calling setup. You can only get a client builder BEFORE performing setup.";
      logError(error);
      throw new IllegalStateException(error);
    }

    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(mActivity, this, this);

    if (0 != (mRequestedClients & CLIENT_GAMES)) {
      builder.addApi(Games.API, mGamesApiOptions);
      builder.addScope(Games.SCOPE_GAMES);
    }

    if (0 != (mRequestedClients & CLIENT_PLUS)) {
      builder.addApi(Plus.API);
      builder.addScope(Plus.SCOPE_PLUS_LOGIN);
    }

    if (0 != (mRequestedClients & CLIENT_APPSTATE)) {
      builder.addApi(AppStateManager.API);
      builder.addScope(AppStateManager.SCOPE_APP_STATE);
    }

    if (0 != (mRequestedClients & CLIENT_SNAPSHOT)) {
      builder.addScope(Drive.SCOPE_APPFOLDER);
      builder.addApi(Drive.API);
    }

    mGoogleApiClientBuilder = builder;
    return builder;
  }
示例#3
0
 private void doApiOptionsPreCheck() {
   if (mGoogleApiClientBuilder != null) {
     String error =
         "GameHelper: you cannot call set*ApiOptions after the client "
             + "builder has been created. Call it before calling createApiClientBuilder() "
             + "or setup().";
     logError(error);
     throw new IllegalStateException(error);
   }
 }
示例#4
0
 void assertConfigured(String operation) {
   if (!mSetupDone) {
     String error =
         "GameHelper error: Operation attempted without setup: "
             + operation
             + ". The setup() method must be called before attempting any other operation.";
     logError(error);
     throw new IllegalStateException(error);
   }
 }
示例#5
0
  /**
   * Performs setup on this GameHelper object. Call this from the onCreate() method of your
   * Activity. This will create the clients and do a few other initialization tasks. Next,
   * call @link{#onStart} from the onStart() method of your Activity.
   *
   * @param listener The listener to be notified of sign-in events.
   */
  public void setup(GameHelperListener listener) {
    if (mSetupDone) {
      String error = "GameHelper: you cannot call GameHelper.setup() more than once!";
      logError(error);
      throw new IllegalStateException(error);
    }
    mListener = listener;
    debugLog("Setup: requested clients: " + mRequestedClients);

    if (mGoogleApiClientBuilder == null) {
      // we don't have a builder yet, so create one
      createApiClientBuilder();
    }

    mGoogleApiClient = mGoogleApiClientBuilder.build();
    mGoogleApiClientBuilder = null;
    mSetupDone = true;
  }