Ejemplo n.º 1
0
 void sendRequest(Team team) {
   SessionManager.getInstance(getApplicationContext()).createSession(team, "team");
   ServiceParams params =
       new ServiceParams(
           getString(R.string.team_path)
               + team.getIdTeam()
               + getString(R.string.persons_path)
               + self.getIdPerson(),
           HttpMethod.POST,
           null);
   new ServiceAsyncTask(handlerTransit).execute(params);
 }
Ejemplo n.º 2
0
        @Override
        public void onClick(View v) {
          Log.i("hr.foi.debug", "UserProfileActivity -- initiated user update");

          String firstNameValue = firstName.getText().toString();
          String lastNameValue = lastName.getText().toString();
          String passwordValue = password.getText().toString();

          // if inputs are valid and passwords are matching
          if (Input.validate(inputs)
              && inputs.get(inputs.size() - 2).equals(inputs.get(inputs.size() - 1))) {

            Log.i("hr.foi.debug", "UserProfileActivity -- fetching user from session");

            Log.i(
                "hr.foi.debug",
                "UserProfileActivity --  user fetched from session " + user.toString());
            user.setName(firstNameValue);
            user.setSurname(lastNameValue);
            Credentials changedPassword =
                new Credentials(user.getCredentials().getUsername(), passwordValue);
            user.setCredentials(changedPassword);

            SessionManager manager = SessionManager.getInstance(getApplicationContext());

            Token userToken = manager.retrieveSession("token", Token.class);

            Log.i("hr.foi.debug", "UserProfileActivity --  calling web service ");

            UpdateHandler updateHandler = new UpdateHandler(UserProfileActivity.this, user);

            new ServiceAsyncTask(updateHandler)
                .execute(
                    new ServiceParams(
                        getString(hr.foi.rsc.webservice.R.string.persons_path) + user.getIdPerson(),
                        HttpMethod.PUT,
                        user,
                        userToken));
          }
        }
Ejemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    code = intent.getStringExtra("code");
    self =
        SessionManager.getInstance(getApplicationContext()).retrieveSession("person", Person.class);

    ServiceParams params =
        new ServiceParams(getString(R.string.game_code_path) + code, HttpMethod.GET, null);
    new ServiceAsyncTask(handler).execute(params);
  }
Ejemplo n.º 4
0
        @Override
        public boolean handleResponse(ServiceResponse response) {
          if (response.getHttpCode() == 200) {
            Game game = new Gson().fromJson(response.getJsonResponse(), Game.class);
            if (game != null && game.getTeam().size() != 0) {

              setContentView(R.layout.activity_choose_team);

              ImageButton red = (ImageButton) findViewById(R.id.ibCtmRed);
              red.setOnClickListener(onRed);

              ImageButton blue = (ImageButton) findViewById(R.id.ibCtmBlue);
              blue.setOnClickListener(onBlue);

              SessionManager.getInstance(getApplicationContext()).createSession(game, "game");
              redTeam = game.getTeam().get(0);
              blueTeam = game.getTeam().get(1);

              redView = (TextView) findViewById(R.id.textViewTeamREd);
              blueView = (TextView) findViewById(R.id.textViewTeamBlue);

              redView.setText(redTeam.getName());
              blueView.setText(blueTeam.getName());

              red.setEnabled(true);
              blue.setEnabled(true);

              return true;
            } else {
              Toast.makeText(
                      getApplicationContext(),
                      "There is no team found for code " + code,
                      Toast.LENGTH_LONG)
                  .show();
              finish();
            }
          } else {
            Toast.makeText(
                    getApplicationContext(), "Failed to fetch teams for match!", Toast.LENGTH_LONG)
                .show();
            finish();
          }
          return false;
        }
Ejemplo n.º 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);

    // session
    user =
        SessionManager.getInstance(getApplicationContext()).retrieveSession("person", Person.class);

    // binding
    firstName = (EditText) findViewById(R.id.firstNameInput);
    username = (EditText) findViewById(R.id.usernameInput);
    username.setClickable(false);
    lastName = (EditText) findViewById(R.id.lastNameInput);
    password = (EditText) findViewById(R.id.passwordInput);
    confirmPassword = (EditText) findViewById(R.id.confirmPasswordInput);
    change = (Button) findViewById(R.id.submitButton);

    // input fill
    firstName.setText(user.getName());
    lastName.setText(user.getSurname());
    username.setText(user.getCredentials().getUsername());
    password.setText(user.getCredentials().getPassword());

    change.setOnClickListener(onChange);

    // input validation
    inputs =
        Arrays.asList(
            new Input(firstName, Input.TEXT_MAIN_PATTERN, getString(R.string.firstname_error)),
            new Input(lastName, Input.TEXT_MAIN_PATTERN, getString(R.string.lastname_error)),
            new Input(password, Input.PASSWORD_PATTERN, getString(R.string.password_error)),
            new Input(
                confirmPassword,
                Input.PASSWORD_PATTERN,
                getString(R.string.matching_password_error)));

    // hide keyboard
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  }