// LocationListener impl @Override public void onLocationChanged(Location location) { String topic = topic(location); if (!topic.equals(currentTopic)) { Log.d(LOG_TAG, "new grid location: " + topic); if (sendInfectionMessage(true)) { currentTopic = topic; subscribeToCurrentTopic(); } } int thisRegion = calcRegionCode(location); if (thisRegion != region || bioHazards.isEmpty()) { Log.d( LOG_TAG, "new region or no biohazards in region " + thisRegion + " - generating biohazards"); region = thisRegion; createBiohazards(location); EventBus.getDefault().post(new MapEvent(MapEvent.Type.REGION_UPDATED, region, bioHazards)); } for (Biohazard b : bioHazards) { if (b.getLocation().distanceTo(location) < BIOHAZARD_INFECTION_RADIUS) { Virus v = VirusFactory.fromBiohazard(b.getSeed(), b.getId()); if (gameDatabase.findVirus(v.getId()) == null) { Log.d(LOG_TAG, "infection by approaching biohazard " + b.getId()); gameDatabase.addVisitedBiohazard(b.getId()); addVirus(v); } } } }