Search in sources :

Example 6 with PhotoEntity

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;
}
Also used : ReportCategory(com.ushahidi.android.app.entities.ReportCategory) PhotoEntity(com.ushahidi.android.app.entities.PhotoEntity) MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 7 with PhotoEntity

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;
}
Also used : PhotoEntity(com.ushahidi.android.app.entities.PhotoEntity) MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 8 with PhotoEntity

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;
}
Also used : PhotoEntity(com.ushahidi.android.app.entities.PhotoEntity) MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 9 with PhotoEntity

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;
}
Also used : PhotoEntity(com.ushahidi.android.app.entities.PhotoEntity)

Example 10 with PhotoEntity

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;
}
Also used : PhotoEntity(com.ushahidi.android.app.entities.PhotoEntity) MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Aggregations

PhotoEntity (com.ushahidi.android.app.entities.PhotoEntity)11 MediaEntity (com.ushahidi.android.app.entities.MediaEntity)6 File (java.io.File)3 ReportCategory (com.ushahidi.android.app.entities.ReportCategory)1 ReportEntity (com.ushahidi.android.app.entities.ReportEntity)1 ListPhotoModel (com.ushahidi.android.app.models.ListPhotoModel)1 Incident (com.ushahidi.java.sdk.api.Incident)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1