@Override
  protected void onCreate(Bundle savedInstanceState) {
    Global.debugMemory(mDebugPrefix, "onCreate");
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    if (Global.debugEnabled && (intent != null)) {
      Log.d(
          Global.LOG_CONTEXT, mDebugPrefix + "onCreate " + intent.toUri(Intent.URI_INTENT_SCHEME));
    }
    setContentView(R.layout.activity_gallery_filter);
    this.mFilterValue = new FilterValue();
    onCreateButtos();

    GalleryFilterParameter filter =
        (savedInstanceState == null)
            ? getFilter(this.getIntent())
            : GalleryFilterParameter.parse(
                savedInstanceState.getString(FILTER_VALUE, ""), new GalleryFilterParameter());

    if (filter != null) {
      mFilter = filter;
      toGui(mFilter);
      mFilterValue.showLatLon(filter.isNonGeoOnly());
    }

    bookmarkController = new BookmarkController(this);
  }
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    saveSettings(this);

    if ((savedInstanceState != null) && (this.mFilter != null)) {
      savedInstanceState.putString(STATE_Filter, this.mFilter.toString());
    }
  }
  /**
   * Call back from sub-activities.<br>
   * Process Change StartTime (longpress start), Select StopTime before stop (longpress stop) or
   * filter change for detailReport
   */
  @Override
  protected void onActivityResult(
      final int requestCode, final int resultCode, final Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    switch (requestCode) {
      case GalleryFilterActivity.resultID:
        onFilterChanged(GalleryFilterActivity.getFilter(intent));
        break;
    }
  }
  @Override
  protected void onDestroy() {
    Global.debugMemory(mDebugPrefix, "onDestroy start");
    super.onDestroy();

    if (dirInfos != null) {
      for (Integer id : dirInfos.keySet()) {
        DirInfo dir = dirInfos.get(id);
        if (dir.directoryRoot != null) {
          dir.directoryRoot.destroy();
        }
      }
      dirInfos = null;
    }

    System.gc();
    Global.debugMemory(mDebugPrefix, "onDestroy end");
    // RefWatcher refWatcher = AndroFotoFinderApp.getRefWatcher(this);
    // refWatcher.watch(this);
  }
 @Override
 protected void onResume() {
   Global.debugMemory(mDebugPrefix, "onResume");
   loadLastFilter();
   super.onResume();
 }
 @Override
 protected void onPause() {
   Global.debugMemory(mDebugPrefix, "onPause");
   saveLastFilter();
   super.onPause();
 }
 @Override
 public void onSaveInstanceState(Bundle savedInstanceState) {
   fromGui(mFilter);
   savedInstanceState.putString(FILTER_VALUE, mFilter.toString());
   super.onSaveInstanceState(savedInstanceState);
 }
 @Override
 protected void onDestroy() {
   saveSettings(this);
   super.onDestroy();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    Intent intent = this.getIntent();

    GeoPointDto geoPointFromIntent = getGeoPointDtoFromIntent(intent);
    // no geo: from intent: use last used value
    mSaveLastUsedGeoToSharedPrefs = (geoPointFromIntent == null);

    String lastGeoUri = sharedPref.getString(STATE_LAST_GEO, "geo:53,8?z=6");
    IGeoPointInfo lastGeo = mGeoUriParser.fromUri(lastGeoUri);
    if ((geoPointFromIntent != null) && (lastGeo != null)) {
      // apply default values if part is missing
      if (Double.isNaN(geoPointFromIntent.getLongitude()))
        geoPointFromIntent.setLongitude(lastGeo.getLongitude());
      if (Double.isNaN(geoPointFromIntent.getLatitude()))
        geoPointFromIntent.setLatitude(lastGeo.getLatitude());
      if (geoPointFromIntent.getZoomMin() == IGeoPointInfo.NO_ZOOM)
        geoPointFromIntent.setZoomMin(lastGeo.getZoomMin());
    }

    IGeoPointInfo initalZoom = (mSaveLastUsedGeoToSharedPrefs) ? lastGeo : geoPointFromIntent;

    String extraTitle = intent.getStringExtra(EXTRA_TITLE);
    if (extraTitle == null && (geoPointFromIntent == null)) {
      extraTitle = getString(R.string.app_map_title);
    }

    if (extraTitle == null) {
      this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    setContentView(R.layout.activity_map_geo_picker);

    if (extraTitle != null) {
      this.setTitle(extraTitle);
    } else {
      setNoTitle();
    }

    mMap = (PickerLocationMapFragment) getFragmentManager().findFragmentById(R.id.fragment_map);
    mMap.STATE_LAST_VIEWPORT = "ignore"; // do not use last viewport in settings

    GeoRectangle rectangle = null;
    int zoom = ZoomUtil.NO_ZOOM;
    if ((savedInstanceState == null) && (initalZoom != null)) {
      rectangle = new GeoRectangle();
      zoom = initalZoom.getZoomMin();
      rectangle.setLogituedMin(initalZoom.getLongitude()).setLatitudeMin(initalZoom.getLatitude());
      rectangle.setLogituedMax(initalZoom.getLongitude()).setLatitudeMax(initalZoom.getLatitude());
    } // else (savedInstanceState != null) restore after rotation. fragment takes care of restoring
    // map pos

    String selectedItemsString = intent.getStringExtra(EXTRA_SELECTED_ITEMS);
    SelectedItems selectedItems =
        (selectedItemsString != null) ? new SelectedItems().parse(selectedItemsString) : null;

    String filter = null;
    // for debugging: where does the filter come from
    String dbgFilter = null;
    if (intent != null) {
      filter = intent.getStringExtra(EXTRA_FILTER);
    }
    this.mSaveLastUsedFilterToSharedPrefs = (filter == null); // false if controlled via intent
    if (savedInstanceState != null) {
      filter = savedInstanceState.getString(STATE_Filter);
      if (filter != null) dbgFilter = "filter from savedInstanceState=" + filter;
    }

    if (this.mSaveLastUsedFilterToSharedPrefs) {
      filter = sharedPref.getString(STATE_Filter, null);
      if (filter != null) dbgFilter = "filter from sharedPref=" + filter;
    }

    this.mFilter = new GalleryFilterParameter();

    if (filter != null) {
      GalleryFilterParameter.parse(filter, this.mFilter);
    }

    if (Global.debugEnabled) {
      Log.i(Global.LOG_CONTEXT, debugPrefix + dbgFilter + " => " + this.mFilter);
    }

    mMap.defineNavigation(this.mFilter, geoPointFromIntent, rectangle, zoom, selectedItems);
  }