Exemplo n.º 1
0
  private void loadHistory() {
    data.clear();
    Cursor result = dbManager.getAllTrips(modality);
    if (result != null) {
      if (result.getCount() > 0) {
        int key = result.getColumnIndex(DatabaseManager.tripKey);
        int origin_index = result.getColumnIndex(DatabaseManager.origin);
        int destination_index = result.getColumnIndex(DatabaseManager.destination);
        int count_index = result.getColumnIndex(DatabaseManager.tripCount);
        int busNumber = result.getColumnIndex(DatabaseManager.modality);

        result.moveToFirst();
        while (!result.isAfterLast()) {
          HashMap<String, String> map = new HashMap<String, String>();
          map.put(tripKey, "" + result.getInt(key));
          if (modality == DatabaseManager.TUBE) {
            map.put(
                tripId,
                result.getString(origin_index) + " to " + result.getString(destination_index));
          } else {
            map.put(
                tripId,
                result.getString(busNumber)
                    + ", "
                    + result.getString(origin_index)
                    + " to "
                    + result.getString(destination_index));
          }

          int count = result.getInt(count_index);
          if (count != 1)
            map.put(
                tripCount,
                "You have rated this trip " + (new Integer(count).toString()) + " times.");
          else map.put(tripCount, "You have rated this trip 1 time.");

          data.add(map);
          result.moveToNext();
        }
      }
      close(result);
    }
  }
Exemplo n.º 2
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   dbManager.close();
 }
Exemplo n.º 3
0
 private void close(Cursor r) {
   r.close();
   dbManager.close();
 }
Exemplo n.º 4
0
 private void insertAndFinish(String o, String d, String type) {
   int key = dbManager.insertNewTrip(o, d, type);
   submit(key);
 }