public SitesOverlay(Drawable marker) { super(marker); this.marker = marker; for (IncidentsData incidentData : mNewIncidents) { IncidentMap.latitude = Double.parseDouble(incidentData.getIncidentLocLatitude()); IncidentMap.longitude = Double.parseDouble(incidentData.getIncidentLocLongitude()); items.add( new OverlayItem( getPoint(latitude, longitude), incidentData.getIncidentTitle(), incidentData.getIncidentDesc())); } populate(); }
// get incidents from the db public List<IncidentsData> showIncidents(String by) { Cursor cursor; if (by.equals("All")) cursor = UshahidiApplication.mDb.fetchAllIncidents(); else cursor = UshahidiApplication.mDb.fetchIncidentsByCategories(by); String title; String date; String description; String location; String categories; String media; if (cursor.moveToFirst()) { int idIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_ID); int titleIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_TITLE); int dateIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_DATE); int verifiedIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_VERIFIED); int locationIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_LOC_NAME); int descIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_DESC); int categoryIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_CATEGORIES); int mediaIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_MEDIA); int latitudeIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_LOC_LATITUDE); int longitudeIndex = cursor.getColumnIndexOrThrow(UshahidiDatabase.INCIDENT_LOC_LONGITUDE); do { IncidentsData incidentData = new IncidentsData(); mOldIncidents.add(incidentData); int id = Util.toInt(cursor.getString(idIndex)); incidentData.setIncidentId(id); title = Util.capitalizeString(cursor.getString(titleIndex)); incidentData.setIncidentTitle(title); description = cursor.getString(descIndex); incidentData.setIncidentDesc(description); categories = cursor.getString(categoryIndex); incidentData.setIncidentCategories(categories); location = cursor.getString(locationIndex); incidentData.setIncidentLocLongitude(location); date = Util.joinString("Date: ", cursor.getString(dateIndex)); incidentData.setIncidentDate(cursor.getString(dateIndex)); media = cursor.getString(mediaIndex); incidentData.setIncidentMedia(media); incidentData.setIncidentVerified(Util.toInt(cursor.getString(verifiedIndex))); incidentData.setIncidentLocLatitude(cursor.getString(latitudeIndex)); incidentData.setIncidentLocLongitude(cursor.getString(longitudeIndex)); } while (cursor.moveToNext()); } cursor.close(); return mOldIncidents; }