/** * Substracts one point to the corresponding team score depending on the {@code callerView}. * * @param callerView The view that has called this method. * @since 6 */ public void substractScore(View callerView) { int teamScoreToSubstractId = -1; switch (callerView.getId()) { case R.id.trucoAnnotator_substractButtonTeam1: teamScoreToSubstractId = R.id.trucoAnnotator_scoreTeam1; break; case R.id.trucoAnnotator_substractButtonTeam2: teamScoreToSubstractId = R.id.trucoAnnotator_scoreTeam2; break; } if (teamScoreToSubstractId != -1) { TextSwitcher scoreToUpdate = (TextSwitcher) findViewById(teamScoreToSubstractId); String currentValueString = ((TextView) scoreToUpdate.getCurrentView()).getText().toString(); int currentScore = 0; if (!currentValueString.equals("")) { currentScore = Integer.valueOf(currentValueString); } if (currentScore != Integer.parseInt(getText(R.string.defaultInitialGameScore).toString())) { int updatedScore = currentScore - GameKeys.TRUCO_INCREMENT; Log.i(LOG_TAG, "Updating score to: " + updatedScore); scoreToUpdate.setText(String.valueOf(updatedScore)); if (updatedScore == GameKeys.TRUCO_MAX_SCORE_WITHOUT_WIN) { enableAllControls(); } } } }