private void setMarkersOptions(Location loc) { boolean visible = true; if (markersOnMap == null) { markersOnMap = new ArrayList<Marker>(); } for (Task task : TaskList.getInstance(getApplicationContext()).getTasks()) { LatLng temp = getLatLngIfPossible(task.getLocation()); if (temp != null) { Location tloc = new Location(task.getLocation()); tloc.setLatitude(temp.latitude); tloc.setLongitude(temp.longitude); float dist = tloc.distanceTo(loc); Marker tempMarker = map.addMarker( new MarkerOptions() .position(temp) .visible(visible) .title(String.valueOf(task.getTask_id())) .icon(BitmapDescriptorFactory.fromResource(R.drawable.marke_65px))); if (dist > sbRadOuter.getProgress() * 100) { tempMarker.setVisible(false); } markersOnMap.add(tempMarker); } } }
@Override public void updateTask(Task task) { SQLiteDatabase db = null; try { db = DBHelper.getReadableDatabase(); ContentValues taskValues = new ContentValues(); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_NAME, task.getName()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_DATE, task.convertDateString()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_TIME, task.convertTimeString()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_CATEGORY, task.getCategory()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_PRIORITY, task.getPriority()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_LOCATION, task.getLocation()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_STATUS, task.getStatus()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_ASSIGNEE, task.getAssignee()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_FIREBASE_ID, task.getFirebaseId()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_PICTURE, task.getPicture()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_ACCEPT_STATUS, task.getAcceptStatus()); taskValues.put( TasKingDBNames.TaskEntry.COLUMN_TASK_TIME_STAMP, new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(new Date())); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_MANAGER_ID, task.getManagerUid()); taskValues.put(TasKingDBNames.TaskEntry.COLUMN_TASK_ASSIGNEE_ID, task.getAssigneeUid()); db.update( TasKingDBNames.TaskEntry.TABLE_NAME, taskValues, TasKingDBNames.TaskEntry.COLUMN_TASK_FIREBASE_ID + "=?", new String[] {task.getFirebaseId()}); } finally { if (db != null) { db.close(); } } }
@Override public View getInfoWindow(Marker marker) { long task_id; try { task_id = Long.parseLong(marker.getTitle()); } catch (Exception e) { task_id = -1; } if (task_id != -1) { LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View windowview = inflater.inflate(R.layout.task_window, null); Task task = TaskList.getInstance(getApplicationContext()) .getTaskById(Long.parseLong(marker.getTitle())); ((TextView) windowview.findViewById(R.id.tvTitleWin)).setText(task.getTitle()); ((TextView) windowview.findViewById(R.id.tvDescriptionWin)).setText(task.getDesc()); ((TextView) windowview.findViewById(R.id.tvLocationWin)).setText(task.getLocation()); ((TextView) windowview.findViewById(R.id.tvFromToWin)).setText(task.getFromTo()); String status = (task.isChecked() == 1) ? "Done" : "Not Done"; ((TextView) windowview.findViewById(R.id.tvStatusWin)).setText(status); return windowview; } else { return null; } }