Refactored and updated omst variables to final
UserOverlay base is now BaseUserOverlay MapFragmentBase is now BaseMapFragment Change-Id: Icbe234964f9b8ad511f17f6d22bca1a677d4189b Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.RectF;
|
||||
import android.util.Log;
|
||||
|
||||
import com.TwentyCodes.android.debug.Debug;
|
||||
@@ -31,7 +32,7 @@ import com.google.android.maps.Projection;
|
||||
* This class will be used to build user overlays
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public abstract class UserOverlayBase extends Overlay implements GeoPointLocationListener, CompassListener {
|
||||
public abstract class BaseUserOverlay extends Overlay implements GeoPointLocationListener, CompassListener {
|
||||
|
||||
/**
|
||||
* This thread is responsible for animating the user icon
|
||||
@@ -126,7 +127,7 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
|
||||
* @param context
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public UserOverlayBase(MapView mapView, Context context) {
|
||||
public BaseUserOverlay(MapView mapView, Context context) {
|
||||
super();
|
||||
mContext = context;
|
||||
mMapView = mapView;
|
||||
@@ -141,7 +142,7 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
|
||||
* @param followUser
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public UserOverlayBase(MapView mapView, Context context, boolean followUser) {
|
||||
public BaseUserOverlay(MapView mapView, Context context, boolean followUser) {
|
||||
this(mapView, context);
|
||||
isFollowingUser = followUser;
|
||||
}
|
||||
@@ -192,7 +193,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
|
||||
/*
|
||||
* the following log is used to demonstrate if the leftGeo point is the correct
|
||||
*/
|
||||
// Log.d(TAG, (GeoUtils.distanceKm(mPoint, leftGeo) * 1000)+"m");
|
||||
if(Debug.DEBUG)
|
||||
Log.d(TAG, (GeoUtils.distanceKm(mPoint, leftGeo) * 1000)+"m");
|
||||
}
|
||||
super.draw(canvas, mapView, shadow);
|
||||
}
|
||||
@@ -234,9 +236,11 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
|
||||
* for testing
|
||||
* draw a dot over the left geopoint
|
||||
*/
|
||||
// paint.setColor(Color.RED);
|
||||
// RectF oval = new RectF(left.x - 1, left.y - 1, left.x + 1, left.y + 1);
|
||||
// canvas.drawOval(oval, paint);
|
||||
if(Debug.DEBUG){
|
||||
paint.setColor(Color.RED);
|
||||
RectF oval = new RectF(left.x - 1, left.y - 1, left.x + 1, left.y + 1);
|
||||
canvas.drawOval(oval, paint);
|
||||
}
|
||||
|
||||
return canvas;
|
||||
}
|
||||
@@ -286,7 +290,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void enableMyLocation(){
|
||||
Log.d(TAG,"enableMyLocation()");
|
||||
if(Debug.DEBUG)
|
||||
Log.d(TAG,"enableMyLocation()");
|
||||
if (! isEnabled) {
|
||||
|
||||
mAnimationThread = new AnimationThread();
|
||||
@@ -307,7 +312,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public void followUser(boolean followUser){
|
||||
Log.d(TAG,"followUser()");
|
||||
if(Debug.DEBUG)
|
||||
Log.d(TAG,"followUser()");
|
||||
isFollowingUser = followUser;
|
||||
}
|
||||
|
||||
@@ -339,8 +345,6 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
|
||||
|
||||
@Override
|
||||
public void onCompassUpdate(float bearing) {
|
||||
if(Debug.DEBUG)
|
||||
Log.v(TAG, "onCompassUpdate()");
|
||||
if(mCompassListener != null)
|
||||
mCompassListener.onCompassUpdate(bearing);
|
||||
mBearing = bearing;
|
||||
@@ -467,7 +471,6 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
|
||||
* @author Ricky Barrette
|
||||
*/
|
||||
public void unRegisterListener(){
|
||||
Log.d(TAG,"unRegisterListener()");
|
||||
mListener = null;
|
||||
}
|
||||
}
|
||||
@@ -30,11 +30,11 @@ import com.google.android.maps.Overlay;
|
||||
public class CompasOverlay extends Overlay implements CompassListener {
|
||||
|
||||
private float mBearing;
|
||||
private Context mContext;
|
||||
private final Context mContext;
|
||||
private GeoPoint mDestination;
|
||||
private GeoPoint mLocation;
|
||||
private boolean isEnabled;
|
||||
private CompassSensor mCompassSensor;
|
||||
private final CompassSensor mCompassSensor;
|
||||
private int mNeedleResId = R.drawable.needle_sm;
|
||||
private int mBackgroundResId = R.drawable.compass_sm;
|
||||
private int mX;
|
||||
@@ -121,7 +121,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
|
||||
public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
|
||||
|
||||
if(isEnabled){
|
||||
//set the center of the compass in the top left corner of the screen
|
||||
|
||||
@@ -41,8 +41,8 @@ public class DirectionsOverlay {
|
||||
private static final String TAG = "DirectionsOverlay";
|
||||
private ArrayList<PathOverlay> mPath;
|
||||
private ArrayList<String> mDirections;
|
||||
private MapView mMapView;
|
||||
private OnDirectionsCompleteListener mListener;
|
||||
private final MapView mMapView;
|
||||
private final OnDirectionsCompleteListener mListener;
|
||||
private String mCopyRights;
|
||||
private ArrayList<GeoPoint> mPoints;
|
||||
private ArrayList<String> mDistance;
|
||||
@@ -59,7 +59,7 @@ public class DirectionsOverlay {
|
||||
* @throws IllegalStateException
|
||||
* @throws JSONException
|
||||
*/
|
||||
public DirectionsOverlay(MapView map, GeoPoint origin, GeoPoint destination, OnDirectionsCompleteListener listener) throws IllegalStateException, ClientProtocolException, IOException, JSONException {
|
||||
public DirectionsOverlay(final MapView map, final GeoPoint origin, final GeoPoint destination, final OnDirectionsCompleteListener listener) throws IllegalStateException, ClientProtocolException, IOException, JSONException {
|
||||
mMapView = map;
|
||||
mListener = listener;
|
||||
String json = downloadJSON(generateUrl(origin, destination));
|
||||
@@ -72,7 +72,7 @@ public class DirectionsOverlay {
|
||||
* @throws JSONException
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public DirectionsOverlay(MapView map, String json, OnDirectionsCompleteListener listener) throws JSONException{
|
||||
public DirectionsOverlay(final MapView map, final String json, final OnDirectionsCompleteListener listener) throws JSONException{
|
||||
mListener = listener;
|
||||
mMapView = map;
|
||||
drawPath(json);
|
||||
@@ -86,7 +86,7 @@ public class DirectionsOverlay {
|
||||
* @author ricky barrette
|
||||
* @throws JSONException
|
||||
*/
|
||||
private void decodePoly(JSONObject step) throws JSONException {
|
||||
private void decodePoly(final JSONObject step) throws JSONException {
|
||||
if(Debug.DEBUG)
|
||||
Log.d(TAG, "decodePoly");
|
||||
|
||||
@@ -143,7 +143,7 @@ public class DirectionsOverlay {
|
||||
* @throws IOException
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private String downloadJSON(String url) throws IllegalStateException, ClientProtocolException, IOException {
|
||||
private String downloadJSON(final String url) throws IllegalStateException, ClientProtocolException, IOException {
|
||||
if(Debug.DEBUG)
|
||||
Log.d(TAG, url);
|
||||
if(url == null)
|
||||
@@ -164,7 +164,7 @@ public class DirectionsOverlay {
|
||||
* @return
|
||||
* @throws JSONException
|
||||
*/
|
||||
public void drawPath(String json) throws JSONException{
|
||||
public void drawPath(final String json) throws JSONException{
|
||||
if(Debug.DEBUG){
|
||||
Log.d(TAG, "drawPath");
|
||||
Log.d(TAG, json);
|
||||
@@ -245,7 +245,7 @@ public class DirectionsOverlay {
|
||||
* @return The Google API url for our directions
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private String generateUrl(GeoPoint origin, GeoPoint destination){
|
||||
private String generateUrl(final GeoPoint origin, final GeoPoint destination){
|
||||
return "http://maps.googleapis.com/maps/api/directions/json?&origin="+
|
||||
Double.toString(origin.getLatitudeE6() / 1.0E6)+
|
||||
","+
|
||||
@@ -279,7 +279,7 @@ public class DirectionsOverlay {
|
||||
* @throws JSONException
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private String getDistance(JSONObject step) throws JSONException{
|
||||
private String getDistance(final JSONObject step) throws JSONException{
|
||||
return step.getJSONObject("distance").getString("text");
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ public class DirectionsOverlay {
|
||||
* @throws JSONException
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private String getDuration(JSONObject step) throws JSONException{
|
||||
private String getDuration(final JSONObject step) throws JSONException{
|
||||
return step.getJSONObject("duration").getString("text");
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ public class DirectionsOverlay {
|
||||
* @throws JSONException
|
||||
* @author ricky barrette
|
||||
*/
|
||||
private GeoPoint getGeoPoint(JSONObject point) throws JSONException{
|
||||
private GeoPoint getGeoPoint(final JSONObject point) throws JSONException{
|
||||
return new GeoPoint((int) (point.getDouble("lat")*1E6), (int) (point.getDouble("lng")*1E6));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class PathOverlay extends Overlay {
|
||||
* Creates a new PathOverlay in path mode
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public PathOverlay(GeoPoint start, GeoPoint end, int color) {
|
||||
public PathOverlay(final GeoPoint start, final GeoPoint end, final int color) {
|
||||
mStart = start;
|
||||
mEnd = end;
|
||||
mColor = color;
|
||||
@@ -49,7 +49,7 @@ public final class PathOverlay extends Overlay {
|
||||
* @param color
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public PathOverlay(GeoPoint point, int radius, int color){
|
||||
public PathOverlay(final GeoPoint point, final int radius, final int color){
|
||||
mMode = POINT;
|
||||
mRadius = radius;
|
||||
mStart = point;
|
||||
@@ -66,8 +66,8 @@ public final class PathOverlay extends Overlay {
|
||||
*/
|
||||
@Override
|
||||
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
|
||||
Projection projection = mapView.getProjection();
|
||||
Paint paint = new Paint();
|
||||
final Projection projection = mapView.getProjection();
|
||||
final Paint paint = new Paint();
|
||||
paint.setColor(mColor);
|
||||
paint.setAntiAlias(true);
|
||||
Point point = new Point();
|
||||
|
||||
@@ -62,12 +62,12 @@ public class RadiusOverlay extends Overlay{
|
||||
* @param when
|
||||
*/
|
||||
@Override
|
||||
public void draw(Canvas canvas, MapView mapView, boolean shadow){
|
||||
public void draw(final Canvas canvas, final MapView mapView, final boolean shadow){
|
||||
if(mPoint != null){
|
||||
Paint paint = new Paint();
|
||||
Point center = new Point();
|
||||
Point left = new Point();
|
||||
Projection projection = mapView.getProjection();
|
||||
final Paint paint = new Paint();
|
||||
final Point center = new Point();
|
||||
final Point left = new Point();
|
||||
final Projection projection = mapView.getProjection();
|
||||
|
||||
/*
|
||||
* Calculate a geopoint that is "radius" meters away from geopoint point and
|
||||
|
||||
@@ -14,9 +14,9 @@ import com.google.android.maps.MapView;
|
||||
* this class will be used to display the users location on the map using skyhook's call back methods
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class SkyHookUserOverlay extends UserOverlayBase{
|
||||
public class SkyHookUserOverlay extends BaseUserOverlay{
|
||||
|
||||
private SkyHook mSkyHook;
|
||||
private final SkyHook mSkyHook;
|
||||
|
||||
public SkyHookUserOverlay(MapView mapView, Context context) {
|
||||
super(mapView, context);
|
||||
@@ -38,7 +38,7 @@ public class SkyHookUserOverlay extends UserOverlayBase{
|
||||
/**
|
||||
* Called when the location provider needs to be disabled
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.overlays.UserOverlayBase#onMyLocationDisabled()
|
||||
* @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationDisabled()
|
||||
*/
|
||||
@Override
|
||||
public void onMyLocationDisabled() {
|
||||
@@ -48,7 +48,7 @@ public class SkyHookUserOverlay extends UserOverlayBase{
|
||||
/**
|
||||
* Called when the location provider needs to be enabled
|
||||
* (non-Javadoc)
|
||||
* @see com.TwentyCodes.android.overlays.UserOverlayBase#onMyLocationEnabled()
|
||||
* @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationEnabled()
|
||||
*/
|
||||
@Override
|
||||
public void onMyLocationEnabled() {
|
||||
|
||||
@@ -14,9 +14,9 @@ import com.google.android.maps.MapView;
|
||||
* This is the standard version of the UserOverlay.
|
||||
* @author ricky barrette
|
||||
*/
|
||||
public class UserOverlay extends UserOverlayBase{
|
||||
public class UserOverlay extends BaseUserOverlay{
|
||||
|
||||
private AndroidGPS mAndroidGPS;
|
||||
private final AndroidGPS mAndroidGPS;
|
||||
|
||||
public UserOverlay(MapView mapView, Context context) {
|
||||
super(mapView, context);
|
||||
|
||||
Reference in New Issue
Block a user