Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Stash gradled work #189

Closed
wants to merge 1 commit into from

1 participant

@tmcw
Owner

No description provided.

@tmcw
Owner

Redone in 5d74b68

@tmcw tmcw closed this
@tmcw tmcw deleted the location-ui branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 20, 2014
  1. @tmcw

    Stash gradled work

    tmcw authored
This page is out of date. Refresh to see the latest.
View
186 src/main/java/com/mapbox/mapboxsdk/overlay/CoreLocationOverlay.java
@@ -1,186 +0,0 @@
-package com.mapbox.mapboxsdk.overlay;
-
-import com.mapbox.mapboxsdk.DefaultResourceProxyImpl;
-import com.mapbox.mapboxsdk.ResourceProxy;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.views.MapView;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.Point;
-import com.mapbox.mapboxsdk.views.util.Projection;
-
-public class CoreLocationOverlay extends Overlay {
- // ===========================================================
- // Constants
- // ===========================================================
- public static final int SIMPLE_OVERLAY_STYLE = 1;
- public static final int DIRECTION_OVERLAY_STYLE = 2;
-
- // ===========================================================
- // Fields
- // ===========================================================
-
- private int overlayStyle = DIRECTION_OVERLAY_STYLE;
-
- protected final Paint mPaint = new Paint();
- protected final Paint mAccuracyPaint = new Paint();
-
- protected Bitmap DIRECTION_ARROW;
-
- protected LatLng mLocation;
- protected float mBearing;
-
- private final Matrix directionRotater = new Matrix();
- private final Point screenCoords = new Point();
-
- private float DIRECTION_ARROW_CENTER_X;
- private float DIRECTION_ARROW_CENTER_Y;
- private int DIRECTION_ARROW_WIDTH;
- private int DIRECTION_ARROW_HEIGHT;
-
- private int mAccuracy = 0;
- private boolean mShowAccuracy = true;
-
-
- protected Bitmap PERSON_ICON;
- /**
- * Coordinates the feet of the person are located.
- */
- protected final android.graphics.Point PERSON_HOTSPOT = new android.graphics.Point(24, 39);
-
-
- // ===========================================================
- // Constructors
- // ===========================================================
-
- public CoreLocationOverlay(final Context ctx, int overlayStyle) {
- this(ctx, new DefaultResourceProxyImpl(ctx), overlayStyle);
- }
-
- public CoreLocationOverlay(final Context ctx, final ResourceProxy pResourceProxy, int overlayStyle) {
- super(pResourceProxy);
-
- this.overlayStyle = overlayStyle;
-
- switch (this.overlayStyle)
- {
- case SIMPLE_OVERLAY_STYLE:
- this.PERSON_ICON = mResourceProxy.getBitmap(ResourceProxy.bitmap.person);
- break;
- default:
- // Default Style is DIRECTION_OVERLAY_STYLE
- this.DIRECTION_ARROW = mResourceProxy.getBitmap(ResourceProxy.bitmap.direction_arrow);
-
- this.DIRECTION_ARROW_CENTER_X = this.DIRECTION_ARROW.getWidth() / 2 - 0.5f;
- this.DIRECTION_ARROW_CENTER_Y = this.DIRECTION_ARROW.getHeight() / 2 - 0.5f;
- this.DIRECTION_ARROW_HEIGHT = this.DIRECTION_ARROW.getHeight();
- this.DIRECTION_ARROW_WIDTH = this.DIRECTION_ARROW.getWidth();
- this.mAccuracyPaint.setStrokeWidth(2);
- this.mAccuracyPaint.setColor(Color.BLUE);
- this.mAccuracyPaint.setAntiAlias(true);
- break;
- }
- }
-
- // ===========================================================
- // Getter & Setter
- // ===========================================================
-
- public void setShowAccuracy(final boolean pShowIt) {
- this.mShowAccuracy = pShowIt;
- }
-
- public void setLocation(final LatLng mp) {
- this.mLocation = mp;
- }
-
- public LatLng getLocation() {
- return this.mLocation;
- }
-
- /**
- * @param pAccuracy in Meters
- */
- public void setAccuracy(final int pAccuracy) {
- this.mAccuracy = pAccuracy;
- }
-
- public void setBearing(final float aHeading) {
- this.mBearing = aHeading;
- }
-
- // ===========================================================
- // Methods from SuperClass/Interfaces
- // ===========================================================
-
- @Override
- public void draw(final Canvas c, final MapView osmv, final boolean shadow) {
-
- switch (this.overlayStyle)
- {
- case SIMPLE_OVERLAY_STYLE:
- if (!shadow && this.mLocation != null) {
- final Projection pj = osmv.getProjection();
- pj.toMapPixels(this.mLocation, screenCoords);
- c.drawBitmap(PERSON_ICON, screenCoords.x - PERSON_HOTSPOT.x, screenCoords.y - PERSON_HOTSPOT.y, this.mPaint);
- }
- break;
- default:
- if (shadow)
- {
- return;
- }
-
- if (this.mLocation != null)
- {
- final Projection pj = osmv.getProjection();
- pj.toMapPixels(this.mLocation, screenCoords);
-
- if (this.mShowAccuracy && this.mAccuracy > 10)
- {
- final float accuracyRadius = pj.metersToEquatorPixels(this.mAccuracy);
- /* Only draw if the DirectionArrow doesn't cover it. */
- if (accuracyRadius > 8)
- {
- /* Draw the inner shadow. */
- this.mAccuracyPaint.setAntiAlias(false);
- this.mAccuracyPaint.setAlpha(30);
- this.mAccuracyPaint.setStyle(Style.FILL);
- c.drawCircle(screenCoords.x, screenCoords.y, accuracyRadius,
- this.mAccuracyPaint);
-
- /* Draw the edge. */
- this.mAccuracyPaint.setAntiAlias(true);
- this.mAccuracyPaint.setAlpha(150);
- this.mAccuracyPaint.setStyle(Style.STROKE);
- c.drawCircle(screenCoords.x, screenCoords.y, accuracyRadius,
- this.mAccuracyPaint);
- }
- }
-
- /*
- * Rotate the direction-Arrow according to the bearing we are driving. And draw it to the canvas.
- */
- this.directionRotater.setRotate(this.mBearing, DIRECTION_ARROW_CENTER_X, DIRECTION_ARROW_CENTER_Y);
- final Bitmap rotatedDirection = Bitmap.createBitmap(DIRECTION_ARROW, 0, 0,
- DIRECTION_ARROW_WIDTH, DIRECTION_ARROW_HEIGHT, this.directionRotater, false);
- c.drawBitmap(rotatedDirection, screenCoords.x - rotatedDirection.getWidth() / 2,
- screenCoords.y - rotatedDirection.getHeight() / 2, this.mPaint);
- }
- break;
- }
- }
-
- // ===========================================================
- // Methods
- // ===========================================================
-
- // ===========================================================
- // Inner and Anonymous Classes
- // ===========================================================
-}
View
19 ...lay/mylocation/GpsMyLocationProvider.java → ...boxsdk/overlay/GpsMyLocationProvider.java
@@ -1,4 +1,4 @@
-package com.mapbox.mapboxsdk.overlay.mylocation;
+package com.mapbox.mapboxsdk.overlay;
import com.mapbox.mapboxsdk.util.NetworkLocationIgnorer;
@@ -8,11 +8,11 @@
import android.location.LocationManager;
import android.os.Bundle;
-public class GpsMyLocationProvider implements IMyLocationProvider, LocationListener {
+public class GpsMyLocationProvider implements LocationListener {
private final LocationManager mLocationManager;
private Location mLocation;
- private IMyLocationConsumer mMyLocationConsumer;
+ private UserLocationOverlay mMyLocationConsumer;
private long mLocationUpdateMinTime = 0;
private float mLocationUpdateMinDistance = 0.0f;
private final NetworkLocationIgnorer mIgnorer = new NetworkLocationIgnorer();
@@ -21,10 +21,6 @@ public GpsMyLocationProvider(Context context) {
mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
}
- // ===========================================================
- // Getter & Setter
- // ===========================================================
-
public long getLocationUpdateMinTime() {
return mLocationUpdateMinTime;
}
@@ -65,8 +61,7 @@ public void setLocationUpdateMinDistance(final float meters) {
* distance by calling {@link setLocationUpdateMinTime(long)} and/or {@link
* setLocationUpdateMinDistance(float)} before calling this method.
*/
- @Override
- public boolean startLocationProvider(IMyLocationConsumer myLocationConsumer) {
+ public boolean startLocationProvider(UserLocationOverlay myLocationConsumer) {
mMyLocationConsumer = myLocationConsumer;
boolean result = false;
for (final String provider : mLocationManager.getProviders(true)) {
@@ -80,21 +75,15 @@ public boolean startLocationProvider(IMyLocationConsumer myLocationConsumer) {
return result;
}
- @Override
public void stopLocationProvider() {
mMyLocationConsumer = null;
mLocationManager.removeUpdates(this);
}
- @Override
public Location getLastKnownLocation() {
return mLocation;
}
- //
- // LocationListener
- //
-
@Override
public void onLocationChanged(final Location location) {
// ignore temporary non-gps fix
View
38 ...rlay/mylocation/MyLocationNewOverlay.java → ...apboxsdk/overlay/UserLocationOverlay.java
@@ -1,10 +1,11 @@
-package com.mapbox.mapboxsdk.overlay.mylocation;
+package com.mapbox.mapboxsdk.overlay;
import java.util.LinkedList;
import com.mapbox.mapboxsdk.DefaultResourceProxyImpl;
import com.mapbox.mapboxsdk.ResourceProxy;
import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.overlay.GpsMyLocationProvider;
import com.mapbox.mapboxsdk.tile.TileSystem;
import com.mapbox.mapboxsdk.views.MapView;
import com.mapbox.mapboxsdk.overlay.IOverlayMenuProvider;
@@ -33,7 +34,7 @@
* @author Marc Kurtz
* @author Manuel Stahl
*/
-public class MyLocationNewOverlay extends SafeDrawOverlay implements IMyLocationConsumer,
+public class UserLocationOverlay extends SafeDrawOverlay implements
IOverlayMenuProvider, Snappable {
// ===========================================================
@@ -53,7 +54,7 @@
protected final MapView mMapView;
private final MapController mMapController;
- public IMyLocationProvider mMyLocationProvider;
+ public GpsMyLocationProvider mMyLocationProvider;
private final LinkedList<Runnable> mRunOnFirstFix = new LinkedList<Runnable>();
private final Point mMapCoords = new Point();
@@ -85,17 +86,17 @@
// Constructors
// ===========================================================
- public MyLocationNewOverlay(Context context, MapView mapView) {
+ public UserLocationOverlay(Context context, MapView mapView) {
this(context, new GpsMyLocationProvider(context), mapView);
}
- public MyLocationNewOverlay(Context context, IMyLocationProvider myLocationProvider,
- MapView mapView) {
+ public UserLocationOverlay(Context context, GpsMyLocationProvider myLocationProvider,
+ MapView mapView) {
this(myLocationProvider, mapView, new DefaultResourceProxyImpl(context));
}
- public MyLocationNewOverlay(IMyLocationProvider myLocationProvider, MapView mapView,
- ResourceProxy resourceProxy) {
+ public UserLocationOverlay(GpsMyLocationProvider myLocationProvider, MapView mapView,
+ ResourceProxy resourceProxy) {
super(resourceProxy);
mMapView = mapView;
@@ -143,17 +144,14 @@ public boolean isDrawAccuracyEnabled() {
return mDrawAccuracyEnabled;
}
- public IMyLocationProvider getMyLocationProvider() {
+ public GpsMyLocationProvider getMyLocationProvider() {
return mMyLocationProvider;
}
- protected void setMyLocationProvider(IMyLocationProvider myLocationProvider) {
- if (myLocationProvider == null)
- throw new RuntimeException(
- "You must pass an IMyLocationProvider to setMyLocationProvider()");
-
- if (mMyLocationProvider != null)
+ protected void setMyLocationProvider(GpsMyLocationProvider myLocationProvider) {
+ if (mMyLocationProvider != null) {
mMyLocationProvider.stopLocationProvider();
+ }
mMyLocationProvider = myLocationProvider;
}
@@ -414,8 +412,7 @@ public boolean isFollowLocationEnabled() {
return mIsFollowing;
}
- @Override
- public void onLocationChanged(Location location, IMyLocationProvider source) {
+ public void onLocationChanged(Location location, GpsMyLocationProvider source) {
// If we had a previous location, let's get those bounds
Location oldLocation = mLocation;
if (oldLocation != null) {
@@ -461,7 +458,7 @@ public void run() {
mRunOnFirstFix.clear();
}
- public boolean enableMyLocation(IMyLocationProvider myLocationProvider) {
+ public boolean enableMyLocation(GpsMyLocationProvider myLocationProvider) {
this.setMyLocationProvider(myLocationProvider);
mIsLocationEnabled = false;
return enableMyLocation();
@@ -475,8 +472,9 @@ public boolean enableMyLocation(IMyLocationProvider myLocationProvider) {
* updates when in the background.
*/
public boolean enableMyLocation() {
- if (mIsLocationEnabled)
+ if (mIsLocationEnabled) {
mMyLocationProvider.stopLocationProvider();
+ }
boolean result = mMyLocationProvider.startLocationProvider(this);
mIsLocationEnabled = result;
@@ -536,5 +534,5 @@ public boolean runOnFirstFix(final Runnable runnable) {
}
}
- private static final String TAG = "MyLocationNewOverlay";
+ private static final String TAG = "UserLocationOverlay";
}
View
7 src/main/java/com/mapbox/mapboxsdk/overlay/mylocation/IMyLocationConsumer.java
@@ -1,7 +0,0 @@
-package com.mapbox.mapboxsdk.overlay.mylocation;
-
-import android.location.Location;
-
-public interface IMyLocationConsumer {
- void onLocationChanged(Location location, IMyLocationProvider source);
-}
View
11 src/main/java/com/mapbox/mapboxsdk/overlay/mylocation/IMyLocationProvider.java
@@ -1,11 +0,0 @@
-package com.mapbox.mapboxsdk.overlay.mylocation;
-
-import android.location.Location;
-
-public interface IMyLocationProvider {
- boolean startLocationProvider(IMyLocationConsumer myLocationConsumer);
-
- void stopLocationProvider();
-
- Location getLastKnownLocation();
-}
View
5 src/main/java/com/mapbox/mapboxsdk/tileprovider/modules/MapTileDownloader.java
@@ -53,7 +53,7 @@ public MapTileDownloader(final ITileSource pTileSource,
setTileSource(pTileSource);
File cacheDir = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
try {
- HttpResponseCache cache = new HttpResponseCache(cacheDir, 1024);
+ cache = new HttpResponseCache(cacheDir, 1024);
} catch(Exception e) {
}
@@ -138,9 +138,6 @@ public Drawable loadTile(final MapTileRequestState aState) throws CantContinueEx
}
try {
- // Log.d(TAG, "getting tile " + tile.getX() + ", " + tile.getY());
- // Log.d(TAG, "Downloading MapTile from url: " + url);
-
HttpURLConnection connection = client.open(new URL(url));
in = connection.getInputStream();
View
9 src/main/java/com/mapbox/mapboxsdk/util/GeometryMath.java
@@ -68,8 +68,9 @@ public static int getNextSquareNumberAbove(final float factor) {
int cur = 1;
int i = 1;
while (true) {
- if (cur > factor)
+ if (cur > factor) {
return out;
+ }
out = i;
cur *= 2;
@@ -78,11 +79,13 @@ public static int getNextSquareNumberAbove(final float factor) {
}
public static int mod(int number, final int modulus) {
- if (number > 0)
+ if (number > 0) {
return number % modulus;
+ }
- while (number < 0)
+ while (number < 0) {
number += modulus;
+ }
return number;
}
Something went wrong with that request. Please try again.