public void recordActivity(String time) { if (time.equals("Restart Clock")) { PlayByPlay pbp = new PlayByPlay(g_id, _thePlay + ".", time, null, 0, 0); ((BasketballDatabaseHelper) _db).createPlayByPlay(pbp); } else { _timeStamp = time; PlayByPlay pbp = new PlayByPlay(g_id, "(" + _timeStamp + ")" + _thePlay + ".", time, null, 0, 0); ((BasketballDatabaseHelper) _db).createPlayByPlay(pbp); } }
@Override public void onClick(View view) { String teamName = ((EditText) findViewById(R.id.teamNameEditText)).getText().toString(); String teamAbbr = ((EditText) findViewById(R.id.teamAbbrEditText)).getText().toString(); String coachName = ((EditText) findViewById(R.id.coachNameEditText)).getText().toString(); long t_id = -1; if (!_editing) { t_id = _db.createTeams(new Teams(teamName, teamAbbr, coachName, _sportType)); } for (int i = 0; i < _playerList.getChildCount(); i++) { String playerName = ((TextView) ((LinearLayout) _playerList.getChildAt(i)).getChildAt(1)) .getText() .toString(); int playerNumber = Integer.parseInt( ((TextView) ((LinearLayout) _playerList.getChildAt(i)).getChildAt(0)) .getText() .toString()); if (!_editing) { if (_sportType.equals("basketball")) { ((BasketballDatabaseHelper) _db) .createPlayers(new BasketballPlayer(t_id, playerName, playerNumber)); } else if (_sportType.equals("soccer")) { ((SoccerDatabaseHelper) _db) .createPlayers(new SoccerPlayer(t_id, playerName, playerNumber)); } else if (_sportType.equals("hockey")) { ((HockeyDatabaseHelper) _db) .createPlayers(new HockeyPlayer(t_id, playerName, playerNumber)); } else if (_sportType.equals("football")) { ((FootballDatabaseHelper) _db) .createPlayers(new FootballPlayer(t_id, playerName, playerNumber)); } // else if(other sports that could be added)... } } if (_editing) { ArrayList<Teams> teams = (ArrayList<Teams>) _db.getAllTeams(); Teams cur = null; for (Teams team : teams) { if (team.gettname().equals(_oldTeamName)) { cur = team; break; } } t_id = cur.gettid(); _db.updateTeam(new Teams(t_id, teamName, teamAbbr, coachName, _sportType)); } _editing = false; int num = _playerList.getChildCount(); if (_sportType.equals("basketball") && num < 5) { for (int i = num + 1; i <= 5; i++) { String pname = "Player " + i; for (int j = 0; j < _playerList.getChildCount(); j++) { String playerName = ((TextView) ((LinearLayout) _playerList.getChildAt(j)).getChildAt(1)) .getText() .toString(); if (pname.equals(playerName)) { pname += "a"; } } BasketballPlayer p = new BasketballPlayer(t_id, pname, 0); ((BasketballDatabaseHelper) _db).createPlayers(p); } } else if (_sportType.equals("hockey") && num < 6) { for (int i = num + 1; i <= 6; i++) { String pname = "Player " + i; for (int j = 0; j < _playerList.getChildCount(); j++) { String playerName = ((TextView) ((LinearLayout) _playerList.getChildAt(j)).getChildAt(1)) .getText() .toString(); if (pname.equals(playerName)) { pname += "a"; } } HockeyPlayer p = new HockeyPlayer(t_id, pname, 0); ((HockeyDatabaseHelper) _db).createPlayers(p); } } else if (_sportType.equals("soccer") && num < 11) { for (int i = num + 1; i <= 11; i++) { String pname = "Player " + i; for (int j = 0; j < _playerList.getChildCount(); j++) { String playerName = ((TextView) ((LinearLayout) _playerList.getChildAt(j)).getChildAt(1)) .getText() .toString(); if (pname.equals(playerName)) { pname += "a"; } } SoccerPlayer p = new SoccerPlayer(t_id, pname, 0); ((SoccerDatabaseHelper) _db).createPlayers(p); } } else if (_sportType.equals("football") && num < 11) { for (int i = num + 1; i <= 11; i++) { String pname = "Player " + i; for (int j = 0; j < _playerList.getChildCount(); j++) { String playerName = ((TextView) ((LinearLayout) _playerList.getChildAt(j)).getChildAt(1)) .getText() .toString(); if (pname.equals(playerName)) { pname += "a"; } } FootballPlayer p = new FootballPlayer(t_id, pname, 0); ((FootballDatabaseHelper) _db).createPlayers(p); } } Intent intent = new Intent(); intent.putExtra(StaticFinalVars.TEAM_NAME, teamName); intent.putExtra(StaticFinalVars.OLD_TEAM_NAME, _oldTeamName); setResult(Activity.RESULT_OK, intent); finish(); }