Esempio n. 1
0
  public List<ShotChartCoords> getAllPlayerShots(long p_id) {
    if (_local) {
      SQLiteDatabase db = this.getReadableDatabase();
      List<ShotChartCoords> shots = new ArrayList<ShotChartCoords>();
      String selectQuery =
          "SELECT * FROM " + TABLE_SHOT_CHART_COORDS + "WHERE " + KEY_P_ID + " = " + p_id;

      Log.i(LOG, selectQuery);

      Cursor c = db.rawQuery(selectQuery, null);

      if (c != null && c.moveToFirst()) {

        do {
          // create the instance of Players using cursor information
          ShotChartCoords shot = new ShotChartCoords();
          shot.setshotid(c.getLong(c.getColumnIndex(KEY_SHOT_ID)));
          shot.setgid((c.getLong(c.getColumnIndex(KEY_G_ID))));
          shot.setpid((c.getLong(c.getColumnIndex(KEY_P_ID))));
          shot.settid((c.getLong(c.getColumnIndex(KEY_T_ID))));
          shot.setx((c.getInt(c.getColumnIndex(KEY_X))));
          shot.sety((c.getInt(c.getColumnIndex(KEY_Y))));
          shot.setmade((c.getString(c.getColumnIndex(KEY_MADE))));

          // adding to players list
          shots.add(shot);
        } while (c.moveToNext());
      }
      return shots;
    } else {
      return _net.getAllPlayerShots(p_id);
    }
  }
Esempio n. 2
0
  // create a row of shot chart coordinates
  public long createShot(ShotChartCoords shot) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_G_ID, shot.getgid());
    values.put(KEY_P_ID, shot.getpid());
    values.put(KEY_T_ID, shot.gettid());
    values.put(KEY_X, shot.getx());
    values.put(KEY_Y, shot.gety());
    values.put(KEY_MADE, shot.getmade());

    // insert row
    long shot_id = db.insert(TABLE_SHOT_CHART_COORDS, null, values);

    shot.setshotid(shot_id);
    _undoInstance.setshot(shot);
    if (!_local) {
      _net.createShot(shot, shot_id);
    }

    return shot_id;
  }