示例#1
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())});
  }
  @SuppressWarnings("unchecked")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stats);

    _team = (Teams) getIntent().getSerializableExtra(StaticFinalVars.TEAM_INFO);
    _players = (ArrayList<Players>) getIntent().getSerializableExtra(StaticFinalVars.PLAYERS_INFO);
    g_id = (Long) getIntent().getSerializableExtra(StaticFinalVars.GAME_ID);
    _name = getIntent().getStringExtra(StaticFinalVars.PLAYER_NAME);
    _home = getIntent().getBooleanExtra(StaticFinalVars.HOME_OR_AWAY, true);
    _shots =
        (ArrayList<ShotChartCoords>) getIntent().getSerializableExtra(StaticFinalVars.SHOT_CHART);
    // NEW
    _hockey_db = new HockeyDatabaseHelper(HockeyIndividualStatActivity.this);

    _player = getIntent().getStringExtra(StaticFinalVars.PLAYER);
    _team2 = (Teams) getIntent().getSerializableExtra(StaticFinalVars.TEAM_INFO2);
    // AVE
    _games = (ArrayList<BasketballGames>) getIntent().getSerializableExtra(StaticFinalVars.GAMES);
    _average = getIntent().getBooleanExtra(StaticFinalVars.AVERAGE, false);

    if (_name != null) {
      if (_shots.isEmpty() && !_name.equals(_team.getabbv() + " Stats")) {
        _shots = (ArrayList<ShotChartCoords>) _hockey_db.getAllTeamShotsGame(_team.gettid(), g_id);
      } else if (_shots.isEmpty() && !_name.equals(_team2.getabbv() + " Stats")) {
        _shots = (ArrayList<ShotChartCoords>) _hockey_db.getAllTeamShotsGame(_team2.gettid(), g_id);
      } else if (_shots.isEmpty() && !_name.equals("All Players")) {
        Players p2 = null;
        for (Players p : _players) {
          if (p.getpname().equals(_name)) {
            p2 = p;
            break;
          }
        }
        long t_id = -1;
        if (p2.gettid() == _team.gettid()) {
          t_id = _team.gettid();
        } else if (p2.gettid() == _team2.gettid()) {
          t_id = _team2.gettid();
        }
        _shots = (ArrayList<ShotChartCoords>) _hockey_db.getAllTeamShotsGame(t_id, g_id);
      }
    }
    if (_player != null) {
      if (_shots.isEmpty() && !_player.equals("All Players")) {
        Players p2 = null;
        for (Players p : _players) {
          if (p.getpname().equals(_player)) {
            p2 = p;
            break;
          }
        }
        long t_id = -1;
        if (p2.gettid() == _team.gettid()) {
          t_id = _team.gettid();
        } else if (p2.gettid() == _team2.gettid()) {
          t_id = _team2.gettid();
        }
        _shots = (ArrayList<ShotChartCoords>) _hockey_db.getAllTeamShotsGame(t_id, g_id);
      }
    }

    // END NEW
    _gameInfo = (GameInfo) getIntent().getSerializableExtra(StaticFinalVars.GAME_INFO);
    int value = getIntent().getIntExtra(StaticFinalVars.DISPLAY_TYPE, 0);

    _hockey_db = new HockeyDatabaseHelper(getApplicationContext());
    _game = (HockeyGames) _hockey_db.getGame(g_id);

    _pager = (ViewPager) findViewById(R.id.statsPager);
    if (_average) {
      _pagerAdapter = new HockeyIndividualStatPageAdapter(getSupportFragmentManager(), 1);
    } else {
      _pagerAdapter = new HockeyIndividualStatPageAdapter(getSupportFragmentManager(), 2);
    }
    _pager.setAdapter(_pagerAdapter);
    _pager.setCurrentItem(value);
  }