Esempio n. 1
0
  private void loadAllEmotions(Event event) {

    String[] columns =
        new String[] {EmotionColumns._ID, EmotionColumns.EVENT_ID, EmotionColumns.EMOTION_TYPE};
    String where = EmotionColumns.EVENT_ID + "='" + event.getId() + "'";

    Cursor listOfEmotions =
        context.getContentResolver().query(EmotionColumns.CONTENT_URI, columns, where, null, null);

    if (listOfEmotions.moveToFirst()) {
      do {
        String id = listOfEmotions.getString(listOfEmotions.getColumnIndex(EmotionColumns._ID));
        switch (listOfEmotions.getInt(listOfEmotions.getColumnIndex(EmotionColumns.EMOTION_TYPE))) {
          case 1:
            event.addEmotion(new Emotion(id, EmotionEnum.LIKE));
            break;
          case 2:
            event.addEmotion(new Emotion(id, EmotionEnum.COOL));
            break;
          case 3:
            event.addEmotion(new Emotion(id, EmotionEnum.DISLIKE));
            break;
          case 4:
            event.addEmotion(new Emotion(id, EmotionEnum.SAD));
            break;
        }

      } while (listOfEmotions.moveToNext());
    }
    listOfEmotions.close();
  }
Esempio n. 2
0
  private void loadAllConnectedEventItems(Event event) {

    String[] eventItemsTableColumns =
        new String[] {
          EventItemsColumns.EVENT_ID,
          EventItemsColumns.EVENT_ITEM_ID,
          EventItemsColumns.EVENT_ITEM_TYPE
        };

    whereStatement = EventItemsColumns.EVENT_ID + "='" + event.getId() + "'";
    String sortOrder = EventItemsColumns.CREATED_DATE + " ASC";

    Cursor listOfEventItems =
        context
            .getContentResolver()
            .query(
                EventItemsColumns.CONTENT_URI,
                eventItemsTableColumns,
                whereStatement,
                null,
                sortOrder);
    DatabaseUtils.dumpCursor(listOfEventItems);
    Log.i("CURSOR", String.valueOf(listOfEventItems.moveToFirst()));
    if (listOfEventItems.moveToFirst()) {
      do {

        String eventItemID =
            listOfEventItems.getString(
                listOfEventItems.getColumnIndex(EventItemsColumns.EVENT_ITEM_ID));
        int itemType =
            listOfEventItems.getInt(
                listOfEventItems.getColumnIndex(EventItemsColumns.EVENT_ITEM_TYPE));

        if (itemType == ModelType.SimpleNote.numberOfType()) {

          addNoteItemToEvent(event, eventItemID);
        }
        if (itemType == ModelType.SimplePicture.numberOfType()) {
          addPictureItemToEvent(event, eventItemID);
        }
        if (itemType == ModelType.SimpleRecording.numberOfType()) {
          addRecordingItemToEvent(event, eventItemID);
        }
        if (itemType == ModelType.SimpleVideo.numberOfType()) {
          addVideoItemToEvent(event, eventItemID);
        }

      } while (listOfEventItems.moveToNext());
    }

    listOfEventItems.close();
  }
Esempio n. 3
0
  private void addPictureItemToEvent(Event event, String eventItemID) {

    String[] pictureColumns =
        new String[] {
          PictureColumns._ID,
          PictureColumns.URI_PATH,
          EventItemsColumns.USERNAME,
          PictureColumns.FILENAME
        };
    String whereStatement = PictureColumns._ID + "='" + eventItemID + "'";

    Cursor cursorOnListOfPicturesBelongingToEvent =
        context
            .getContentResolver()
            .query(PictureColumns.CONTENT_URI, pictureColumns, whereStatement, null, null);
    DatabaseUtils.dumpCursor(cursorOnListOfPicturesBelongingToEvent);
    if (cursorOnListOfPicturesBelongingToEvent.moveToFirst()) {
      do {
        SimplePicture picture =
            new SimplePicture(
                cursorOnListOfPicturesBelongingToEvent.getString(
                    cursorOnListOfPicturesBelongingToEvent.getColumnIndex(PictureColumns._ID)),
                Uri.parse(
                    cursorOnListOfPicturesBelongingToEvent.getString(
                        cursorOnListOfPicturesBelongingToEvent.getColumnIndex(
                            PictureColumns.URI_PATH))),
                new Account(
                    cursorOnListOfPicturesBelongingToEvent.getString(
                        cursorOnListOfPicturesBelongingToEvent.getColumnIndex(
                            EventItemsColumns.USERNAME)),
                    "com.google"),
                cursorOnListOfPicturesBelongingToEvent.getString(
                    cursorOnListOfPicturesBelongingToEvent.getColumnIndex(
                        PictureColumns.FILENAME)));

        event.getEventItems().add(picture);
      } while (cursorOnListOfPicturesBelongingToEvent.moveToNext());

      cursorOnListOfPicturesBelongingToEvent.close();
    }
  }
Esempio n. 4
0
  private void addNoteItemToEvent(Event event, String eventItemID) {

    String[] columns =
        new String[] {
          NoteColumns._ID,
          NoteColumns.TITLE,
          NoteColumns.NOTE,
          NoteColumns.CREATED_DATE,
          NoteColumns.MODIFIED_DATE,
          EventItemsColumns.USERNAME
        };
    String whereStatement = NoteColumns._ID + "='" + eventItemID + "'";
    Cursor listOfNotesBelongingToEvent =
        context
            .getContentResolver()
            .query(NoteColumns.CONTENT_URI, columns, whereStatement, null, null);

    if (listOfNotesBelongingToEvent.moveToFirst()) {
      do {
        SimpleNote note =
            new SimpleNote(
                listOfNotesBelongingToEvent.getString(
                    listOfNotesBelongingToEvent.getColumnIndex(NoteColumns._ID)),
                listOfNotesBelongingToEvent.getString(
                    listOfNotesBelongingToEvent.getColumnIndex(NoteColumns.TITLE)),
                listOfNotesBelongingToEvent.getString(
                    listOfNotesBelongingToEvent.getColumnIndex(NoteColumns.NOTE)),
                new Account(
                    listOfNotesBelongingToEvent.getString(
                        listOfNotesBelongingToEvent.getColumnIndex(EventItemsColumns.USERNAME)),
                    "com.google"));

        event.getEventItems().add(note);

      } while (listOfNotesBelongingToEvent.moveToNext());

      listOfNotesBelongingToEvent.close();
    }
  }
Esempio n. 5
0
  private void addRecordingItemToEvent(Event event, String eventItemID) {

    String[] recordingColumns =
        new String[] {
          RecordingColumns._ID,
          RecordingColumns.FILE_URI,
          EventItemsColumns.USERNAME,
          RecordingColumns.FILENAME
        };
    String whereStatement = RecordingColumns._ID + "='" + eventItemID + "'";

    Cursor cursorOnRecordingList =
        context
            .getContentResolver()
            .query(RecordingColumns.CONTENT_URI, recordingColumns, whereStatement, null, null);
    DatabaseUtils.dumpCursor(cursorOnRecordingList);

    if (cursorOnRecordingList.moveToFirst()) {
      do {
        SimpleRecording recording =
            new SimpleRecording(
                cursorOnRecordingList.getString(
                    cursorOnRecordingList.getColumnIndex(RecordingColumns._ID)),
                Uri.parse(
                    cursorOnRecordingList.getString(
                        cursorOnRecordingList.getColumnIndex(RecordingColumns.FILE_URI))),
                new Account(
                    cursorOnRecordingList.getString(
                        cursorOnRecordingList.getColumnIndex(EventItemsColumns.USERNAME)),
                    "com.google"),
                cursorOnRecordingList.getString(
                    cursorOnRecordingList.getColumnIndex(RecordingColumns.FILENAME)));

        event.addEventItem(recording);
      } while (cursorOnRecordingList.moveToNext());
      cursorOnRecordingList.close();
    }
  }
Esempio n. 6
0
  private void addVideoItemToEvent(Event event, String eventItemID) {

    String[] videoColumns =
        new String[] {
          VideoColumns._ID,
          VideoColumns.FILE_PATH,
          EventItemsColumns.USERNAME,
          VideoColumns.FILENAME
        };
    String whereStatement = VideoColumns._ID + "='" + eventItemID + "'";

    Cursor cursorOnVideoList =
        context
            .getContentResolver()
            .query(VideoColumns.CONTENT_URI, videoColumns, whereStatement, null, null);
    DatabaseUtils.dumpCursor(cursorOnVideoList);

    if (cursorOnVideoList.moveToFirst()) {
      do {
        SimpleVideo video =
            new SimpleVideo(
                cursorOnVideoList.getString(cursorOnVideoList.getColumnIndex(VideoColumns._ID)),
                Uri.parse(
                    cursorOnVideoList.getString(
                        cursorOnVideoList.getColumnIndex(VideoColumns.FILE_PATH))),
                new Account(
                    cursorOnVideoList.getString(
                        cursorOnVideoList.getColumnIndex(EventItemsColumns.USERNAME)),
                    "com.google"),
                cursorOnVideoList.getString(
                    cursorOnVideoList.getColumnIndex(RecordingColumns.FILENAME)));

        event.addEventItem(video);
      } while (cursorOnVideoList.moveToNext());
      cursorOnVideoList.close();
    }
  }
Esempio n. 7
0
  public ArrayList<BaseEvent> LoadAllEventsFromDatabase() {

    ArrayList<BaseEvent> allEvents = new ArrayList<BaseEvent>();

    String[] eventTableColumns =
        new String[] {
          EventColumns._ID,
          EventColumns.EVENT_EXPERIENCEID,
          EventColumns.EVENT_TITLE,
          EventColumns.EVENT_LOCATION_LAT,
          EventColumns.EVENT_LOCATION_LNG,
          EventColumns.IS_SHARED,
          EventColumns.CREATOR,
          EventColumns.MOODX,
          EventColumns.MOODY
        };

    Cursor c =
        context
            .getContentResolver()
            .query(EventColumns.CONTENT_URI, eventTableColumns, null, null, null);

    if (c.moveToFirst()) {
      do {
        Date createdDate = new Date(c.getLong(c.getColumnIndex(EventColumns.EVENT_TITLE)));
        Location location = new Location("");
        location.setLatitude(
            Double.parseDouble(c.getString(c.getColumnIndex(EventColumns.EVENT_LOCATION_LAT))));
        location.setLongitude(
            Double.parseDouble(c.getString(c.getColumnIndex(EventColumns.EVENT_LOCATION_LNG))));

        if ((Double.parseDouble(c.getString(c.getColumnIndex(EventColumns.MOODX))) == 1000)) {
          Event event =
              new Event(
                  c.getString(c.getColumnIndex(EventColumns._ID)),
                  c.getString(c.getColumnIndex(EventColumns.EVENT_EXPERIENCEID)),
                  createdDate,
                  location,
                  new Account(c.getString(c.getColumnIndex(EventColumns.CREATOR)), "com.google"));

          event.setShared(
              (c.getInt((c.getColumnIndex(EventColumns.IS_SHARED))) == 1) ? true : false);
          loadAllEmotions(event);
          loadAllConnectedEventItems(event);
          event.setTags(tagManager.getAllTagsConnectedToEvent(event.getId()));
          allEvents.add(event);
        } else {
          MoodEvent moodEvent =
              new MoodEvent(
                  c.getString(c.getColumnIndex(EventColumns._ID)),
                  c.getString(c.getColumnIndex(EventColumns.EVENT_EXPERIENCEID)),
                  createdDate,
                  location,
                  MoodEnum.getType(
                      (Double.parseDouble(c.getString(c.getColumnIndex(EventColumns.MOODX)))),
                      (Double.parseDouble(c.getString(c.getColumnIndex(EventColumns.MOODY))))),
                  new Account(c.getString(c.getColumnIndex(EventColumns.CREATOR)), "com.google"));
          allEvents.add(moodEvent);
        }
      } while (c.moveToNext());
    }
    c.close();

    Log.i("CONTENTLOADER - EVENTS", allEvents.size() + " events loaded");

    return allEvents;
  }