use of im.tny.segvault.disturbances.ui.widget.POIView in project underlx by underlx.
the class StationPOIFragment method update.
private void update() {
if (mListener == null)
return;
MainService service = mListener.getMainService();
if (service == null)
return;
Network net = service.getNetwork(networkId);
if (net == null)
return;
final Station station = net.getStation(stationId);
if (station == null)
return;
Locale l = Util.getCurrentLocale(getContext());
final String lang = l.getLanguage();
// POIs
pois = station.getPOIs();
Collections.sort(pois, new Comparator<POI>() {
@Override
public int compare(POI o1, POI o2) {
return o1.getNames(lang)[0].compareTo(o2.getNames(lang)[0]);
}
});
for (POI poi : pois) {
POIView v = new POIView(getContext(), poi);
v.setInteractionListener(new POIView.OnViewInteractionListener() {
@Override
public void onPOIClicked(POI poi) {
if (googleMap == null || !mapLayoutReady) {
return;
}
Marker marker = markers.get(poi);
if (marker != null) {
marker.showInfoWindow();
}
poiScrollView.fullScroll(NestedScrollView.FOCUS_UP);
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.fromLatLngZoom(marker.getPosition(), googleMap.getCameraPosition().zoom)));
}
});
poisLayout.addView(v);
}
// Lobbies
final int[] lobbyColors = Util.lobbyColors.clone();
if (station.getLobbies().size() == 1) {
lobbyColors[0] = Color.BLACK;
}
final ViewTreeObserver vto = mapView.getViewTreeObserver();
if (vto.isAlive()) {
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
mapLayoutReady = true;
trySetupMap(station, pois, lobbyColors, lang);
// remove the listener... or we'll be doing this a lot.
ViewTreeObserver obs = mapView.getViewTreeObserver();
obs.removeGlobalOnLayoutListener(this);
}
});
}
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap mMap) {
googleMap = mMap;
trySetupMap(station, pois, lobbyColors, lang);
}
});
}
Aggregations