Search in sources :

Example 11 with ReportEntity

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

the class MapFragment method getReportLatLng.

private LatLng getReportLatLng() {
    if (mReportModel != null) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (ReportEntity reportEntity : mReportModel) {
            double latitude = 0.0;
            double longitude = 0.0;
            try {
                latitude = Double.valueOf(reportEntity.getIncident().getLatitude());
            } catch (NumberFormatException e) {
                latitude = 0.0;
            }
            try {
                longitude = Double.valueOf(reportEntity.getIncident().getLongitude());
            } catch (NumberFormatException e) {
                longitude = 0.0;
            }
            builder.include(new LatLng(latitude, longitude));
        }
        return Util.getCenter(builder.build());
    }
    return null;
}
Also used : LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) LatLng(com.google.android.gms.maps.model.LatLng) ReportEntity(com.ushahidi.android.app.entities.ReportEntity)

Example 12 with ReportEntity

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

the class ReportDao method fetchPendingReportByCategory.

@Override
public List<ReportEntity> fetchPendingReportByCategory(String category) {
    final String sortOrder = INCIDENT_TITLE + " DESC";
    final String[] selectionArgs = { category, String.valueOf(1) };
    final String selection = INCIDENT_CATEGORIES + " LIKE ? AND " + INCIDENT_PENDING + " =? ";
    listReport = new ArrayList<ReportEntity>();
    cursor = super.query(INCIDENTS_TABLE, null, selection, selectionArgs, sortOrder);
    if (cursor != null) {
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            ReportEntity report = cursorToEntity(cursor);
            listReport.add(report);
            cursor.moveToNext();
        }
        cursor.close();
    }
    return listReport;
}
Also used : ReportEntity(com.ushahidi.android.app.entities.ReportEntity)

Example 13 with ReportEntity

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

the class ReportDao method fetchReportByCategory.

@Override
public List<ReportEntity> fetchReportByCategory(String category) {
    final String sortOrder = INCIDENT_TITLE + " DESC";
    final String[] selectionArgs = { category };
    final String selection = INCIDENT_CATEGORIES + " LIKE ?";
    listReport = new ArrayList<ReportEntity>();
    cursor = super.query(INCIDENTS_TABLE, null, selection, selectionArgs, sortOrder);
    if (cursor != null) {
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            ReportEntity report = cursorToEntity(cursor);
            listReport.add(report);
            cursor.moveToNext();
        }
        cursor.close();
    }
    return listReport;
}
Also used : ReportEntity(com.ushahidi.android.app.entities.ReportEntity)

Example 14 with ReportEntity

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

the class ReportDao method addReport.

@Override
public boolean addReport(List<ReportEntity> reports) {
    try {
        mDb.beginTransaction();
        for (ReportEntity report : reports) {
            addReport(report);
        }
        mDb.setTransactionSuccessful();
    } finally {
        mDb.endTransaction();
    }
    return true;
}
Also used : ReportEntity(com.ushahidi.android.app.entities.ReportEntity)

Example 15 with ReportEntity

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

the class ReportDao method fetchReportByCategoryId.

@Override
public List<ReportEntity> fetchReportByCategoryId(int categoryId) {
    final String sortOrder = INCIDENT_TITLE + " DESC";
    final String sql = "SELECT * FROM " + INCIDENTS_TABLE + " reports INNER JOIN " + IReportCategorySchema.TABLE + " cats ON reports." + INCIDENT_ID + " = cats." + IReportCategorySchema.REPORT_ID + " WHERE cats." + IReportCategorySchema.CATEGORY_ID + " =? AND " + "cats." + IReportCategorySchema.STATUS + " =?  AND cats." + INCIDENT_PENDING + "=? ORDER BY  " + sortOrder;
    final String[] selectionArgs = { String.valueOf(categoryId), String.valueOf(IReportSchema.FETCHED), String.valueOf(IReportSchema.FETCHED) };
    listReport = new ArrayList<ReportEntity>();
    cursor = super.rawQuery(sql, selectionArgs);
    if (cursor != null) {
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            ReportEntity report = cursorToEntity(cursor);
            listReport.add(report);
            cursor.moveToNext();
        }
        cursor.close();
    }
    return listReport;
}
Also used : ReportEntity(com.ushahidi.android.app.entities.ReportEntity)

Aggregations

ReportEntity (com.ushahidi.android.app.entities.ReportEntity)18 Incident (com.ushahidi.java.sdk.api.Incident)3 ReportCategory (com.ushahidi.android.app.entities.ReportCategory)2 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 LatLng (com.google.android.gms.maps.model.LatLng)1 LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 UploadPhotoAdapter (com.ushahidi.android.app.adapters.UploadPhotoAdapter)1 ReportsApi (com.ushahidi.android.app.api.ReportsApi)1 MediaEntity (com.ushahidi.android.app.entities.MediaEntity)1 PhotoEntity (com.ushahidi.android.app.entities.PhotoEntity)1 AddReportView (com.ushahidi.android.app.views.AddReportView)1 UshahidiException (com.ushahidi.java.sdk.UshahidiException)1 Category (com.ushahidi.java.sdk.api.Category)1 Incidents (com.ushahidi.java.sdk.api.Incidents)1 Person (com.ushahidi.java.sdk.api.Person)1