コード例 #1
0
  private void authenticateUser(CharSequence registerName, CharSequence registerPassword) {

    FirebaseManager.getInstance()
        .authenticate(
            registerName,
            registerPassword,
            new FirebaseManager.FirebaseListener() {
              @Override
              public void onSuccess(String userID) {
                Intent intent = new Intent(MainActivity.this, UserActivity.class);
                startActivity(intent);
                System.out.println("l utilisateur est loggé");
              }

              @Override
              public void onError() {
                Snackbar.make(
                        findViewById(R.id.mainContainer),
                        "L'authentification a échoué",
                        Snackbar.LENGTH_LONG)
                    .setAction(
                        "UNDO",
                        new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                            Log.d(TAG, "closed");
                          }
                        })
                    .show();
              }
            });
  }
コード例 #2
0
  private void registerUser(CharSequence registerName, CharSequence registerPassword) {

    // try to register to firebase

    FirebaseManager.getInstance()
        .register(
            registerName,
            registerPassword,
            new FirebaseManager.FirebaseListener() {
              @Override
              public void onSuccess(String userID) {
                Snackbar.make(
                        findViewById(R.id.mainContainer),
                        "Utilisateur créé : " + userID,
                        Snackbar.LENGTH_LONG)
                    .setAction(
                        "LOGIN",
                        new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                            Log.d(TAG, "closed");
                          }
                        })
                    .show();
              }

              @Override
              public void onError() {
                Snackbar.make(
                        findViewById(R.id.mainContainer),
                        "L'inscription n'a pas fonctionné",
                        Snackbar.LENGTH_LONG)
                    .setAction(
                        "UNDO",
                        new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                            Log.d(TAG, "closed");
                          }
                        })
                    .show();
              }
            });
  }