Exemplo n.º 1
0
  private void showObservationCallout(com.google.android.gms.maps.model.Marker marker) {
    final Marker item = mMarkersAdapter.getItem(marker);
    Bundle args = new Bundle();
    args.putString("uid", item.uid);
    getLoaderManager()
        .restartLoader(
            LOADER_OBSERVATION,
            args,
            new LoaderManager.LoaderCallbacks<Observation>() {

              @Override
              public Loader<Observation> onCreateLoader(int id, Bundle args) {
                return new ObservationLoader(getActivity(), args.getString("uid"));
              }

              @Override
              public void onLoadFinished(Loader<Observation> loader, Observation data) {
                if (data != null) {
                  com.google.android.gms.maps.model.Marker marker = mMarkersAdapter.getMarker(item);
                  if (marker != null) {
                    mMarkersAdapter.getItem(marker).observation = data;
                    if (marker.isInfoWindowShown()) marker.showInfoWindow();
                  }
                }
              }

              @Override
              public void onLoaderReset(Loader<Observation> loader) {}
            });
    marker.showInfoWindow();
    mInfoWindowMarker = marker;
    AnalyticsHelper.trackUiEvent("callout", null);
  }
Exemplo n.º 2
0
 @Override
 public void onInfoWindowClick(com.google.android.gms.maps.model.Marker marker) {
   Marker item = mMarkersAdapter.getItem(marker);
   if (item.observation != null) {
     // TODO
     if (!(item.observation instanceof WezzooObservation)) return;
     startActivity(ObservationActivity.newIntent(getActivity(), item.observation, false));
   }
 }
Exemplo n.º 3
0
 private void setFeatureMode(FeatureMode featureMode) {
   if (featureMode != mFeatureMode) {
     mFeatureMode = featureMode;
     mWeatherModeBtn.setSelected(mFeatureMode == FeatureMode.WEATHER);
     mTemperatureModeBtn.setSelected(mFeatureMode == FeatureMode.TEMPERATURE);
     mMarkersAdapter.setFeatureMode(mFeatureMode);
     reloadMap();
   }
 }
Exemplo n.º 4
0
 @Override
 public void onLoadFinished(Loader<ObservationsMap> loader, ObservationsMap data) {
   if (data != null) {
     mMarkersAdapter.setMarkers(data.markers);
     HomeFragment homeFragment = getHomeFragment();
     if (data.centerConditions != null && homeFragment != null) {
       homeFragment.setWeatherConditionsBar(data.centerConditions);
     }
   }
 }
Exemplo n.º 5
0
 @Override
 public void onMapReady(GoogleMap googleMap) {
   mGoogleMap = googleMap;
   mMarkersAdapter = new MarkersAdapter(getActivity(), googleMap);
   mMarkersAdapter.setFeatureMode(mFeatureMode);
   mMarkersAdapter.setFullInfoWindowEnabled(true);
   UiSettings settings = googleMap.getUiSettings();
   settings.setMyLocationButtonEnabled(true);
   settings.setCompassEnabled(true);
   settings.setAllGesturesEnabled(mMapGestureEnabled);
   settings.setMapToolbarEnabled(false);
   googleMap.setOnCameraChangeListener(this);
   googleMap.setOnMarkerClickListener(this);
   googleMap.setInfoWindowAdapter(mMarkersAdapter);
   googleMap.setOnInfoWindowClickListener(this);
   googleMap.setPadding(0, mToolbar.getHeight(), 0, mMapBottomPadding);
   getLoaderManager().initLoader(LOADER_MAP, null, mMapCallback);
   if (mMapLocation != null) {
     googleMap.moveCamera(
         CameraUpdateFactory.newLatLngZoom(
             new LatLng(mMapLocation.getLatitude(), mMapLocation.getLongitude()), DEFAULT_ZOOM));
     mMapLocation = null;
   }
 }