Пример #1
0
  @Override
  public void onNextClicked() {
    // TODO: login user as anonymous

    Account account = mCurrentUser.getAccount();

    if (account == null) { // if there is no previously existing user

      mCurrentUser.createAnonymousUser(
          new ListUser.AnonymousUserCallback() {
            @Override
            public void onSuccess() {
              Log.v(TAG, "> createAnonymousUser > onSuccess");

              Account account = mCurrentUser.getAccount();
              String userID = am.getUserData(account, AccountGeneral.USER_ID);

              Log.v(TAG, "USER ID: " + userID);

              Intent intent = new Intent(StartActivity.this, CategoryListActivity.class);
              startActivity(intent);
            }

            @Override
            public void onAccountFail(Boolean bol) {
              Log.v(TAG, "> createAnonymousUser > onAccountFail: " + bol.toString());
              // TODO: if account fails to be created in
            }

            @Override
            public void onFail(VolleyError error) {
              Log.v(TAG, "> createAnonymousUser > onFail: " + error.getMessage());

              if (error instanceof NoConnectionError || error instanceof NetworkError) {
                // TODO: need an working internet connection
              } else if (error instanceof ServerError) {
                // TODO: we’re experiencing some problems dialog
              }
            }
          });

    } else {
      // TODO: what happens if you already have an account on the phone: account picker?
      Intent intent = new Intent(StartActivity.this, CategoryListActivity.class);
      startActivity(intent);
    }
  } // onNextClicked