예제 #1
0
  /**
   * Resume the state of:
   *
   * <p>* tile cache * Controls
   */
  @Override
  protected void onResume() {
    super.onResume();
    loadPersistencePreferences();
    checkIfMapViewNeedsBackgroundUpdate();
    // Refresh control beacuse any changes can be changed
    for (MapControl mic : mapView.getControls()) {
      mic.refreshControl(
          GetFeatureInfoLayerListActivity.BBOX_REQUEST,
          GetFeatureInfoLayerListActivity.BBOX_REQUEST,
          null);
    }

    // Some debug
    Intent i = getIntent();
    if (i != null) {
      String a = i.getAction();
      Log.v("MapsActivity onResume", "Action:" + a);
    }
  }
예제 #2
0
  /* (non-Javadoc)
   * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
   */
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d(MapsActivity.class.getSimpleName(), "MapsActivity onActivityResult");

    if (requestCode == LayerSwitcherFragment.OPACITY_SETTIN_REQUEST_ID) {

      final int newValue =
          PreferenceManager.getDefaultSharedPreferences(getBaseContext())
              .getInt(MBTilesLayerOpacitySettingActivity.MBTILES_OPACITY_ID, 192);

      ArrayList<Layer> layers = layerManager.getLayers();

      for (Layer l : layers) {
        if (l instanceof MbTilesLayer) {
          l.setOpacity(newValue);
          layerManager.redrawLayer(l);
        }
      }

      // its not necessary to handle the other stuff
      return;
    }

    if (requestCode == GetFeatureInfoLayerListActivity.BBOX_REQUEST && resultCode == RESULT_OK) {
      // the response can contain a feature to use to replace the current marker
      // on the map
      manageMarkerSubstitutionAction(data);
    }

    // controls can be refreshed getting the result of an intent, in this case
    // each control knows which intent he sent with their requestCode/resultCode
    for (MapControl control : mapView.getControls()) {
      control.refreshControl(requestCode, resultCode, data);
    }
    // reload stores in the panel (we do it everyTime, maybe there is a better way
    SourcesFragment sf =
        (SourcesFragment) getSupportFragmentManager().findFragmentById(R.id.right_drawer);
    if (sf != null) {
      sf.reloadStores();
    }
    // manager mapstore configuration load
    // TODO: with the new interface this will load a map instead of the mapstoreconfig
    if (data == null) return;
    Bundle b = data.getExtras();
    if (requestCode == DATAPROPERTIES_REQUEST_CODE) {
      mapView.getOverlayController().redrawOverlays();
      // close right drawer
      if (mLayerMenu != null) {
        if (mDrawerLayout.isDrawerOpen(mLayerMenu)) {
          mDrawerLayout.closeDrawer(mLayerMenu);
        }
      }
    }
    Resource resource =
        (Resource) data.getSerializableExtra(GeoStoreResourceDetailActivity.PARAMS.RESOURCE);
    if (resource != null) {
      String geoStoreUrl = data.getStringExtra(GeoStoreResourcesActivity.PARAMS.GEOSTORE_URL);
      loadGeoStoreResource(resource, geoStoreUrl);
    }
    if (b.containsKey(MAPSTORE_CONFIG)) {
      overlayManager.loadMapStoreConfig((MapStoreConfiguration) b.getSerializable(MAPSTORE_CONFIG));
    }
    if (b.containsKey(MSM_MAP)) {
      layerManager.loadMap((MSMMap) b.getSerializable(MSM_MAP));
    }
    ArrayList<Layer> layersToAdd = (ArrayList<Layer>) b.getSerializable(LAYERS_TO_ADD);
    if (layersToAdd != null) {
      addLayers(layersToAdd);
    }
  }