/** Called when the activity is first created. */ @Override public void onCreate(final Bundle savedInstanceState) { Log.d(Constants.DEBUGTAG, "OnCREATE"); super.onCreate(savedInstanceState); applyZoomButtonListeners(); applyQuickButtonListeners(); applyMapViewLongPressListener(); /* Check if this is the first start, or a configuration-change. */ if (savedInstanceState == null) { final GeoPoint location = super.getLastKnownLocation(true); if (location == null || Math.abs(location.getLatitudeE6()) <= 100 || Math.abs(location.getLongitudeE6()) <= 100) { this.mOSMapView.getController().setZoom(3); } else { this.mOSMapView.getController().setZoom(13); this.mOSMapView.getController().setCenter(location); } /* Init the First bug-query a bit delayed, until the mapview offers a correct bounding-box. */ new Handler() .postDelayed( new Runnable() { public void run() { refreshVisibleBugs(); } }, 1000); if (Preferences.getShowOSBInstructions(this)) { showDialog(DIALOG_SHOW_INSTRUCTIONS); } } }
@Override protected void onRestoreInstanceState(final Bundle in) { final ArrayList<OSMMapViewOSBOverlayItem> items = in.getParcelableArrayList(STATE_BUGOVERLAYITEMS_ID); this.mBugOverlayItems.addAll(items); this.mBugOverlayItemsIndex = in.getInt(STATE_BUGOVERLAYITEMS_SELECTED_ID); super.mOSMapView.getController().setZoom(in.getInt(STATE_ZOOMLEVEL_ID)); final GeoPoint mapCenter = in.getParcelable(STATE_MAPCENTER_ID); if (mapCenter != null) { super.mOSMapView.getController().setCenter(mapCenter); } this.mAddOSMPOIType = in.getParcelable(STATE_ADDOSMPOITYPE_ID); super.mOSMapView.invalidate(); }
@Override public void onLocationChanged(final AndNavLocation pLocation) { if (this.mMyLocationOverlay != null) { this.mMyLocationOverlay.setLocation(getLastKnownLocation(true)); } if (super.mOSMapView != null) { super.mOSMapView.invalidate(); } }
@Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { switch (requestCode) { case REQUESTCODE_POICATEGORYSELECTOR: this.mAddOSMPOIType = POIType.values()[resultCode]; showDialog(DIALOG_INPUT_OSM_POI); break; } super.onActivityResult(requestCode, resultCode, data); }
@Override protected void onPrepareDialog(final int id, final Dialog d) { Log.d(DEBUGTAG, "Preparing dialog: " + id); super.onPrepareDialog(id, d); switch (id) { case DIALOG_INPUT_EDIT_BUG: CommonDialogFactory.prepareEditOSBBugDialog( this, d, OSBMap.this.mBugOverlayItems.get(OSBMap.this.mBugOverlayItemsIndex).getBug()); break; case DIALOG_INPUT_OSM_POI: CommonDialogFactory.prepareInputOSMPOIDialog(this, d, this.mAddOSMPOIType); break; } }
@Override protected void onSetupContentView() { this.setContentView(R.layout.osbmap); super.mOSMapView = (MapView) findViewById(R.id.map_osbmap); this.mIbtnCommentWrite = (ImageButton) this.findViewById(R.id.ibtn_osbmap_comment_write); this.mIbtnRefresh = (ImageButton) this.findViewById(R.id.ibtn_osbmap_refresh); this.mIbtnAdd = (ImageButton) this.findViewById(R.id.ibtn_osbmap_add); this.mIbtnAddCancel = (ImageButton) this.findViewById(R.id.ibtn_osbmap_add_cancel); this.mScaleIndicatorView = new ScaleBarOverlay(this); if (Preferences.getUnitSystem(this) == UnitSystem.IMPERIAL) { this.mScaleIndicatorView.setImperial(); } else { this.mScaleIndicatorView.setMetric(); } this.mScaleIndicatorView.setScaleBarOffset( getResources().getDisplayMetrics().widthPixels / 2 - getResources().getDisplayMetrics().xdpi / 2, 10); this.mIbtnCommentWrite.setEnabled(false); final OverlayManager overlaymanager = this.mOSMapView.getOverlayManager(); this.mOSBOverlay = new OSMMapViewOSBOverlay(this, this.mBugOverlayItems, this); this.mOSBOverlay.setFocusItemsOnTap(false); overlaymanager.add(this.mScaleIndicatorView); overlaymanager.add(this.mMyLocationOverlay = new SimpleLocationOverlay(this)); overlaymanager.add(this.mOSBOverlay); /* Add AddBugOverlay after OSBOverlay to give it a higher zOrder. */ overlaymanager.add( this.mAddBugCrosshairOverlay = new OSMMapViewCrosshairOverlay(this, Color.BLACK, 2, 17)); this.mAddBugCrosshairOverlay.setEnabled(false); super.mOSMapView.invalidate(); }