Ejemplo n.º 1
0
  /** Shows the login fragment for the user to enter their credentials */
  private void showLoginFragment() {

    mLoginFragment = LoginFragment.newInstance("*****@*****.**", "password", true);

    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    fragmentTransaction.setCustomAnimations(R.animator.frag_in, R.animator.frag_out);
    fragmentTransaction.replace(R.id.fragment_place, mLoginFragment);
    fragmentTransaction.commit();
  }
Ejemplo n.º 2
0
  /**
   * Implements the login button pressed called by the LoginFragment
   *
   * @param usernameOrEmail the username or email entered
   * @param password the password entered
   * @param rememberMe true if the user wants to autologin next time
   */
  @Override
  public void loginPressed(String usernameOrEmail, String password, boolean rememberMe) {

    Log.d(
        LOG_TAG,
        "Login Pressed. Username='******', Password='******', Remember Me="
            + rememberMe);

    showBusy(true);

    // Disable the fragment so the user can't press or enter text while we are calling the
    // litter service
    mLoginFragment.enable(false);

    mGlitterAPI.login(
        usernameOrEmail,
        password,
        new LitterAPI.LoginCallback() {
          @Override
          public void loginSuccessful(User user) {
            // Success!

            mCurrentUser = user;

            showBusy(false);
            showLittersList();
          }

          @Override
          public void badCredentials() {
            showBusy(false);
            showBadCredentials();
          }

          @Override
          public void callFailed(String message) {
            // TODO: Network communictions failure displayed here
          }
        });
  }