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;
}
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;
}
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;
}
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;
}
use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.
the class MediaDao method addMedia.
/*
* (non-Javadoc)
*
* @see com.ushahidi.android.app.database.IMediaDao#addMedia(java.util.List)
*/
@Override
public boolean addMedia(List<MediaEntity> sMedia) {
try {
mDb.beginTransaction();
for (MediaEntity media : sMedia) {
addMedia(media);
}
mDb.setTransactionSuccessful();
} finally {
mDb.endTransaction();
}
return true;
}
Aggregations