Search in sources :

Example 16 with MediaEntity

use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.

the class ListPhotoModel method getPhotosByCheckinId.

public List<PhotoEntity> getPhotosByCheckinId(int checkinId) {
    mPhotoModel = new ArrayList<PhotoEntity>();
    mMedia = Database.mMediaDao.fetchCheckinPhoto(checkinId);
    if (mMedia != null && mMedia.size() > 0) {
        for (MediaEntity item : mMedia) {
            PhotoEntity photo = new PhotoEntity();
            photo.setDbId(item.getDbId());
            photo.setPhoto(item.getLink());
            mPhotoModel.add(photo);
        }
    }
    return mPhotoModel;
}
Also used : PhotoEntity(com.ushahidi.android.app.entities.PhotoEntity) MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 17 with MediaEntity

use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.

the class MediaDao method fetchPendingCheckinPhoto.

@Override
public List<MediaEntity> fetchPendingCheckinPhoto(int checkinId) {
    listMedia = new ArrayList<MediaEntity>();
    final String selection = CHECKIN_ID + " = " + checkinId + " AND " + TYPE + " =" + IMAGE;
    cursor = super.query(TABLE, MEDIA_COLUMNS, selection, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            MediaEntity media = cursorToEntity(cursor);
            listMedia.add(media);
            cursor.moveToNext();
        }
        cursor.close();
    }
    return listMedia;
}
Also used : MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 18 with MediaEntity

use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.

the class MediaDao method fetchReportPhoto.

@Override
public List<MediaEntity> fetchReportPhoto(int reportId) {
    listMedia = new ArrayList<MediaEntity>();
    final String selection = REPORT_ID + " = " + reportId + " AND " + TYPE + " =" + IMAGE;
    cursor = super.query(TABLE, MEDIA_COLUMNS, selection, null, null);
    if (cursor != null) {
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            MediaEntity media = cursorToEntity(cursor);
            listMedia.add(media);
            cursor.moveToNext();
        }
        cursor.close();
    }
    return listMedia;
}
Also used : MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 19 with MediaEntity

use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.

the class MediaDao method fetchMedia.

@Override
public List<MediaEntity> fetchMedia(String itemType, int itemId, int mediaType, int limit) {
    listMedia = new ArrayList<MediaEntity>();
    final String selection = itemType + " =" + itemId + " AND " + TYPE + " =" + mediaType;
    cursor = super.query(TABLE, MEDIA_COLUMNS, selection, null, null, String.valueOf(limit));
    if (cursor != null) {
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            MediaEntity media = cursorToEntity(cursor);
            listMedia.add(media);
            cursor.moveToNext();
        }
        cursor.close();
    }
    return listMedia;
}
Also used : MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 20 with MediaEntity

use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.

the class MediaDao method cursorToEntity.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ushahidi.android.app.database.DbContentProvider#cursorToEntity(android
	 * .database.Cursor)
	 */
@SuppressWarnings("unchecked")
@Override
protected MediaEntity cursorToEntity(Cursor cursor) {
    MediaEntity media = new MediaEntity();
    int idIndex;
    int reportIdIndex;
    int checkinIdIndex;
    int typeIndex;
    int linkIndex;
    if (cursor != null) {
        if (cursor.getColumnIndex(ID) != -1) {
            idIndex = cursor.getColumnIndexOrThrow(ID);
            media.setDbId(cursor.getInt(idIndex));
        }
        if (cursor.getColumnIndex(REPORT_ID) != -1) {
            reportIdIndex = cursor.getColumnIndexOrThrow(REPORT_ID);
            media.setReportId(cursor.getInt(reportIdIndex));
        }
        if (cursor.getColumnIndex(CHECKIN_ID) != -1) {
            checkinIdIndex = cursor.getColumnIndexOrThrow(CHECKIN_ID);
            media.setCheckinId(cursor.getInt(checkinIdIndex));
        }
        if (cursor.getColumnIndex(TYPE) != -1) {
            typeIndex = cursor.getColumnIndexOrThrow(TYPE);
            media.setType(cursor.getInt(typeIndex));
        }
        if (cursor.getColumnIndex(LINK) != -1) {
            linkIndex = cursor.getColumnIndexOrThrow(LINK);
            media.setLink(cursor.getString(linkIndex));
        }
    }
    return media;
}
Also used : MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Aggregations

MediaEntity (com.ushahidi.android.app.entities.MediaEntity)22 PhotoEntity (com.ushahidi.android.app.entities.PhotoEntity)6 ReportCategory (com.ushahidi.android.app.entities.ReportCategory)3 File (java.io.File)2 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 ReportEntity (com.ushahidi.android.app.entities.ReportEntity)1 AddReportView (com.ushahidi.android.app.views.AddReportView)1 ArrayList (java.util.ArrayList)1