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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations