vtm-android: dont force MapView to use MapActivity context
This commit is contained in:
parent
35d7d2c0b5
commit
350f6394fd
@ -1 +1 @@
|
||||
Subproject commit 6093f28947a9188f58c6a362d196920dfd5d02c8
|
||||
Subproject commit 2173ae1f3f4349c44908a8be97d93fdce6734094
|
@ -28,7 +28,7 @@ import android.view.Menu;
|
||||
|
||||
public class BaseMapActivity extends MapActivity {
|
||||
|
||||
private final static boolean USE_CACHE = false;
|
||||
private final static boolean USE_CACHE = true;
|
||||
|
||||
MapView mMapView;
|
||||
VectorTileLayer mBaseLayer;
|
||||
@ -42,6 +42,7 @@ public class BaseMapActivity extends MapActivity {
|
||||
setContentView(R.layout.activity_map);
|
||||
|
||||
mMapView = (MapView) findViewById(R.id.mapView);
|
||||
registerMapView(mMapView);
|
||||
|
||||
mTileSource = new OSciMap4TileSource();
|
||||
mTileSource.setOption("url", "http://opensciencemap.org/tiles/vtm");
|
||||
|
@ -43,6 +43,7 @@ public class MarkerOverlayActivity extends MapActivity implements OnItemGestureL
|
||||
setContentView(R.layout.activity_map);
|
||||
|
||||
mMapView = (MapView) findViewById(R.id.mapView);
|
||||
registerMapView(mMapView);
|
||||
|
||||
MarkerSymbol symbol = AndroidGraphics.makeMarker(getResources(),
|
||||
R.drawable.marker_poi,
|
||||
|
@ -37,6 +37,7 @@ public class PathOverlayActivity extends MapActivity {
|
||||
setContentView(R.layout.activity_map);
|
||||
|
||||
mMapView = (MapView) findViewById(R.id.mapView);
|
||||
registerMapView(mMapView);
|
||||
|
||||
for (double lon = -180; lon < 180; lon += 5) {
|
||||
List<GeoPoint> pts = new ArrayList<GeoPoint>();
|
||||
|
@ -50,9 +50,9 @@ public class Compass {
|
||||
private final SensorManager mSensorManager;
|
||||
private final Sensor mSensor;
|
||||
|
||||
public Compass(MapActivity mapActivity, Map map) {
|
||||
public Compass(Context context, Map map) {
|
||||
mMap = map;
|
||||
mSensorManager = (SensorManager) mapActivity
|
||||
mSensorManager = (SensorManager) context
|
||||
.getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
|
||||
|
@ -45,8 +45,6 @@ public abstract class MapActivity extends Activity {
|
||||
|
||||
private static final String PREFERENCES_FILE = "MapActivity";
|
||||
|
||||
//private static final String KEY_THEME = "Theme";
|
||||
|
||||
private static boolean containsViewport(SharedPreferences sharedPreferences) {
|
||||
return sharedPreferences.contains(KEY_LATITUDE)
|
||||
&& sharedPreferences.contains(KEY_LONGITUDE)
|
||||
@ -100,8 +98,8 @@ public abstract class MapActivity extends Activity {
|
||||
* @param map
|
||||
* the calling MapView.
|
||||
*/
|
||||
public final void registerMapView(Map map) {
|
||||
mMap = map;
|
||||
public final void registerMapView(MapView map) {
|
||||
mMap = map.getMap();
|
||||
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE,
|
||||
MODE_PRIVATE);
|
||||
|
@ -35,7 +35,6 @@ import android.util.DisplayMetrics;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.OnGestureListener;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
/**
|
||||
@ -91,9 +90,6 @@ public class MapView extends RelativeLayout {
|
||||
public MapView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
|
||||
if (!(context instanceof MapActivity))
|
||||
throw new IllegalArgumentException("context is not an instance of MapActivity");
|
||||
|
||||
CanvasAdapter.g = AndroidGraphics.INSTANCE;
|
||||
AssetAdapter.g = new AndroidAssetAdapter(context);
|
||||
GLAdapter.g = new AndroidGL();
|
||||
@ -108,13 +104,8 @@ public class MapView extends RelativeLayout {
|
||||
// TODO make this dpi dependent
|
||||
Tile.SIZE = 400;
|
||||
|
||||
MapActivity mapActivity = (MapActivity) context;
|
||||
|
||||
mMap = new AndroidMap(this);
|
||||
|
||||
mCompass = new Compass(mapActivity, mMap);
|
||||
|
||||
mapActivity.registerMapView(mMap);
|
||||
mCompass = new Compass(context, mMap);
|
||||
|
||||
mMap.clearMap();
|
||||
mMap.updateMap(false);
|
||||
@ -122,9 +113,7 @@ public class MapView extends RelativeLayout {
|
||||
mGestureDetector = new GestureDetector(context, new OnGestureListener() {
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
boolean handled = mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
|
||||
mMotionEvent.wrap(null);
|
||||
return handled;
|
||||
return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -139,7 +128,6 @@ public class MapView extends RelativeLayout {
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
mMap.handleGesture(Gesture.LONG_PRESS, mMotionEvent.wrap(e));
|
||||
mMotionEvent.wrap(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -149,34 +137,9 @@ public class MapView extends RelativeLayout {
|
||||
|
||||
@Override
|
||||
public boolean onDown(MotionEvent e) {
|
||||
boolean handled = mMap.handleGesture(Gesture.PRESS, mMotionEvent.wrap(e));
|
||||
mMotionEvent.wrap(null);
|
||||
return handled;
|
||||
return mMap.handleGesture(Gesture.PRESS, mMotionEvent.wrap(e));
|
||||
}
|
||||
});
|
||||
|
||||
//mGestureDetector.setOnDoubleTapListener(new OnDoubleTapListener() {
|
||||
//
|
||||
// @Override
|
||||
// public boolean onSingleTapConfirmed(MotionEvent e) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onDoubleTapEvent(MotionEvent e) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean onDoubleTap(MotionEvent e) {
|
||||
// return false;
|
||||
// }
|
||||
//});
|
||||
|
||||
}
|
||||
|
||||
View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map getMap() {
|
||||
@ -220,7 +183,6 @@ public class MapView extends RelativeLayout {
|
||||
return true;
|
||||
}
|
||||
|
||||
// synchronized ???
|
||||
@Override
|
||||
protected void onSizeChanged(int width, int height,
|
||||
int oldWidth, int oldHeight) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user