Search in sources :

Example 1 with MediaEntity

use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.

the class ReportsApi method saveMedia.

/**
     * Save fetched media to the database
     * 
     * @param mediaId The ID of the media
     * @param reportId The report ID associated with the media
     * @param type The media type. 1 for image, 2 for news link, 3 for video
     *            link
     * @param link The URL of the media
     * @return void
     */
private void saveMedia(int mediaId, int reportId, int type, String link) {
    log("downloading... " + link + " ReportId: " + reportId);
    MediaEntity media = new MediaEntity();
    media.setMediaId(mediaId);
    media.setReportId(reportId);
    media.setType(type);
    media.setLink(link);
    List<MediaEntity> sMedia = new ArrayList<MediaEntity>();
    sMedia.add(media);
    // save new data
    Database.mMediaDao.addMedia(sMedia);
}
Also used : ArrayList(java.util.ArrayList) MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 2 with MediaEntity

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

Example 3 with MediaEntity

use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.

the class AddCheckinModel method addPendingCheckin.

public boolean addPendingCheckin(Checkin checkin, File[] pendingPhotos) {
    boolean status;
    // add pending reports
    status = Database.mCheckin.addCheckin(checkin);
    // int id = Database.mCheckin.
    int id = Database.mCheckin.fetchPendingCheckinIdByDate(checkin.getDate());
    // add photos
    if (pendingPhotos != null && pendingPhotos.length > 0) {
        for (File file : pendingPhotos) {
            if (file.exists()) {
                MediaEntity media = new MediaEntity();
                media.setMediaId(0);
                media.setLink(file.getName());
                // get report ID;
                media.setCheckinId(id);
                media.setType(IMediaSchema.IMAGE);
                Database.mMediaDao.addMedia(media);
            }
        }
    }
    return status;
}
Also used : File(java.io.File) MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 4 with MediaEntity

use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.

the class ListReportNewsModel method getNewsByReportId.

public List<ListReportNewsModel> getNewsByReportId(int reportId) {
    mNewsModel = new ArrayList<ListReportNewsModel>();
    mMedia = Database.mMediaDao.fetchReportNews(reportId);
    if (mMedia != null && mMedia.size() > 0) {
        for (MediaEntity item : mMedia) {
            ListReportNewsModel newsModel = new ListReportNewsModel();
            newsModel.setId(item.getDbId());
            newsModel.setTitle(item.getLink());
            newsModel.setUrl(item.getLink());
            mNewsModel.add(newsModel);
        }
    }
    return mNewsModel;
}
Also used : MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 5 with MediaEntity

use of com.ushahidi.android.app.entities.MediaEntity in project Ushahidi_Android by ushahidi.

the class MediaDao method fetchReportNews.

@Override
public List<MediaEntity> fetchReportNews(int reportId) {
    listMedia = new ArrayList<MediaEntity>();
    final String selection = REPORT_ID + " = " + reportId + " AND " + TYPE + " =" + NEWS;
    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;
}
Also used : MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Aggregations

MediaEntity (com.ushahidi.android.app.entities.MediaEntity)22 PhotoEntity (com.ushahidi.android.app.entities.PhotoEntity)6 ReportCategory (com.ushahidi.android.app.entities.ReportCategory)3 File (java.io.File)2 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 ReportEntity (com.ushahidi.android.app.entities.ReportEntity)1 AddReportView (com.ushahidi.android.app.views.AddReportView)1 ArrayList (java.util.ArrayList)1