Search in sources :

Example 1 with ReportCategory

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

the class ReportCategoryDao method fetchReportCategoryByReportId.

@Override
public List<ReportCategory> fetchReportCategoryByReportId(int reportId, int status) {
    listReportCategories = new ArrayList<ReportCategory>();
    final String[] selectionArgs = { String.valueOf(reportId), String.valueOf(status) };
    final String selection = REPORT_ID + " =? AND " + STATUS + " =?";
    cursor = super.query(TABLE, COLUMNS, selection, selectionArgs, null);
    if (cursor != null) {
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            ReportCategory reportCategory = cursorToEntity(cursor);
            listReportCategories.add(reportCategory);
            cursor.moveToNext();
        }
        cursor.close();
    }
    return listReportCategories;
}
Also used : ReportCategory(com.ushahidi.android.app.entities.ReportCategory)

Example 2 with ReportCategory

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

the class ReportCategoryDao method fetchReportCategory.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ushahidi.android.app.database.IReportCategoryDao#fetchReportCategory
	 * (long)
	 */
@Override
public List<ReportCategory> fetchReportCategory(long id) {
    listReportCategories = new ArrayList<ReportCategory>();
    final String[] selectionArgs = { String.valueOf(id) };
    final String selection = ID + " =?";
    cursor = super.query(TABLE, COLUMNS, selection, selectionArgs, null);
    if (cursor != null) {
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            ReportCategory reportCategory = cursorToEntity(cursor);
            listReportCategories.add(reportCategory);
            cursor.moveToNext();
        }
        cursor.close();
    }
    return listReportCategories;
}
Also used : ReportCategory(com.ushahidi.android.app.entities.ReportCategory)

Example 3 with ReportCategory

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

the class AddReportActivity method setSavedReport.

/**
	 * Edit existing report
	 * 
	 * @author henryaddo
	 */
private void setSavedReport(int reportId) {
    // set text part of reports
    ReportEntity report = model.fetchPendingReportById(reportId);
    if (report != null) {
        view.mIncidentTitle.setText(report.getIncident().getTitle());
        view.mIncidentDesc.setText(report.getIncident().getDescription());
        view.mLongitude.setText(String.valueOf(report.getIncident().getLongitude()));
        view.mLatitude.setText(String.valueOf(report.getIncident().getLatitude()));
        view.mIncidentLocation.setText(report.getIncident().getLocationName());
        // set date and time
        setDateAndTime(report.getIncident().getDate());
    }
    // set Categories.
    mVectorCategories.clear();
    for (ReportCategory reportCategory : model.fetchReportCategories(reportId, IReportSchema.PENDING)) {
        mVectorCategories.add(reportCategory.getCategoryId());
    }
    setSelectedCategories(mVectorCategories);
    // set the photos
    pendingPhoto.refresh(id);
    // set news
    List<MediaEntity> newsMedia = model.fetchReportNews(reportId);
    if (newsMedia != null && newsMedia.size() > 0) {
        view.mNews.setText(newsMedia.get(0).getLink());
    }
    mIsReportEditable = mOgsDao.getReportState(id) != IOpenGeoSmsSchema.STATE_SENT;
    if (!mIsReportEditable) {
        View[] views = new View[] { view.mBtnAddCategory, view.mIncidentDesc, view.mIncidentLocation, view.mIncidentTitle, view.mLatitude, view.mLongitude, view.mPickDate, view.mPickTime };
        for (View v : views) {
            v.setEnabled(false);
        }
        updateMarker(report.getIncident().getLatitude(), report.getIncident().getLongitude(), true);
    }
}
Also used : ReportCategory(com.ushahidi.android.app.entities.ReportCategory) ReportEntity(com.ushahidi.android.app.entities.ReportEntity) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AddReportView(com.ushahidi.android.app.views.AddReportView) MediaEntity(com.ushahidi.android.app.entities.MediaEntity)

Example 4 with ReportCategory

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

the class ReportCategoryDao method cursorToEntity.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ushahidi.android.app.database.DbContentProvider#cursorToEntity(android
	 * .database.Cursor)
	 */
@SuppressWarnings("unchecked")
@Override
protected ReportCategory cursorToEntity(Cursor cursor) {
    ReportCategory reportCategory = new ReportCategory();
    int idIndex;
    int reportIdIndex;
    int categoryIdIndex;
    int statusIndex;
    if (cursor != null) {
        if (cursor.getColumnIndex(ID) != -1) {
            idIndex = cursor.getColumnIndexOrThrow(ID);
            reportCategory.setDbId(cursor.getInt(idIndex));
        }
        if (cursor.getColumnIndex(REPORT_ID) != -1) {
            reportIdIndex = cursor.getColumnIndexOrThrow(REPORT_ID);
            reportCategory.setReportId(cursor.getInt(reportIdIndex));
        }
        if (cursor.getColumnIndex(CATEGORY_ID) != -1) {
            categoryIdIndex = cursor.getColumnIndexOrThrow(CATEGORY_ID);
            reportCategory.setCategoryId(cursor.getInt(categoryIdIndex));
        }
        if (cursor.getColumnIndex(STATUS) != -1) {
            statusIndex = cursor.getColumnIndexOrThrow(STATUS);
            reportCategory.setStatus(cursor.getInt(statusIndex));
        }
    }
    return reportCategory;
}
Also used : ReportCategory(com.ushahidi.android.app.entities.ReportCategory)

Example 5 with ReportCategory

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

the class ReportCategoryDao method addReportCategories.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ushahidi.android.app.database.IReportCategoryDao#addReportCategories
	 * (java.util.List)
	 */
@Override
public boolean addReportCategories(List<ReportCategory> reportCategories) {
    try {
        mDb.beginTransaction();
        for (ReportCategory reportCategory : reportCategories) {
            addReportCategory(reportCategory);
        }
        mDb.setTransactionSuccessful();
    } finally {
        mDb.endTransaction();
    }
    return true;
}
Also used : ReportCategory(com.ushahidi.android.app.entities.ReportCategory)

Aggregations

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