use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class AddCheckinModel method updatePendingCheckin.
public boolean updatePendingCheckin(int checkinId, Checkin checkin, List<PhotoEntity> pendingPhotos) {
boolean status;
// update pending reports
status = Database.mCheckin.updatePendingCheckin(checkinId, checkin);
// update photos
if (pendingPhotos != null && pendingPhotos.size() > 0) {
// delete existing photo
Database.mMediaDao.deleteReportPhoto(checkinId);
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.setCheckinId(checkinId);
media.setType(IMediaSchema.IMAGE);
Database.mMediaDao.addMedia(media);
}
}
return status;
}
use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class ListPhotoModel method getPendingPhotos.
public List<PhotoEntity> getPendingPhotos(Context context) {
mPhotoModel = new ArrayList<PhotoEntity>();
File[] pendingPhotos = PhotoUtils.getPendingPhotos(context);
if (pendingPhotos != null && pendingPhotos.length > 0) {
int id = 0;
for (File file : pendingPhotos) {
if (file.exists()) {
id += 1;
PhotoEntity photo = new PhotoEntity();
photo.setDbId(id);
photo.setPhoto(PENDING + file.getName());
mPhotoModel.add(photo);
}
}
}
return mPhotoModel;
}
use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class AddReportActivity method addPhotoToReport.
/**
* Set photo to be attached to an existing report
*/
private void addPhotoToReport() {
File[] pendingPhotos = PhotoUtils.getPendingPhotos(this);
if (pendingPhotos != null && pendingPhotos.length > 0) {
int id = 0;
for (File file : pendingPhotos) {
if (file.exists()) {
id += 1;
PhotoEntity photo = new PhotoEntity();
photo.setDbId(id);
photo.setPhoto(file.getName());
pendingPhoto.addItem(photo);
}
}
}
}
use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class AddReportActivity method addReport.
/**
* Post to local database
*
* @author henryaddo
*/
private boolean addReport() {
log("Adding new reports");
File[] pendingPhotos = PhotoUtils.getPendingPhotos(this);
ReportEntity report = new ReportEntity();
Incident incident = new Incident();
incident.setTitle(view.mIncidentTitle.getText().toString());
incident.setDescription(view.mIncidentDesc.getText().toString());
incident.setMode(0);
incident.setLocationName(view.mIncidentLocation.getText().toString());
incident.setVerified(0);
incident.setLatitude(Double.valueOf(view.mLatitude.getText().toString()));
incident.setLongitude(Double.valueOf(view.mLongitude.getText().toString()));
if (date != null) {
incident.setDate(date);
} else {
incident.setDate(new Date());
}
report.setIncident(incident);
report.setPending(1);
if (id == 0) {
// Add a new pending report
if (model.addPendingReport(report, mVectorCategories, pendingPhotos, view.mNews.getText().toString())) {
// move saved photos
log("Moving photos to fetched folder");
ImageManager.movePendingPhotos(this);
id = report.getDbId();
} else {
return false;
}
} else {
// Update existing report
List<PhotoEntity> photos = new ArrayList<PhotoEntity>();
for (int i = 0; i < pendingPhoto.getCount(); i++) {
photos.add(pendingPhoto.getItem(i));
}
if (model.updatePendingReport(id, report, mVectorCategories, photos, view.mNews.getText().toString())) {
// move saved photos
log("Moving photos to fetched folder");
ImageManager.movePendingPhotos(this);
} else {
return false;
}
}
if (mSendOpenGeoSms) {
mOgsDao.addReport(id);
} else {
mOgsDao.deleteReport(id);
}
return true;
}
use of com.ushahidi.android.app.entities.PhotoEntity in project Ushahidi_Android by ushahidi.
the class ViewReportView method setListPhotos.
public void setListPhotos(int reportId) {
if (photo != null) {
ListPhotoModel mListPhotoModel = new ListPhotoModel();
final boolean loaded = mListPhotoModel.load(reportId);
int totalPhotos = mListPhotoModel.totalReportPhoto();
if (loaded) {
final List<PhotoEntity> items = mListPhotoModel.getPhotos();
if (items.size() > 0) {
getPhoto(items.get(0).getPhoto(), photo);
total.setText(context.getResources().getQuantityString(R.plurals.no_of_images, totalPhotos, totalPhotos));
} else {
photo.setVisibility(View.GONE);
total.setVisibility(View.GONE);
listPhotosEmptyView.setVisibility(View.VISIBLE);
}
}
}
}
Aggregations