コード例 #1
0
ファイル: MapsActivity.java プロジェクト: Gnafu/SIIGMobile
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);

    savedInstanceState.putBoolean(DB_LOADED_FLAG, dbLoaded);

    savedInstanceState.putString(FEATUREIDFIELD_FLAG, featureIdField);

    savedInstanceState.putBoolean(CANCONFRIM_FLAG, canConfirm);
    // MARKERS
    // get current markers
    overlayManager.saveInstanceState(savedInstanceState);
    for (MapControl mc : mapView.getControls()) {
      mc.saveState(savedInstanceState);
    }
  }
コード例 #2
0
ファイル: MapsActivity.java プロジェクト: Gnafu/SIIGMobile
  /**
   * 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);
    }
  }
コード例 #3
0
ファイル: MapsActivity.java プロジェクト: Gnafu/SIIGMobile
  /* (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);
    }
  }
コード例 #4
0
ファイル: MapsActivity.java プロジェクト: Gnafu/SIIGMobile
  /**
   * Add controls to the mapView and to the Buttons
   *
   * @param savedInstanceState
   */
  private void addControls(Bundle savedInstanceState) {
    String action = getIntent().getAction();
    Log.v("MapsActivity", "action: " + action);

    // Coordinate Control
    mapView.addControl(new CoordinateControl(mapView, true));
    List<MapControl> group = new ArrayList<MapControl>();

    // Info Control
    MapInfoControl ic;
    if (getIntent().hasExtra(PARAMETERS.CUSTOM_MAPINFO_CONTROL)) {
      ic = (MapInfoControl) getIntent().getParcelableExtra(PARAMETERS.CUSTOM_MAPINFO_CONTROL);
      ic.activity = this;
      ic.mapView = mapView;
      ic.instantiateListener();
    } else {
      ic = new MapInfoControl(mapView, this);
    }
    ic.setActivationButton((ImageButton) findViewById(R.id.ButtonInfo));

    mapView.addControl(ic);

    if (!Intent.ACTION_VIEW.equals(action)) {
      Log.v("MapsActivity", "Adding MarkerControl");

      // Marker Control
      MarkerControl mc = new MarkerControl(mapView);
      // activation button
      ImageButton mcbmb = (ImageButton) findViewById(R.id.ButtonMarker);
      mcbmb.setVisibility(View.VISIBLE);
      mc.setActivationButton(mcbmb);
      // info button  // TODO: do we need this button?
      ImageButton mcib = (ImageButton) findViewById(R.id.marker_info_button);
      mcib.setVisibility(View.VISIBLE);
      mc.setInfoButton(mcib);

      mapView.addControl(mc);
      group.add(mc);
      mc.setGroup(group);
      mc.setMode(MarkerControl.MODE_EDIT);
    }

    // My location Control
    LocationControl lc = new LocationControl(mapView);
    lc.setActivationButton((ImageButton) findViewById(R.id.ButtonLocation));
    mapView.addControl(lc);

    // create and add group
    group.add(ic);

    ic.setGroup(group);

    // TODO move this in a control

    // Set modes for controls
    if (Intent.ACTION_VIEW.equals(action)) {
      ic.setMode(MapInfoControl.MODE_VIEW);
    } else if (Intent.ACTION_EDIT.equals(action)) {
      ic.setMode(MapInfoControl.MODE_EDIT);
      // Default edit mode
    } else {
      ic.setMode(MapInfoControl.MODE_EDIT);
    }
    if (savedInstanceState != null) {
      for (MapControl c : mapView.getControls()) {
        c.restoreState(savedInstanceState);
      }
    }
  }