cleanup vtm-android

This commit is contained in:
Hannes Janetzek
2014-02-08 03:01:37 +01:00
parent 7bbb74b985
commit d836ffaad1
2 changed files with 5 additions and 77 deletions

View File

@@ -26,13 +26,12 @@ import android.content.SharedPreferences.Editor;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
/** /**
* MapActivity is the abstract base class which must be extended in order to use * MapActivity is the abstract base class which can be extended in order to use
* a {@link Map}. There are no abstract methods in this implementation which * a {@link MapView}. There are no abstract methods in this implementation which
* subclasses need to override and no API key or registration is required. * subclasses need to override and no API key or registration is required.
* <p> * <p>
* A subclass may create a MapView either via one of the MapView constructors or * A subclass may create a MapView either via one of the MapView constructors or
* by inflating an XML layout file. It is possible to use more than one MapView * by inflating an XML layout file.
* at the same time.
* <p> * <p>
* When the MapActivity is shut down, the current center position, zoom level * When the MapActivity is shut down, the current center position, zoom level
* and map file of the MapView are saved in a preferences file and restored in * and map file of the MapView are saved in a preferences file and restored in
@@ -77,8 +76,6 @@ public abstract class MapActivity extends FragmentActivity {
editor.putInt(KEY_LONGITUDE, geoPoint.longitudeE6); editor.putInt(KEY_LONGITUDE, geoPoint.longitudeE6);
editor.putFloat(KEY_MAP_SCALE, (float) mapPosition.scale); editor.putFloat(KEY_MAP_SCALE, (float) mapPosition.scale);
//editor.putString(KEY_THEME, mMap.getRenderTheme());
editor.commit(); editor.commit();
} }
@@ -116,22 +113,5 @@ public abstract class MapActivity extends FragmentActivity {
mMap.setMapPosition(mapPosition); mMap.setMapPosition(mapPosition);
} }
//String theme = sharedPreferences.getString(KEY_THEME,
// InternalRenderTheme.DEFAULT.name());
// if (theme.startsWith("/")) {
// try {
// map.setRenderTheme(theme);
// } catch (FileNotFoundException e) {
// map.setRenderTheme(InternalRenderTheme.DEFAULT);
// }
// } else {
// try {
// map.setRenderTheme(InternalRenderTheme.valueOf(theme));
// } catch (IllegalArgumentException e) {
// map.setRenderTheme(InternalRenderTheme.DEFAULT);
// }
// }
} }
} }

View File

@@ -49,15 +49,12 @@ public class MapView extends RelativeLayout {
System.loadLibrary("vtm-jni"); System.loadLibrary("vtm-jni");
} }
public static final boolean debugFrameTime = false;
public static final boolean testRegionZoom = false;
public boolean mRotationEnabled = false; public boolean mRotationEnabled = false;
public boolean mCompassEnabled = false; public boolean mCompassEnabled = false;
public boolean enablePagedFling = false; public boolean enablePagedFling = false;
private final Compass mCompass;
private final GestureDetector mGestureDetector; private final GestureDetector mGestureDetector;
final AndroidMotionEvent mMotionEvent;
private int mWidth; private int mWidth;
private int mHeight; private int mHeight;
@@ -109,11 +106,10 @@ public class MapView extends RelativeLayout {
if (context instanceof MapActivity) if (context instanceof MapActivity)
((MapActivity)context).registerMapView(this); ((MapActivity)context).registerMapView(this);
mCompass = new Compass(context, mMap);
mMap.clearMap(); mMap.clearMap();
mMap.updateMap(false); mMap.updateMap(false);
mMotionEvent = new AndroidMotionEvent();
mGestureDetector = new GestureDetector(context, new OnGestureListener() { mGestureDetector = new GestureDetector(context, new OnGestureListener() {
@Override @Override
public boolean onSingleTapUp(MotionEvent e) { public boolean onSingleTapUp(MotionEvent e) {
@@ -152,26 +148,16 @@ public class MapView extends RelativeLayout {
public void onStop() { public void onStop() {
log.debug("onStop"); log.debug("onStop");
//mMap.destroy();
} }
void onPause() { void onPause() {
mMap.pause(true); mMap.pause(true);
if (this.mCompassEnabled)
mCompass.disable();
} }
void onResume() { void onResume() {
if (this.mCompassEnabled)
mCompass.enable();
mMap.pause(false); mMap.pause(false);
} }
final AndroidMotionEvent mMotionEvent = new AndroidMotionEvent();
@Override @Override
public boolean onTouchEvent(android.view.MotionEvent motionEvent) { public boolean onTouchEvent(android.view.MotionEvent motionEvent) {
@@ -189,7 +175,6 @@ public class MapView extends RelativeLayout {
@Override @Override
protected void onSizeChanged(int width, int height, protected void onSizeChanged(int width, int height,
int oldWidth, int oldHeight) { int oldWidth, int oldHeight) {
log.debug("onSizeChanged: " + width + "x" + height);
super.onSizeChanged(width, height, oldWidth, oldHeight); super.onSizeChanged(width, height, oldWidth, oldHeight);
@@ -201,41 +186,4 @@ public class MapView extends RelativeLayout {
if (mInitialized) if (mInitialized)
mMap.getViewport().setViewport(width, height); mMap.getViewport().setViewport(width, height);
} }
public void enableRotation(boolean enable) {
mRotationEnabled = enable;
if (enable) {
enableCompass(false);
}
}
public void enableCompass(boolean enable) {
if (enable == mCompassEnabled)
return;
mCompassEnabled = enable;
if (enable)
enableRotation(false);
if (enable)
mCompass.enable();
else
mCompass.disable();
}
public boolean getCompassEnabled() {
return mCompassEnabled;
}
public boolean getRotationEnabled() {
return mRotationEnabled;
}
public void destroy() {
log.debug("TODO Auto-generated method stub");
}
} }