Search in sources :

Example 6 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 7 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)

Example 8 with ReportCategory

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

the class ReportsApi method saveCategories.

/**
     * Save details of categories to the database
     * 
     * @param categoryId The ID of the category
     * @param reportId The ID of the report
     * @return void
     */
private void saveCategories(int categoryId, int reportId) {
    ReportCategory reportCategory = new ReportCategory();
    reportCategory.setCategoryId(categoryId);
    reportCategory.setReportId(reportId);
    reportCategory.setStatus(IReportSchema.FETCHED);
    List<ReportCategory> reportCategories = new ArrayList<ReportCategory>();
    reportCategories.add(reportCategory);
    // save new data
    Database.mReportCategoryDao.addReportCategories(reportCategories);
}
Also used : ReportCategory(com.ushahidi.android.app.entities.ReportCategory) ArrayList(java.util.ArrayList)

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