Example #1
0
  public List<PlayByPlay> getPlayByPlayGame(long g_id) {
    if (_local) {
      SQLiteDatabase db = this.getReadableDatabase();
      List<PlayByPlay> pbps = new ArrayList<PlayByPlay>();
      String selectPlayByPlayQuery =
          "SELECT * FROM " + TABLE_PLAY_BY_PLAY + " WHERE " + KEY_G_ID + " = " + g_id;

      Log.i(LOG, selectPlayByPlayQuery);

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

      if (c != null && c.moveToFirst()) {
        do {
          // create the instance of Players using cursor information
          PlayByPlay pbp = new PlayByPlay();
          pbp.setaid(c.getLong(c.getColumnIndex(KEY_A_ID)));
          pbp.setgid(c.getLong(c.getColumnIndex(KEY_G_ID)));
          pbp.setaction(c.getString(c.getColumnIndex(KEY_ACTION)));
          pbp.settime(c.getString(c.getColumnIndex(KEY_TIME)));
          pbp.setperiod(c.getString(c.getColumnIndex(KEY_PERIOD)));
          pbp.sethomescore(c.getInt(c.getColumnIndex(KEY_HOME_SCORE)));
          pbp.setawayscore(c.getInt(c.getColumnIndex(KEY_AWAY_SCORE)));
          // adding to playbyplay list
          pbps.add(pbp);
        } while (c.moveToNext());
      }
      return pbps;
    } else {
      return _net.getPlayByPlayGame(g_id);
    }
  }
Example #2
0
  public long createPlayByPlay(PlayByPlay pbp) {
    SQLiteDatabase db = this.getWritableDatabase();
    Log.i("INTEG", "starting play by play creation");
    ContentValues values = new ContentValues();
    values.put(KEY_G_ID, pbp.getgid());
    values.put(KEY_ACTION, pbp.getaction());
    values.put(KEY_TIME, pbp.gettime());
    values.put(KEY_PERIOD, pbp.getperiod());
    values.put(KEY_HOME_SCORE, pbp.gethomescore());
    values.put(KEY_AWAY_SCORE, pbp.getawayscore());

    // insert row
    long a_id = db.insert(TABLE_PLAY_BY_PLAY, null, values);

    pbp.setaid(a_id);
    if (!_local) {
      Log.i("INTEG", "entering network pbp creation");
      _net.createPlayByPlay(pbp, a_id);
    }
    return a_id;
  }