public long createGame(Games game) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_HOME_ID, game.gethomeid());
    values.put(KEY_AWAY_ID, game.getawayid());
    values.put(KEY_DATE, game.getDate());

    values.put(KEY_HOME_SHOTS, 0);
    values.put(KEY_HOME_SOG, 0);
    values.put(KEY_HOME_GOALS, 0);
    values.put(KEY_HOME_AST, 0);
    values.put(KEY_HOME_PEN_MINOR, 0);
    values.put(KEY_HOME_PEN_MAJOR, 0);
    values.put(KEY_HOME_PEN_MISCONDUCT, 0);
    values.put(KEY_HOME_SAVES, 0);
    values.put(KEY_HOME_GOALS_ALLOWED, 0);

    values.put(KEY_AWAY_SHOTS, 0);
    values.put(KEY_AWAY_SOG, 0);
    values.put(KEY_AWAY_GOALS, 0);
    values.put(KEY_AWAY_AST, 0);
    values.put(KEY_AWAY_PEN_MINOR, 0);
    values.put(KEY_AWAY_PEN_MAJOR, 0);
    values.put(KEY_AWAY_PEN_MISCONDUCT, 0);
    values.put(KEY_AWAY_SAVES, 0);
    values.put(KEY_AWAY_GOALS_ALLOWED, 0);

    // insert row
    long g_id = db.insert(TABLE_GAMES, null, values);

    List<Players> home_players = getPlayersTeam(game.gethomeid());
    List<Players> away_players = getPlayersTeam(game.getawayid());

    for (Players player : home_players) {
      createGameStats(player.getpid(), g_id);
    }
    for (Players player : away_players) {
      createGameStats(player.getpid(), g_id);
    }

    return g_id;
  }
示例#2
0
  public int updatePlayer(Players player) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_T_ID, player.gettid());
    values.put(KEY_P_NAME, player.getpname());
    values.put(KEY_P_NUM, player.getpnum());
    if (!_local) {
      _net.updatePlayer(player);
    }
    return db.update(
        TABLE_PLAYERS, values, KEY_P_ID + " = ?", new String[] {String.valueOf(player.getpid())});
  }
示例#3
0
 @Override
 public void onClick(View view) {
   if (_viewSelected != null) {
     ArrayList<Players> players = (ArrayList<Players>) _db.getPlayersTeam2(t_id);
     Players curPlayer = null;
     String oldPName =
         ((TextView) ((LinearLayout) _viewSelected).getChildAt(1)).getText().toString();
     for (Players p : players) {
       if (oldPName.equals(p.getpname())) {
         curPlayer = p;
         break;
       }
     }
     _db.deletePlayer(curPlayer.getpid());
     _playerList.removeView(_viewSelected);
     _viewSelected = null;
   }
 }