use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class AddReportModel method updatePendingReport.
public boolean updatePendingReport(int reportId, ReportEntity report, Vector<Integer> category, List<PhotoEntity> pendingPhotos, String news) {
boolean status;
// update pending reports
status = Database.mReportDao.updatePendingReport(reportId, report);
// update category
if (status) {
if (category != null && category.size() > 0) {
// delete existing categories. It's easier this way
Database.mReportCategoryDao.deleteReportCategoryByReportId(reportId, IReportSchema.PENDING);
for (Integer cat : category) {
ReportCategory reportCategory = new ReportCategory();
reportCategory.setCategoryId(cat);
reportCategory.setReportId(reportId);
reportCategory.setStatus(IReportSchema.PENDING);
Database.mReportCategoryDao.addReportCategory(reportCategory);
}
}
// update photos
if (pendingPhotos != null && pendingPhotos.size() > 0) {
// delete existing photo
Database.mMediaDao.deleteReportPhoto(reportId);
for (PhotoEntity photo : pendingPhotos) {
MediaEntity media = new MediaEntity();
media.setMediaId(0);
// FIXME:: this is nasty.
String[] sections = photo.getPhoto().split("/");
media.setLink(sections[1]);
// get report ID
media.setReportId(reportId);
media.setType(IMediaSchema.IMAGE);
Database.mMediaDao.addMedia(media);
}
}
// add news
if (news != null && news.length() > 0) {
// delete existing news item
Database.mMediaDao.deleteReportNews(reportId);
MediaEntity media = new MediaEntity();
media.setMediaId(0);
media.setLink(news);
// get report ID;
media.setReportId(reportId);
media.setType(IMediaSchema.NEWS);
Database.mMediaDao.addMedia(media);
}
}
return status;
}
use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class ListPhotoModel method getPhotosByReportId.
public List<PhotoEntity> getPhotosByReportId(int reportId) {
mPhotoModel = new ArrayList<PhotoEntity>();
mMedia = Database.mMediaDao.fetchReportPhoto(reportId);
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;
}
use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class ListPhotoModel method getPendingPhotosByReportId.
public List<PhotoEntity> getPendingPhotosByReportId(int reportId) {
mPhotoModel = new ArrayList<PhotoEntity>();
mMedia = Database.mMediaDao.fetchPendingReportPhoto(reportId);
if (mMedia != null && mMedia.size() > 0) {
for (MediaEntity item : mMedia) {
PhotoEntity photo = new PhotoEntity();
photo.setDbId(item.getDbId());
photo.setPhoto(FETCHED + item.getLink());
mPhotoModel.add(photo);
}
}
return mPhotoModel;
}
use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class ListPhotoModel method getPhotos.
public List<PhotoEntity> getPhotos() {
mPhotoModel = new ArrayList<PhotoEntity>();
if (mMedia != null && mMedia.size() > 0) {
PhotoEntity photo = new PhotoEntity();
photo.setDbId(mMedia.get(0).getDbId());
photo.setPhoto(mMedia.get(0).getLink());
mPhotoModel.add(photo);
}
return mPhotoModel;
}
use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class ListPhotoModel method getPendingPhotosByCheckinId.
public List<PhotoEntity> getPendingPhotosByCheckinId(int checkinId) {
mPhotoModel = new ArrayList<PhotoEntity>();
mMedia = Database.mMediaDao.fetchPendingCheckinPhoto(checkinId);
if (mMedia != null && mMedia.size() > 0) {
for (MediaEntity item : mMedia) {
PhotoEntity photo = new PhotoEntity();
photo.setDbId(item.getDbId());
photo.setPhoto(FETCHED + item.getLink());
mPhotoModel.add(photo);
}
}
return mPhotoModel;
}
Aggregations