@Override public View getView(int position, View convertView, ViewGroup parent) { View view = null; if (convertView == null) { LayoutInflater inflator = context.getLayoutInflater(); view = inflator.inflate(R.layout.marklist, null); final ViewHolder viewHolder = new ViewHolder(); viewHolder.name = (TextView) view.findViewById(R.id.name); viewHolder.created = (TextView) view.findViewById(R.id.createdAt); viewHolder.lat = (TextView) view.findViewById(R.id.lati); viewHolder.lon = (TextView) view.findViewById(R.id.longi); viewHolder.label = (TextView) view.findViewById(R.id.label); view.setTag(viewHolder); } else { view = convertView; } ViewHolder holder = (ViewHolder) view.getTag(); holder.name.setText(list.get(position).getName()); holder.created.setText(list.get(position).getCreated().toString()); holder.lat.setText( Location.convert(list.get(position).getLat() * 0.000001, Location.FORMAT_SECONDS)); holder.lon.setText( Location.convert(list.get(position).getLon() * 0.000001, Location.FORMAT_SECONDS)); holder.label.setText(list.get(position).getLabel()); return view; }
public static String convertLocation(double latitude, double longitude) { StringBuffer strBuffer = new StringBuffer(); strBuffer .append("lat: ") .append(Location.convert(latitude, Location.FORMAT_MINUTES)) .append(" lon: ") .append(Location.convert(longitude, Location.FORMAT_MINUTES)); return strBuffer.toString(); }
@Override void receivedSensorDataBundle(SensorDataBundleWrapper bundle) { Location location = bundle.getLocation(); if (location == null) { mLatView.setText(R.string.common_na); mLonView.setText(R.string.common_na); } else { String lat_val[], lon_val[]; lat_val = Location.convert(location.getLatitude(), Location.FORMAT_SECONDS).split(":", 0); lon_val = Location.convert(location.getLongitude(), Location.FORMAT_SECONDS).split(":", 0); mLatView.setText( lat_val[0] + "º" + lat_val[1] + "'" + lat_val[2].substring(0, lat_val[2].indexOf('.')) + "\""); mLonView.setText( lon_val[0] + "º" + lon_val[1] + "'" + lon_val[2].substring(0, lon_val[2].indexOf('.')) + "\""); } SensorDataParser parser = DeviceHandlerFactory.getInstance().getParser(bundle.getSensorName(), bundle.getSensorId()); for (SensorData data : parser.getSensorData(bundle.getSensorData(), filter)) { switch (data.getDataType()) { case CO2: updateBox(data, 0); break; case NOx: updateBox(data, 1); break; case COx: updateBox(data, 2); break; case Noise: updateBox(data, 3); break; case Humidity: mHumidityView.setText(data.getStrValue()); mHumidityUnitView.setText(data.getUnit()); break; case Temperature: mTemperatureView.setText(data.getStrValue()); mTemperatureUnitView.setText(data.getUnit()); break; } } }
/** Updates the map view with all zombies and humans */ public void run() { Log.d(ZomDroid.TAG, "Running VicinityTask"); UsersOverlay humanOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.humanmark)); UsersOverlay infectedOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.infectedmark)); UsersOverlay zombieOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.zombiemark)); UsersOverlay medicOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.medicmark)); UsersOverlay hospitalOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.hospitalmark)); for (Player player : GameEngine.getInstance().getPlayers()) { Double gpx = Double.valueOf(Location.convert(player.gpx, Location.FORMAT_DEGREES)) * 1E6; Double gpy = Double.valueOf(Location.convert(player.gpy, Location.FORMAT_DEGREES)) * 1E6; Log.d(ZomDroid.TAG, "gpx=" + gpx.intValue() + ", gpy=" + gpy.intValue()); OverlayItem item = new OverlayItem( new GeoPoint(gpx.intValue(), (gpy.intValue())), player.id, player.zhType); if (player.zhType.equals(GameEngine.HUMAN)) humanOverlay.addOverlay(item); else if (player.zhType.equals(GameEngine.INFECTED)) infectedOverlay.addOverlay(item); else if (player.zhType.equals(GameEngine.ZOMBIE)) zombieOverlay.addOverlay(item); else if (player.zhType.equals(GameEngine.MEDIC)) medicOverlay.addOverlay(item); else if (player.zhType.equals(GameEngine.HOSPITAL)) hospitalOverlay.addOverlay(item); if (GameEngine.getInstance().stateChanged) showAlert(); } synchronized (GameEngine.getInstance()) { List<Overlay> overlays = map.getOverlays(); overlays.clear(); if (humanOverlay.size() > 0) overlays.add(humanOverlay); if (infectedOverlay.size() > 0) overlays.add(infectedOverlay); if (zombieOverlay.size() > 0) overlays.add(zombieOverlay); if (medicOverlay.size() > 0) overlays.add(medicOverlay); map.postInvalidate(); } }
// conversion to simple coordinate public String locationStringFromLocation(final Location location) { return Location.convert(location.getLatitude(), Location.FORMAT_DEGREES) + " " + Location.convert(location.getLongitude(), Location.FORMAT_DEGREES); }