/** Delete any existing photo in the pending folder */ private void deleteExistingPhoto() { File[] pendingPhotos = PhotoUtils.getPendingPhotos(this); if (pendingPhotos != null && pendingPhotos.length > 0) { for (File file : pendingPhotos) { if (file.exists()) { file.delete(); } } } }
/** * Post to local database * * @author henryaddo */ private boolean addReport() { log("Adding new reports"); File[] pendingPhotos = PhotoUtils.getPendingPhotos(this); Report report = new Report(); report.setTitle(view.mIncidentTitle.getText().toString()); report.setDescription(view.mIncidentDesc.getText().toString()); report.setLatitude(view.mLatitude.getText().toString()); report.setLongitude(view.mLongitude.getText().toString()); report.setLocationName(view.mIncidentLocation.getText().toString()); report.setReportDate(mDateToSubmit); report.setMode(String.valueOf(0)); report.setVerified(String.valueOf(0)); 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 exisiting report List<Photo> photos = new ArrayList<Photo>(); 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; }
/** 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; Photo photo = new Photo(); photo.setDbId(id); photo.setPhoto("pending/" + file.getName()); pendingPhoto.addItem(photo); } } } }