From 1a811b01f02a9b982233f23fbaa293e44126cdff Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Tue, 23 Aug 2016 14:19:24 +0200 Subject: [PATCH] [android] #6109 - cleanup Hungarian notation sdk and test app, added some javadocs todo for public api on mapboxmap --- .../mapbox/mapboxsdk/annotations/Icon.java | 24 +- .../mapboxsdk/annotations/IconFactory.java | 56 +- .../mapboxsdk/annotations/InfoWindow.java | 86 +- .../annotations/InfoWindowTipView.java | 58 +- .../mapboxsdk/annotations/InfoWindowView.java | 6 +- .../mapboxsdk/geometry/LatLngBounds.java | 76 +- .../mapbox/mapboxsdk/geometry/LatLngSpan.java | 28 +- .../mapbox/mapboxsdk/http/HTTPRequest.java | 38 +- .../mapbox/mapboxsdk/maps/MapFragment.java | 22 +- .../com/mapbox/mapboxsdk/maps/MapView.java | 942 +++++++++--------- .../com/mapbox/mapboxsdk/maps/MapboxMap.java | 443 ++++---- .../mapbox/mapboxsdk/maps/NativeMapView.java | 191 ++-- .../com/mapbox/mapboxsdk/maps/Projection.java | 20 +- .../mapboxsdk/maps/SupportMapFragment.java | 22 +- .../mapboxsdk/maps/widgets/CompassView.java | 62 +- .../mapboxsdk/offline/OfflineManager.java | 16 +- .../mapboxsdk/offline/OfflineRegion.java | 14 +- .../annotation/AnimatedMarkerActivity.java | 24 +- .../annotation/BulkMarkerActivity.java | 46 +- .../annotation/MarkerViewActivity.java | 26 +- .../activity/annotation/PolylineActivity.java | 54 +- .../annotation/PressForMarkerActivity.java | 25 +- .../activity/camera/ManualZoomActivity.java | 20 +- .../directions/DirectionsActivity.java | 18 +- .../imagegenerator/PrintActivity.java | 18 +- .../maplayout/MapPaddingActivity.java | 20 +- .../SurfaceViewMediaControlActivity.java | 18 +- .../activity/offline/OfflineActivity.java | 52 +- .../MyLocationTrackingModeActivity.java | 69 +- 29 files changed, 1269 insertions(+), 1225 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java index fceeb527134..bcf3f1bd16c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java @@ -10,20 +10,20 @@ * @see Marker */ public class Icon { - private Bitmap mBitmap; - private String mId; + private Bitmap bitmap; + private String id; Icon(String id, Bitmap bitmap) { - mId = id; - mBitmap = bitmap; + this.id = id; + this.bitmap = bitmap; } public String getId() { - return mId; + return id; } public Bitmap getBitmap() { - return mBitmap; + return bitmap; } @Override @@ -33,19 +33,19 @@ public boolean equals(Object o) { Icon icon = (Icon) o; - if (!mBitmap.equals(icon.mBitmap)) return false; - return mId.equals(icon.mId); + if (!bitmap.equals(icon.bitmap)) return false; + return id.equals(icon.id); } @Override public int hashCode() { int result = 0; - if (mBitmap != null) { - result = mBitmap.hashCode(); + if (bitmap != null) { + result = bitmap.hashCode(); } - if (mId != null) { - result = 31 * result + mId.hashCode(); + if (id != null) { + result = 31 * result + id.hashCode(); } return result; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java index 93c6deddc95..7ba4709fb32 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java @@ -30,23 +30,23 @@ public final class IconFactory { private static final String ICON_ID_PREFIX = "com.mapbox.icons.icon_"; - private Context mContext; - private static IconFactory sInstance; - private Icon mDefaultMarker; - private Icon mDefaultMarkerView; - private BitmapFactory.Options mOptions; + private static IconFactory instance; - private int mNextId = 0; + private Context context; + private Icon defaultMarker; + private Icon defaultMarkerView; + private BitmapFactory.Options options; + private int nextId = 0; public static synchronized IconFactory getInstance(@NonNull Context context) { - if (sInstance == null) { - sInstance = new IconFactory(context.getApplicationContext()); + if (instance == null) { + instance = new IconFactory(context.getApplicationContext()); } - return sInstance; + return instance; } private IconFactory(@NonNull Context context) { - mContext = context; + this.context = context; DisplayMetrics realMetrics = null; DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); @@ -57,20 +57,20 @@ private IconFactory(@NonNull Context context) { } wm.getDefaultDisplay().getMetrics(metrics); - mOptions = new BitmapFactory.Options(); - mOptions.inScaled = true; - mOptions.inDensity = DisplayMetrics.DENSITY_DEFAULT; - mOptions.inTargetDensity = metrics.densityDpi; + options = new BitmapFactory.Options(); + options.inScaled = true; + options.inDensity = DisplayMetrics.DENSITY_DEFAULT; + options.inTargetDensity = metrics.densityDpi; if (realMetrics != null) { - mOptions.inScreenDensity = realMetrics.densityDpi; + options.inScreenDensity = realMetrics.densityDpi; } } public Icon fromBitmap(@NonNull Bitmap bitmap) { - if (mNextId < 0) { + if (nextId < 0) { throw new TooManyIconsException(); } - String id = ICON_ID_PREFIX + ++mNextId; + String id = ICON_ID_PREFIX + ++nextId; return new Icon(id, bitmap); } @@ -96,7 +96,7 @@ public Icon fromDrawable(@NonNull Drawable drawable, int width, int height) { } public Icon fromResource(@DrawableRes int resourceId) { - Drawable drawable = ContextCompat.getDrawable(mContext, resourceId); + Drawable drawable = ContextCompat.getDrawable(context, resourceId); Bitmap bitmap; if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; @@ -116,28 +116,28 @@ public Icon fromResource(@DrawableRes int resourceId) { } public Icon defaultMarker() { - if (mDefaultMarker == null) { - mDefaultMarker = fromResource(R.drawable.default_marker); + if (defaultMarker == null) { + defaultMarker = fromResource(R.drawable.default_marker); } - return mDefaultMarker; + return defaultMarker; } public Icon defaultMarkerView() { - if (mDefaultMarkerView == null) { - mDefaultMarkerView = fromResource(R.drawable.default_markerview); + if (defaultMarkerView == null) { + defaultMarkerView = fromResource(R.drawable.default_markerview); } - return mDefaultMarkerView; + return defaultMarkerView; } private Icon fromInputStream(@NonNull InputStream is) { - Bitmap bitmap = BitmapFactory.decodeStream(is, null, mOptions); + Bitmap bitmap = BitmapFactory.decodeStream(is, null, options); return fromBitmap(bitmap); } public Icon fromAsset(@NonNull String assetName) { InputStream is; try { - is = mContext.getAssets().open(assetName); + is = context.getAssets().open(assetName); } catch (IOException e) { return null; } @@ -145,14 +145,14 @@ public Icon fromAsset(@NonNull String assetName) { } public Icon fromPath(@NonNull String absolutePath) { - Bitmap bitmap = BitmapFactory.decodeFile(absolutePath, mOptions); + Bitmap bitmap = BitmapFactory.decodeFile(absolutePath, options); return fromBitmap(bitmap); } public Icon fromFile(@NonNull String fileName) { FileInputStream is; try { - is = mContext.openFileInput(fileName); + is = context.openFileInput(fileName); } catch (FileNotFoundException e) { return null; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java index 9af459e8a05..3deee942345 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java @@ -26,21 +26,21 @@ */ public class InfoWindow { - private WeakReference mBoundMarker; - private WeakReference mMapboxMap; - protected WeakReference mView; + private WeakReference boundMarker; + private WeakReference mapboxMap; + protected WeakReference view; - private float mMarkerHeightOffset; - private float mMarkerWidthOffset; - private float mViewWidthOffset; - private PointF mCoordinates; - private boolean mIsVisible; + private float markerHeightOffset; + private float markerWidthOffset; + private float viewWidthOffset; + private PointF coordinates; + private boolean isVisible; @LayoutRes - private int mLayoutRes; + private int layoutRes; InfoWindow(MapView mapView, int layoutResId, MapboxMap mapboxMap) { - mLayoutRes = layoutResId; + layoutRes = layoutResId; View view = LayoutInflater.from(mapView.getContext()).inflate(layoutResId, mapView, false); initialize(view, mapboxMap); } @@ -50,14 +50,14 @@ public class InfoWindow { } private void initialize(View view, MapboxMap mapboxMap) { - mMapboxMap = new WeakReference<>(mapboxMap); - mIsVisible = false; - mView = new WeakReference<>(view); + this.mapboxMap = new WeakReference<>(mapboxMap); + isVisible = false; + this.view = new WeakReference<>(view); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - MapboxMap mapboxMap = mMapboxMap.get(); + MapboxMap mapboxMap = InfoWindow.this.mapboxMap.get(); if (mapboxMap != null) { MapboxMap.OnInfoWindowClickListener onInfoWindowClickListener = mapboxMap.getOnInfoWindowClickListener(); boolean handledDefaultClick = false; @@ -76,7 +76,7 @@ public void onClick(View v) { view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { - MapboxMap mapboxMap = mMapboxMap.get(); + MapboxMap mapboxMap = InfoWindow.this.mapboxMap.get(); if (mapboxMap != null) { MapboxMap.OnInfoWindowLongClickListener listener = mapboxMap.getOnInfoWindowLongClickListener(); if (listener != null) { @@ -103,19 +103,19 @@ InfoWindow open(MapView mapView, Marker boundMarker, LatLng position, int offset MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT); - MapboxMap mapboxMap = mMapboxMap.get(); - View view = mView.get(); + MapboxMap mapboxMap = this.mapboxMap.get(); + View view = this.view.get(); if (view != null && mapboxMap != null) { view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); // Calculate y-offset for update method - mMarkerHeightOffset = -view.getMeasuredHeight() + offsetY; - mMarkerWidthOffset = -offsetX; + markerHeightOffset = -view.getMeasuredHeight() + offsetY; + markerWidthOffset = -offsetX; // Calculate default Android x,y coordinate - mCoordinates = mapboxMap.getProjection().toScreenLocation(position); - float x = mCoordinates.x - (view.getMeasuredWidth() / 2) + offsetX; - float y = mCoordinates.y - view.getMeasuredHeight() + offsetY; + coordinates = mapboxMap.getProjection().toScreenLocation(position); + float x = coordinates.x - (view.getMeasuredWidth() / 2) + offsetX; + float y = coordinates.y - view.getMeasuredHeight() + offsetY; if (view instanceof InfoWindowView) { // only apply repositioning/margin for InfoWindowView @@ -175,11 +175,11 @@ InfoWindow open(MapView mapView, Marker boundMarker, LatLng position, int offset view.setY(y); // Calculate x-offset for update method - mViewWidthOffset = x - mCoordinates.x - offsetX; + viewWidthOffset = x - coordinates.x - offsetX; close(); //if it was already opened mapView.addView(view, lp); - mIsVisible = true; + isVisible = true; } return this; } @@ -190,10 +190,10 @@ InfoWindow open(MapView mapView, Marker boundMarker, LatLng position, int offset * @return this info window */ InfoWindow close() { - MapboxMap mapboxMap = mMapboxMap.get(); - if (mIsVisible && mapboxMap != null) { - mIsVisible = false; - View view = mView.get(); + MapboxMap mapboxMap = this.mapboxMap.get(); + if (isVisible && mapboxMap != null) { + isVisible = false; + View view = this.view.get(); if (view != null && view.getParent() != null) { ((ViewGroup) view.getParent()).removeView(view); } @@ -216,12 +216,12 @@ InfoWindow close() { * @param overlayItem the tapped overlay item */ void adaptDefaultMarker(Marker overlayItem, MapboxMap mapboxMap, MapView mapView) { - View view = mView.get(); + View view = this.view.get(); if (view == null) { - view = LayoutInflater.from(mapView.getContext()).inflate(mLayoutRes, mapView, false); + view = LayoutInflater.from(mapView.getContext()).inflate(layoutRes, mapView, false); initialize(view, mapboxMap); } - mMapboxMap = new WeakReference<>(mapboxMap); + this.mapboxMap = new WeakReference<>(mapboxMap); String title = overlayItem.getTitle(); TextView titleTextView = ((TextView) view.findViewById(R.id.infowindow_title)); if (!TextUtils.isEmpty(title)) { @@ -242,39 +242,39 @@ void adaptDefaultMarker(Marker overlayItem, MapboxMap mapboxMap, MapView mapView } InfoWindow setBoundMarker(Marker boundMarker) { - mBoundMarker = new WeakReference<>(boundMarker); + this.boundMarker = new WeakReference<>(boundMarker); return this; } Marker getBoundMarker() { - if (mBoundMarker == null) { + if (boundMarker == null) { return null; } - return mBoundMarker.get(); + return boundMarker.get(); } public void update() { - MapboxMap mapboxMap = mMapboxMap.get(); - Marker marker = mBoundMarker.get(); - View view = mView.get(); + MapboxMap mapboxMap = this.mapboxMap.get(); + Marker marker = boundMarker.get(); + View view = this.view.get(); if (mapboxMap != null && marker != null && view != null) { - mCoordinates = mapboxMap.getProjection().toScreenLocation(marker.getPosition()); + coordinates = mapboxMap.getProjection().toScreenLocation(marker.getPosition()); if (view instanceof InfoWindowView) { - view.setX(mCoordinates.x + mViewWidthOffset - mMarkerWidthOffset); + view.setX(coordinates.x + viewWidthOffset - markerWidthOffset); } else { - view.setX(mCoordinates.x - (view.getMeasuredWidth() / 2) - mMarkerWidthOffset); + view.setX(coordinates.x - (view.getMeasuredWidth() / 2) - markerWidthOffset); } - view.setY(mCoordinates.y + mMarkerHeightOffset); + view.setY(coordinates.y + markerHeightOffset); } } public View getView() { - return mView != null ? mView.get() : null; + return view != null ? view.get() : null; } boolean isVisible() { - return mIsVisible; + return isVisible; } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowTipView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowTipView.java index d2afafc59d5..8e60f58dcd7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowTipView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowTipView.java @@ -12,20 +12,20 @@ final class InfoWindowTipView extends View { - private Paint mPaint; - private Path mPath; - private int mLineWidth; + private Paint paint; + private Path path; + private int lineWidth; public InfoWindowTipView(Context context, AttributeSet attrs) { super(context, attrs); - mPath = new Path(); - mLineWidth = (int) context.getResources().getDimension(R.dimen.infowindow_line_width); - mPaint = new Paint(); - mPaint.setColor(Color.WHITE); - mPaint.setAntiAlias(true); - mPaint.setStrokeWidth(0.0f); - mPaint.setStyle(Paint.Style.FILL); + path = new Path(); + lineWidth = (int) context.getResources().getDimension(R.dimen.infowindow_line_width); + paint = new Paint(); + paint.setColor(Color.WHITE); + paint.setAntiAlias(true); + paint.setStrokeWidth(0.0f); + paint.setStyle(Paint.Style.FILL); } @Override @@ -34,29 +34,29 @@ protected void onDraw(Canvas canvas) { int height = getMeasuredHeight(); int width = getMeasuredWidth(); - mPath.rewind(); + path.rewind(); - this.mPaint.setColor(Color.WHITE); - this.mPaint.setAntiAlias(true); - this.mPaint.setStrokeWidth(0.0f); - this.mPaint.setStyle(Paint.Style.FILL); + this.paint.setColor(Color.WHITE); + this.paint.setAntiAlias(true); + this.paint.setStrokeWidth(0.0f); + this.paint.setStyle(Paint.Style.FILL); - mPath.moveTo(0, 0); - mPath.lineTo(width, 0); - mPath.lineTo((width / 2), height); - mPath.lineTo(0, 0); - canvas.drawPath(mPath, this.mPaint); + path.moveTo(0, 0); + path.lineTo(width, 0); + path.lineTo((width / 2), height); + path.lineTo(0, 0); + canvas.drawPath(path, this.paint); - mPath.rewind(); + path.rewind(); - this.mPaint.setColor(Color.parseColor("#C2C2C2")); - this.mPaint.setAntiAlias(true); - this.mPaint.setStrokeWidth(mLineWidth); - this.mPaint.setStyle(Paint.Style.STROKE); + this.paint.setColor(Color.parseColor("#C2C2C2")); + this.paint.setAntiAlias(true); + this.paint.setStrokeWidth(lineWidth); + this.paint.setStyle(Paint.Style.STROKE); - mPath.moveTo(0, 0); - mPath.lineTo(width / 2, height); - mPath.lineTo(width, 0); - canvas.drawPath(mPath, this.mPaint); + path.moveTo(0, 0); + path.lineTo(width / 2, height); + path.lineTo(width, 0); + canvas.drawPath(path, this.paint); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowView.java index 80dc5931a79..b2fa119d84c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindowView.java @@ -9,7 +9,7 @@ class InfoWindowView extends RelativeLayout { - private InfoWindowTipView mTipView; + private InfoWindowTipView tipView; public InfoWindowView(Context context) { this(context, null); @@ -26,11 +26,11 @@ public InfoWindowView(Context context, AttributeSet attrs, int defStyleAttr) { private void initialize(Context context) { LayoutInflater.from(context).inflate(R.layout.infowindow_content, this); - mTipView = (InfoWindowTipView) findViewById(R.id.infowindow_tipview); + tipView = (InfoWindowTipView) findViewById(R.id.infowindow_tipview); } void setTipViewMarginLeft(int marginLeft) { - RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mTipView.getLayoutParams(); + RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) tipView.getLayoutParams(); layoutParams.leftMargin = marginLeft; // This is a bit of a hack but prevents an occasional gap between the InfoWindow layoutParams.topMargin = (int) getResources().getDimension(R.dimen.infowindow_offset); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java index 2fd28202af6..d367f61c8c7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java @@ -14,10 +14,10 @@ */ public class LatLngBounds implements Parcelable { - private final double mLatNorth; - private final double mLatSouth; - private final double mLonEast; - private final double mLonWest; + private final double latNorth; + private final double latSouth; + private final double lonEast; + private final double lonWest; /** * Construct a new LatLngBounds based on its corners, given in NESW @@ -29,10 +29,10 @@ public class LatLngBounds implements Parcelable { * @param westLongitude Western Longitude */ LatLngBounds(final double northLatitude, final double eastLongitude, final double southLatitude, final double westLongitude) { - this.mLatNorth = northLatitude; - this.mLonEast = eastLongitude; - this.mLatSouth = southLatitude; - this.mLonWest = westLongitude; + this.latNorth = northLatitude; + this.lonEast = eastLongitude; + this.latSouth = southLatitude; + this.lonWest = westLongitude; } /** @@ -42,24 +42,24 @@ public class LatLngBounds implements Parcelable { * @return LatLng center of this LatLngBounds */ public LatLng getCenter() { - return new LatLng((this.mLatNorth + this.mLatSouth) / 2, - (this.mLonEast + this.mLonWest) / 2); + return new LatLng((this.latNorth + this.latSouth) / 2, + (this.lonEast + this.lonWest) / 2); } public double getLatNorth() { - return this.mLatNorth; + return this.latNorth; } public double getLatSouth() { - return this.mLatSouth; + return this.latSouth; } public double getLonEast() { - return this.mLonEast; + return this.lonEast; } public double getLonWest() { - return this.mLonWest; + return this.lonWest; } /** @@ -78,7 +78,7 @@ public LatLngSpan getSpan() { * @return Span distance */ public double getLatitudeSpan() { - return Math.abs(this.mLatNorth - this.mLatSouth); + return Math.abs(this.latNorth - this.latSouth); } /** @@ -88,7 +88,7 @@ public double getLatitudeSpan() { * @return Span distance */ public double getLongitudeSpan() { - return Math.abs(this.mLonEast - this.mLonWest); + return Math.abs(this.lonEast - this.lonWest); } @@ -103,7 +103,7 @@ public boolean isEmptySpan() { @Override public String toString() { - return "N:" + this.mLatNorth + "; E:" + this.mLonEast + "; S:" + this.mLatSouth + "; W:" + this.mLonWest; + return "N:" + this.latNorth + "; E:" + this.lonEast + "; S:" + this.latSouth + "; W:" + this.lonWest; } /** @@ -133,7 +133,7 @@ static LatLngBounds fromLatLngs(final List latLngs) { } public LatLng[] toLatLngs() { - return new LatLng[]{new LatLng(mLatNorth, mLonEast), new LatLng(mLatSouth, mLonWest)}; + return new LatLng[]{new LatLng(latNorth, lonEast), new LatLng(latSouth, lonWest)}; } /** @@ -147,10 +147,10 @@ public boolean equals(final Object o) { if (this == o) return true; if (o instanceof LatLngBounds) { LatLngBounds other = (LatLngBounds) o; - return mLatNorth == other.getLatNorth() - && mLatSouth == other.getLatSouth() - && mLonEast == other.getLonEast() - && mLonWest == other.getLonWest(); + return latNorth == other.getLatNorth() + && latSouth == other.getLatSouth() + && lonEast == other.getLonEast() + && lonWest == other.getLonWest(); } return false; } @@ -165,10 +165,10 @@ public boolean equals(final Object o) { public boolean contains(final ILatLng latLng) { final double latitude = latLng.getLatitude(); final double longitude = latLng.getLongitude(); - return ((latitude < this.mLatNorth) - && (latitude > this.mLatSouth)) - && ((longitude < this.mLonEast) - && (longitude > this.mLonWest)); + return ((latitude < this.latNorth) + && (latitude > this.latSouth)) + && ((longitude < this.lonEast) + && (longitude > this.lonWest)); } /** @@ -192,10 +192,10 @@ public LatLngBounds union(LatLngBounds bounds) { * @return BoundingBox */ public LatLngBounds union(final double lonNorth, final double latEast, final double lonSouth, final double latWest) { - return new LatLngBounds((this.mLatNorth < lonNorth) ? lonNorth : this.mLatNorth, - (this.mLonEast < latEast) ? latEast : this.mLonEast, - (this.mLatSouth > lonSouth) ? lonSouth : this.mLatSouth, - (this.mLonWest > latWest) ? latWest : this.mLonWest); + return new LatLngBounds((this.latNorth < lonNorth) ? lonNorth : this.latNorth, + (this.lonEast < latEast) ? latEast : this.lonEast, + (this.latSouth > lonSouth) ? lonSouth : this.latSouth, + (this.lonWest > latWest) ? latWest : this.lonWest); } /** @@ -245,10 +245,10 @@ public LatLngBounds[] newArray(final int size) { @Override public int hashCode() { - return (int) ((mLatNorth + 90) - + ((mLatSouth + 90) * 1000) - + ((mLonEast + 180) * 1000000) - + ((mLonEast + 180) * 1000000000)); + return (int) ((latNorth + 90) + + ((latSouth + 90) * 1000) + + ((lonEast + 180) * 1000000) + + ((lonEast + 180) * 1000000000)); } @Override @@ -258,10 +258,10 @@ public int describeContents() { @Override public void writeToParcel(final Parcel out, final int arg1) { - out.writeDouble(this.mLatNorth); - out.writeDouble(this.mLonEast); - out.writeDouble(this.mLatSouth); - out.writeDouble(this.mLonWest); + out.writeDouble(this.latNorth); + out.writeDouble(this.lonEast); + out.writeDouble(this.latSouth); + out.writeDouble(this.lonWest); } private static LatLngBounds readFromParcel(final Parcel in) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java index 81e52666f62..a21c4778ca1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java @@ -9,12 +9,12 @@ */ public class LatLngSpan implements Parcelable { - private double mLatitudeSpan; - private double mLongitudeSpan; + private double latitudeSpan; + private double longitudeSpan; private LatLngSpan(@NonNull Parcel in) { - mLatitudeSpan = in.readDouble(); - mLongitudeSpan = in.readDouble(); + latitudeSpan = in.readDouble(); + longitudeSpan = in.readDouble(); } /** @@ -24,8 +24,8 @@ private LatLngSpan(@NonNull Parcel in) { * @param longitudeSpan The span used for longitude. */ public LatLngSpan(double latitudeSpan, double longitudeSpan) { - mLatitudeSpan = latitudeSpan; - mLongitudeSpan = longitudeSpan; + this.latitudeSpan = latitudeSpan; + this.longitudeSpan = longitudeSpan; } /** @@ -34,7 +34,7 @@ public LatLngSpan(double latitudeSpan, double longitudeSpan) { * @return The latitude span. */ public double getLatitudeSpan() { - return mLatitudeSpan; + return latitudeSpan; } /** @@ -43,7 +43,7 @@ public double getLatitudeSpan() { * @param latitudeSpan The latitude span to set. */ public void setLatitudeSpan(double latitudeSpan) { - mLatitudeSpan = latitudeSpan; + this.latitudeSpan = latitudeSpan; } /** @@ -52,7 +52,7 @@ public void setLatitudeSpan(double latitudeSpan) { * @return The longitude span. */ public double getLongitudeSpan() { - return mLongitudeSpan; + return longitudeSpan; } /** @@ -61,7 +61,7 @@ public double getLongitudeSpan() { * @param longitudeSpan The longitude span to set. */ public void setLongitudeSpan(double longitudeSpan) { - mLongitudeSpan = longitudeSpan; + this.longitudeSpan = longitudeSpan; } @Override @@ -69,8 +69,8 @@ public boolean equals(Object o) { if (this == o) return true; if (o instanceof LatLngSpan) { LatLngSpan other = (LatLngSpan) o; - return mLongitudeSpan == other.getLongitudeSpan() - && mLatitudeSpan == other.getLatitudeSpan(); + return longitudeSpan == other.getLongitudeSpan() + && latitudeSpan == other.getLatitudeSpan(); } return false; } @@ -95,7 +95,7 @@ public int describeContents() { @Override public void writeToParcel(Parcel out, int arg1) { - out.writeDouble(mLatitudeSpan); - out.writeDouble(mLongitudeSpan); + out.writeDouble(latitudeSpan); + out.writeDouble(longitudeSpan); } } \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java index 5b87e70ef68..195cb440996 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HTTPRequest.java @@ -23,7 +23,7 @@ class HTTPRequest implements Callback { - private static OkHttpClient mClient = new OkHttpClient(); + private static OkHttpClient httpClient = new OkHttpClient(); private final String LOG_TAG = HTTPRequest.class.getName(); private static final int CONNECTION_ERROR = 0; @@ -32,19 +32,19 @@ class HTTPRequest implements Callback { // Reentrancy is not needed, but "Lock" is an // abstract class. - private ReentrantLock mLock = new ReentrantLock(); + private ReentrantLock lock = new ReentrantLock(); - private long mNativePtr = 0; + private long nativePtr = 0; - private Call mCall; - private Request mRequest; + private Call call; + private Request request; private native void nativeOnFailure(int type, String message); private native void nativeOnResponse(int code, String etag, String modified, String cacheControl, String expires, byte[] body); private HTTPRequest(long nativePtr, String resourceUrl, String userAgent, String etag, String modified) { - mNativePtr = nativePtr; + this.nativePtr = nativePtr; try { HttpUrl httpUrl = HttpUrl.parse(resourceUrl); @@ -64,25 +64,25 @@ private HTTPRequest(long nativePtr, String resourceUrl, String userAgent, String } else if (modified.length() > 0) { builder = builder.addHeader("If-Modified-Since", modified); } - mRequest = builder.build(); - mCall = mClient.newCall(mRequest); - mCall.enqueue(this); + request = builder.build(); + call = httpClient.newCall(request); + call.enqueue(this); } catch (Exception e) { onFailure(e); } } public void cancel() { - mCall.cancel(); + call.cancel(); // TODO: We need a lock here because we can try // to cancel at the same time the request is getting // answered on the OkHTTP thread. We could get rid of // this lock by using Runnable when we move Android // implementation of mbgl::RunLoop to Looper. - mLock.lock(); - mNativePtr = 0; - mLock.unlock(); + lock.lock(); + nativePtr = 0; + lock.unlock(); } @Override @@ -108,11 +108,11 @@ public void onResponse(Call call, Response response) throws IOException { response.body().close(); } - mLock.lock(); - if (mNativePtr != 0) { + lock.lock(); + if (nativePtr != 0) { nativeOnResponse(response.code(), response.header("ETag"), response.header("Last-Modified"), response.header("Cache-Control"), response.header("Expires"), body); } - mLock.unlock(); + lock.unlock(); } @Override @@ -132,10 +132,10 @@ private void onFailure(Exception e) { String errorMessage = e.getMessage() != null ? e.getMessage() : "Error processing the request"; - mLock.lock(); - if (mNativePtr != 0) { + lock.lock(); + if (nativePtr != 0) { nativeOnFailure(type, errorMessage); } - mLock.unlock(); + lock.unlock(); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java index 27ecb7520b0..a6fdef533a7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java @@ -31,8 +31,8 @@ */ public final class MapFragment extends Fragment { - private MapView mMap; - private OnMapReadyCallback mOnMapReadyCallback; + private MapView map; + private OnMapReadyCallback onMapReadyCallback; /** * Creates a MapFragment instance @@ -84,7 +84,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa options.accessToken(token); } } - return mMap = new MapView(inflater.getContext(), options); + return map = new MapView(inflater.getContext(), options); } /** @@ -128,7 +128,7 @@ private String getToken(@NonNull Context context) { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - mMap.onCreate(savedInstanceState); + map.onCreate(savedInstanceState); } /** @@ -137,7 +137,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) { @Override public void onStart() { super.onStart(); - mMap.getMapAsync(mOnMapReadyCallback); + map.getMapAsync(onMapReadyCallback); } /** @@ -146,7 +146,7 @@ public void onStart() { @Override public void onResume() { super.onResume(); - mMap.onResume(); + map.onResume(); } /** @@ -155,7 +155,7 @@ public void onResume() { @Override public void onPause() { super.onPause(); - mMap.onPause(); + map.onPause(); } /** @@ -166,7 +166,7 @@ public void onPause() { @Override public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); - mMap.onSaveInstanceState(outState); + map.onSaveInstanceState(outState); } /** @@ -183,7 +183,7 @@ public void onStop() { @Override public void onLowMemory() { super.onLowMemory(); - mMap.onLowMemory(); + map.onLowMemory(); } /** @@ -192,7 +192,7 @@ public void onLowMemory() { @Override public void onDestroyView() { super.onDestroyView(); - mMap.onDestroy(); + map.onDestroy(); } /** @@ -201,6 +201,6 @@ public void onDestroyView() { * @param onMapReadyCallback The callback to be invoked. */ public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) { - mOnMapReadyCallback = onMapReadyCallback; + this.onMapReadyCallback = onMapReadyCallback; } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 3cb28ed3957..b47fb74478e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -112,52 +112,52 @@ */ public class MapView extends FrameLayout { - private MapboxMap mMapboxMap; - private boolean mInitialLoad; - private boolean mDestroyed; - - private List mIcons; - private int mAverageIconHeight; - private int mAverageIconWidth; - - private NativeMapView mNativeMapView; - private boolean mHasSurface = false; - - private ViewGroup mMarkerViewContainer; - private CompassView mCompassView; - private ImageView mLogoView; - private ImageView mAttributionsView; - private MyLocationView mMyLocationView; - private LocationListener mMyLocationListener; - - private CopyOnWriteArrayList mOnMapChangedListener; - private ZoomButtonsController mZoomButtonsController; - private ConnectivityReceiver mConnectivityReceiver; - private float mScreenDensity = 1.0f; - - private TrackballLongPressTimeOut mCurrentTrackballLongPressTimeOut; - private GestureDetectorCompat mGestureDetector; - private ScaleGestureDetector mScaleGestureDetector; - private RotateGestureDetector mRotateGestureDetector; - private ShoveGestureDetector mShoveGestureDetector; - private boolean mTwoTap = false; - private boolean mZoomStarted = false; - private boolean mDragStarted = false; - private boolean mQuickZoom = false; - private boolean mScrollInProgress = false; - - private int mContentPaddingLeft; - private int mContentPaddingTop; - private int mContentPaddingRight; - private int mContentPaddingBottom; - - private PointF mFocalPoint; - - private String mStyleUrl; - private String mInitalStyle; - - private List mOnMapReadyCallbackList; - private SnapshotRequest mSnapshotRequest; + private MapboxMap mapboxMap; + private boolean initialLoad; + private boolean destroyed; + + private List icons; + private int averageIconHeight; + private int averageIconWidth; + + private NativeMapView nativeMapView; + private boolean hasSurface = false; + + private ViewGroup markerViewContainer; + private CompassView compassView; + private ImageView logoView; + private ImageView attributionsView; + private MyLocationView myLocationView; + private LocationListener myLocationListener; + + private CopyOnWriteArrayList onMapChangedListener; + private ZoomButtonsController zoomButtonsController; + private ConnectivityReceiver connectivityReceiver; + private float screenDensity = 1.0f; + + private TrackballLongPressTimeOut trackballLongPressTimeOut; + private GestureDetectorCompat gestureDetectorCompat; + private ScaleGestureDetector scaleGestureDetector; + private RotateGestureDetector rotateGestureDetector; + private ShoveGestureDetector shoveGestureDetector; + private boolean twoTap = false; + private boolean zoomStarted = false; + private boolean dragStarted = false; + private boolean quickZoom = false; + private boolean scrollInProgress = false; + + private int contentPaddingLeft; + private int contentPaddingTop; + private int contentPaddingRight; + private int contentPaddingBottom; + + private PointF focalPoint; + + private String styleUrl; + private String initialStyle; + + private List onMapReadyCallbackList; + private SnapshotRequest snapshotRequest; @UiThread public MapView(@NonNull Context context) { @@ -190,18 +190,18 @@ private void initialize(@NonNull Context context, @NonNull MapboxMapOptions opti return; } - mInitialLoad = true; - mOnMapReadyCallbackList = new ArrayList<>(); - mOnMapChangedListener = new CopyOnWriteArrayList<>(); - mMapboxMap = new MapboxMap(this); - mIcons = new ArrayList<>(); + initialLoad = true; + onMapReadyCallbackList = new ArrayList<>(); + onMapChangedListener = new CopyOnWriteArrayList<>(); + mapboxMap = new MapboxMap(this); + icons = new ArrayList<>(); View view = LayoutInflater.from(context).inflate(R.layout.mapview_internal, this); setWillNotDraw(false); // Reference the TextureView SurfaceView surfaceView = (SurfaceView) view.findViewById(R.id.surfaceView); - mNativeMapView = new NativeMapView(this); + nativeMapView = new NativeMapView(this); // Ensure this view is interactable setClickable(true); @@ -213,77 +213,77 @@ private void initialize(@NonNull Context context, @NonNull MapboxMapOptions opti surfaceView.getHolder().addCallback(new SurfaceCallback()); // Touch gesture detectors - mGestureDetector = new GestureDetectorCompat(context, new GestureListener()); - mGestureDetector.setIsLongpressEnabled(true); - mScaleGestureDetector = new ScaleGestureDetector(context, new ScaleGestureListener()); - ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, true); - mRotateGestureDetector = new RotateGestureDetector(context, new RotateGestureListener()); - mShoveGestureDetector = new ShoveGestureDetector(context, new ShoveGestureListener()); + gestureDetectorCompat = new GestureDetectorCompat(context, new GestureListener()); + gestureDetectorCompat.setIsLongpressEnabled(true); + scaleGestureDetector = new ScaleGestureDetector(context, new ScaleGestureListener()); + ScaleGestureDetectorCompat.setQuickScaleEnabled(scaleGestureDetector, true); + rotateGestureDetector = new RotateGestureDetector(context, new RotateGestureListener()); + shoveGestureDetector = new ShoveGestureDetector(context, new ShoveGestureListener()); - mZoomButtonsController = new ZoomButtonsController(this); - mZoomButtonsController.setZoomSpeed(MapboxConstants.ANIMATION_DURATION); - mZoomButtonsController.setOnZoomListener(new OnZoomListener()); + zoomButtonsController = new ZoomButtonsController(this); + zoomButtonsController.setZoomSpeed(MapboxConstants.ANIMATION_DURATION); + zoomButtonsController.setOnZoomListener(new OnZoomListener()); // Connectivity onConnectivityChanged(isConnected()); - mMarkerViewContainer = (ViewGroup) view.findViewById(R.id.markerViewContainer); + markerViewContainer = (ViewGroup) view.findViewById(R.id.markerViewContainer); - mMyLocationView = (MyLocationView) view.findViewById(R.id.userLocationView); - mMyLocationView.setMapboxMap(mMapboxMap); + myLocationView = (MyLocationView) view.findViewById(R.id.userLocationView); + myLocationView.setMapboxMap(mapboxMap); - mCompassView = (CompassView) view.findViewById(R.id.compassView); - mCompassView.setMapboxMap(mMapboxMap); + compassView = (CompassView) view.findViewById(R.id.compassView); + compassView.setMapboxMap(mapboxMap); - mLogoView = (ImageView) view.findViewById(R.id.logoView); + logoView = (ImageView) view.findViewById(R.id.logoView); // Setup Attributions control - mAttributionsView = (ImageView) view.findViewById(R.id.attributionView); - mAttributionsView.setOnClickListener(new AttributionOnClickListener(this)); + attributionsView = (ImageView) view.findViewById(R.id.attributionView); + attributionsView.setOnClickListener(new AttributionOnClickListener(this)); - mScreenDensity = context.getResources().getDisplayMetrics().density; + screenDensity = context.getResources().getDisplayMetrics().density; setInitialState(options); // Shows the zoom controls if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) { - mMapboxMap.getUiSettings().setZoomControlsEnabled(true); + mapboxMap.getUiSettings().setZoomControlsEnabled(true); } } private void setInitialState(MapboxMapOptions options) { - mMapboxMap.setDebugActive(options.getDebugActive()); + mapboxMap.setDebugActive(options.getDebugActive()); CameraPosition position = options.getCamera(); if (position != null) { - mMapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(position)); - mMyLocationView.setTilt(position.tilt); + mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(position)); + myLocationView.setTilt(position.tilt); } // access token String accessToken = options.getAccessToken(); if (!TextUtils.isEmpty(accessToken)) { - mMapboxMap.setAccessToken(accessToken); + mapboxMap.setAccessToken(accessToken); } // style url String style = options.getStyle(); if (!TextUtils.isEmpty(style)) { - mInitalStyle = style; + initialStyle = style; } // MyLocationView - MyLocationViewSettings myLocationViewSettings = mMapboxMap.getMyLocationViewSettings(); + MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings(); myLocationViewSettings.setForegroundDrawable(options.getMyLocationForegroundDrawable(), options.getMyLocationForegroundBearingDrawable()); myLocationViewSettings.setForegroundTintColor(options.getMyLocationForegroundTintColor()); myLocationViewSettings.setBackgroundDrawable(options.getMyLocationBackgroundDrawable(), options.getMyLocationBackgroundPadding()); myLocationViewSettings.setBackgroundTintColor(options.getMyLocationBackgroundTintColor()); myLocationViewSettings.setAccuracyAlpha(options.getMyLocationAccuracyAlpha()); myLocationViewSettings.setAccuracyTintColor(options.getMyLocationAccuracyTintColor()); - mMapboxMap.setMyLocationEnabled(options.getLocationEnabled()); + mapboxMap.setMyLocationEnabled(options.getLocationEnabled()); // Enable gestures - UiSettings uiSettings = mMapboxMap.getUiSettings(); + UiSettings uiSettings = mapboxMap.getUiSettings(); uiSettings.setZoomGesturesEnabled(options.getZoomGesturesEnabled()); uiSettings.setZoomGestureChangeAllowed(options.getZoomGesturesEnabled()); uiSettings.setScrollGesturesEnabled(options.getScrollGesturesEnabled()); @@ -297,8 +297,8 @@ private void setInitialState(MapboxMapOptions options) { uiSettings.setZoomControlsEnabled(options.getZoomControlsEnabled()); // Zoom - mMapboxMap.setMaxZoom(options.getMaxZoom()); - mMapboxMap.setMinZoom(options.getMinZoom()); + mapboxMap.setMaxZoom(options.getMaxZoom()); + mapboxMap.setMinZoom(options.getMinZoom()); // Compass uiSettings.setCompassEnabled(options.getCompassEnabled()); @@ -357,10 +357,10 @@ private void setInitialState(MapboxMapOptions options) { */ @UiThread public void onCreate(@Nullable Bundle savedInstanceState) { - String accessToken = mMapboxMap.getAccessToken(); + String accessToken = mapboxMap.getAccessToken(); if (TextUtils.isEmpty(accessToken)) { accessToken = MapboxAccountManager.getInstance().getAccessToken(); - mMapboxMap.setAccessToken(accessToken); + mapboxMap.setAccessToken(accessToken); } else { // user provided access token through xml attributes, need to start MapboxAccountManager MapboxAccountManager.start(getContext(), accessToken); @@ -374,10 +374,10 @@ public void onCreate(@Nullable Bundle savedInstanceState) { // Get previous camera position CameraPosition cameraPosition = savedInstanceState.getParcelable(MapboxConstants.STATE_CAMERA_POSITION); if (cameraPosition != null) { - mMapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); + mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } - UiSettings uiSettings = mMapboxMap.getUiSettings(); + UiSettings uiSettings = mapboxMap.getUiSettings(); uiSettings.setZoomGesturesEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_ZOOM_ENABLED)); uiSettings.setZoomGestureChangeAllowed(savedInstanceState.getBoolean(MapboxConstants.STATE_ZOOM_ENABLED_CHANGE)); uiSettings.setScrollGesturesEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_SCROLL_ENABLED)); @@ -412,17 +412,17 @@ public void onCreate(@Nullable Bundle savedInstanceState) { , savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_RIGHT) , savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_BOTTOM)); - mMapboxMap.setDebugActive(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE)); - mMapboxMap.setStyleUrl(savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL)); + mapboxMap.setDebugActive(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE)); + mapboxMap.setStyleUrl(savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL)); // User location try { - mMapboxMap.setMyLocationEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED)); + mapboxMap.setMyLocationEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED)); } catch (SecurityException ignore) { // User did not accept location permissions } - TrackingSettings trackingSettings = mMapboxMap.getTrackingSettings(); + TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); //noinspection ResourceType trackingSettings.setMyLocationTrackingMode(savedInstanceState.getInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, MyLocationTracking.TRACKING_NONE)); //noinspection ResourceType @@ -435,35 +435,35 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } // Initialize EGL - mNativeMapView.initializeDisplay(); - mNativeMapView.initializeContext(); + nativeMapView.initializeDisplay(); + nativeMapView.initializeContext(); // Add annotation deselection listener addOnMapChangedListener(new OnMapChangedListener() { @Override public void onMapChanged(@MapChange int change) { - if (change == WILL_START_RENDERING_MAP && mInitialLoad) { - mInitialLoad = false; + if (change == WILL_START_RENDERING_MAP && initialLoad) { + initialLoad = false; reloadIcons(); reloadMarkers(); adjustTopOffsetPixels(); - if (mOnMapReadyCallbackList.size() > 0) { - Iterator iterator = mOnMapReadyCallbackList.iterator(); + if (onMapReadyCallbackList.size() > 0) { + Iterator iterator = onMapReadyCallbackList.iterator(); while (iterator.hasNext()) { OnMapReadyCallback callback = iterator.next(); - callback.onMapReady(mMapboxMap); + callback.onMapReady(mapboxMap); iterator.remove(); } - mMapboxMap.getMarkerViewManager().scheduleViewMarkerInvalidation(); + mapboxMap.getMarkerViewManager().scheduleViewMarkerInvalidation(); } } else if (change == REGION_IS_CHANGING || change == REGION_DID_CHANGE || change == DID_FINISH_LOADING_MAP) { - mMapboxMap.getMarkerViewManager().scheduleViewMarkerInvalidation(); + mapboxMap.getMarkerViewManager().scheduleViewMarkerInvalidation(); - mCompassView.update(getDirection()); - mMyLocationView.update(); - mMapboxMap.getMarkerViewManager().update(); + compassView.update(getDirection()); + myLocationView.update(); + mapboxMap.getMarkerViewManager().update(); - for (InfoWindow infoWindow : mMapboxMap.getInfoWindows()) { + for (InfoWindow infoWindow : mapboxMap.getInfoWindows()) { infoWindow.update(); } } @@ -490,18 +490,18 @@ public void onMapChanged(@MapChange int change) { @UiThread public void onSaveInstanceState(@NonNull Bundle outState) { outState.putBoolean(MapboxConstants.STATE_HAS_SAVED_STATE, true); - outState.putParcelable(MapboxConstants.STATE_CAMERA_POSITION, mMapboxMap.getCameraPosition()); - outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, mMapboxMap.isDebugActive()); - outState.putString(MapboxConstants.STATE_STYLE_URL, mStyleUrl); - outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED, mMapboxMap.isMyLocationEnabled()); + outState.putParcelable(MapboxConstants.STATE_CAMERA_POSITION, mapboxMap.getCameraPosition()); + outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, mapboxMap.isDebugActive()); + outState.putString(MapboxConstants.STATE_STYLE_URL, styleUrl); + outState.putBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED, mapboxMap.isMyLocationEnabled()); // TrackingSettings - TrackingSettings trackingSettings = mMapboxMap.getTrackingSettings(); + TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); outState.putInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, trackingSettings.getMyLocationTrackingMode()); outState.putInt(MapboxConstants.STATE_MY_BEARING_TRACKING_MODE, trackingSettings.getMyBearingTrackingMode()); // UiSettings - UiSettings uiSettings = mMapboxMap.getUiSettings(); + UiSettings uiSettings = mapboxMap.getUiSettings(); outState.putBoolean(MapboxConstants.STATE_ZOOM_ENABLED, uiSettings.isZoomGesturesEnabled()); outState.putBoolean(MapboxConstants.STATE_ZOOM_ENABLED_CHANGE, uiSettings.isZoomGestureChangeAllowed()); outState.putBoolean(MapboxConstants.STATE_SCROLL_ENABLED, uiSettings.isScrollGesturesEnabled()); @@ -542,12 +542,12 @@ public void onSaveInstanceState(@NonNull Bundle outState) { */ @UiThread public void onDestroy() { - mDestroyed = true; - mNativeMapView.terminateContext(); - mNativeMapView.terminateDisplay(); - mNativeMapView.destroySurface(); - mNativeMapView.destroy(); - mNativeMapView = null; + destroyed = true; + nativeMapView.terminateContext(); + nativeMapView.terminateDisplay(); + nativeMapView.destroySurface(); + nativeMapView.destroy(); + nativeMapView = null; } /** @@ -556,10 +556,10 @@ public void onDestroy() { @UiThread public void onPause() { // Register for connectivity changes - getContext().unregisterReceiver(mConnectivityReceiver); - mConnectivityReceiver = null; + getContext().unregisterReceiver(connectivityReceiver); + connectivityReceiver = null; - mMyLocationView.onPause(); + myLocationView.onPause(); } /** @@ -568,29 +568,29 @@ public void onPause() { @UiThread public void onResume() { // Register for connectivity changes - mConnectivityReceiver = new ConnectivityReceiver(); - getContext().registerReceiver(mConnectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); + connectivityReceiver = new ConnectivityReceiver(); + getContext().registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); - mNativeMapView.update(); - mMyLocationView.onResume(); + nativeMapView.update(); + myLocationView.onResume(); - if (mStyleUrl == null) { + if (styleUrl == null) { // user supplied style through xml // user has failed to supply a style url - setStyleUrl(mInitalStyle == null ? Style.MAPBOX_STREETS : mInitalStyle); + setStyleUrl(initialStyle == null ? Style.MAPBOX_STREETS : initialStyle); } } void setFocalPoint(PointF focalPoint) { if (focalPoint == null) { // resetting focal point, - UiSettings uiSettings = mMapboxMap.getUiSettings(); + UiSettings uiSettings = mapboxMap.getUiSettings(); // need to validate if we need to reset focal point with user provided one if (uiSettings.getFocalPoint() != null) { focalPoint = uiSettings.getFocalPoint(); } } - mFocalPoint = focalPoint; + this.focalPoint = focalPoint; } /** @@ -598,7 +598,7 @@ void setFocalPoint(PointF focalPoint) { */ @UiThread public void onLowMemory() { - mNativeMapView.onLowMemory(); + nativeMapView.onLowMemory(); } // Called when debug mode is enabled to update a FPS counter @@ -608,7 +608,7 @@ protected void onFpsChanged(final double fps) { post(new Runnable() { @Override public void run() { - MapboxMap.OnFpsChangedListener listener = mMapboxMap.getOnFpsChangedListener(); + MapboxMap.OnFpsChangedListener listener = mapboxMap.getOnFpsChangedListener(); if (listener != null) { listener.onFpsChanged(fps); } @@ -621,7 +621,7 @@ public void run() { // LatLng getLatLng() { - return mNativeMapView.getLatLng(); + return nativeMapView.getLatLng(); } // @@ -629,12 +629,12 @@ LatLng getLatLng() { // double getTilt() { - return mNativeMapView.getPitch(); + return nativeMapView.getPitch(); } void setTilt(Double pitch) { - mMyLocationView.setTilt(pitch); - mNativeMapView.setPitch(pitch, 0); + myLocationView.setTilt(pitch); + nativeMapView.setPitch(pitch, 0); } @@ -643,11 +643,11 @@ void setTilt(Double pitch) { // double getDirection() { - if (mDestroyed) { + if (destroyed) { return 0; } - double direction = -mNativeMapView.getBearing(); + double direction = -nativeMapView.getBearing(); while (direction > 360) { direction -= 360; @@ -660,29 +660,29 @@ void setTilt(Double pitch) { } void setDirection(@FloatRange(from = MapboxConstants.MINIMUM_DIRECTION, to = MapboxConstants.MAXIMUM_DIRECTION) double direction) { - if (mDestroyed) { + if (destroyed) { return; } setDirection(direction, false); } void setDirection(@FloatRange(from = MapboxConstants.MINIMUM_DIRECTION, to = MapboxConstants.MAXIMUM_DIRECTION) double direction, boolean animated) { - if (mDestroyed) { + if (destroyed) { return; } long duration = animated ? MapboxConstants.ANIMATION_DURATION : 0; - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Out of range directions are normalised in setBearing - mNativeMapView.setBearing(-direction, duration); + nativeMapView.setBearing(-direction, duration); } void resetNorth() { - if (mDestroyed) { + if (destroyed) { return; } - mMyLocationView.setBearing(0); - mNativeMapView.cancelTransitions(); - mNativeMapView.resetNorth(); + myLocationView.setBearing(0); + nativeMapView.cancelTransitions(); + nativeMapView.resetNorth(); } // @@ -690,27 +690,27 @@ void resetNorth() { // int getContentPaddingLeft() { - return mContentPaddingLeft; + return contentPaddingLeft; } int getContentPaddingTop() { - return mContentPaddingTop; + return contentPaddingTop; } int getContentPaddingRight() { - return mContentPaddingRight; + return contentPaddingRight; } int getContentPaddingBottom() { - return mContentPaddingBottom; + return contentPaddingBottom; } int getContentWidth() { - return getWidth() - mContentPaddingLeft - mContentPaddingRight; + return getWidth() - contentPaddingLeft - contentPaddingRight; } int getContentHeight() { - return getHeight() - mContentPaddingBottom - mContentPaddingTop; + return getHeight() - contentPaddingBottom - contentPaddingTop; } // @@ -718,38 +718,38 @@ int getContentHeight() { // double getZoom() { - if (mDestroyed) { + if (destroyed) { return 0; } - return mNativeMapView.getZoom(); + return nativeMapView.getZoom(); } void setMinZoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = MapboxConstants.MAXIMUM_ZOOM) double minZoom) { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.setMinZoom(minZoom); + nativeMapView.setMinZoom(minZoom); } double getMinZoom() { - if (mDestroyed) { + if (destroyed) { return 0; } - return mNativeMapView.getMinZoom(); + return nativeMapView.getMinZoom(); } void setMaxZoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = MapboxConstants.MAXIMUM_ZOOM) double maxZoom) { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.setMaxZoom(maxZoom); + nativeMapView.setMaxZoom(maxZoom); } double getMaxZoom() { - if (mDestroyed) { + if (destroyed) { return 0; } - return mNativeMapView.getMaxZoom(); + return nativeMapView.getMaxZoom(); } // Zoom in or out @@ -759,16 +759,16 @@ private void zoom(boolean zoomIn) { private void zoom(boolean zoomIn, float x, float y) { // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); if (zoomIn) { - mNativeMapView.scaleBy(2.0, x / mScreenDensity, y / mScreenDensity, MapboxConstants.ANIMATION_DURATION); + nativeMapView.scaleBy(2.0, x / screenDensity, y / screenDensity, MapboxConstants.ANIMATION_DURATION); } else { - mNativeMapView.scaleBy(0.5, x / mScreenDensity, y / mScreenDensity, MapboxConstants.ANIMATION_DURATION); + nativeMapView.scaleBy(0.5, x / screenDensity, y / screenDensity, MapboxConstants.ANIMATION_DURATION); } // work around to invalidate camera position - postDelayed(new ZoomInvalidator(mMapboxMap), MapboxConstants.ANIMATION_DURATION); + postDelayed(new ZoomInvalidator(mapboxMap), MapboxConstants.ANIMATION_DURATION); } // @@ -776,24 +776,24 @@ private void zoom(boolean zoomIn, float x, float y) { // boolean isDebugActive() { - if (mDestroyed) { + if (destroyed) { return false; } - return mNativeMapView.getDebug(); + return nativeMapView.getDebug(); } void setDebugActive(boolean debugActive) { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.setDebug(debugActive); + nativeMapView.setDebug(debugActive); } void cycleDebugOptions() { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.cycleDebugOptions(); + nativeMapView.cycleDebugOptions(); } // @@ -829,11 +829,11 @@ void cycleDebugOptions() { * @see Style */ public void setStyleUrl(@NonNull String url) { - if (mDestroyed) { + if (destroyed) { return; } - mStyleUrl = url; - mNativeMapView.setStyleUrl(url); + styleUrl = url; + nativeMapView.setStyleUrl(url); } /** @@ -866,7 +866,7 @@ public void setStyle(@Style.StyleUrl String style) { @UiThread @NonNull public String getStyleUrl() { - return mStyleUrl; + return styleUrl; } // @@ -892,7 +892,7 @@ public String getStyleUrl() { @Deprecated @UiThread public void setAccessToken(@NonNull String accessToken) { - if (mDestroyed) { + if (destroyed) { return; } // validateAccessToken does the null check @@ -900,7 +900,7 @@ public void setAccessToken(@NonNull String accessToken) { accessToken = accessToken.trim(); } MapboxAccountManager.validateAccessToken(accessToken); - mNativeMapView.setAccessToken(accessToken); + nativeMapView.setAccessToken(accessToken); } /** @@ -918,10 +918,10 @@ public void setAccessToken(@NonNull String accessToken) { @UiThread @Nullable public String getAccessToken() { - if (mDestroyed) { + if (destroyed) { return ""; } - return mNativeMapView.getAccessToken(); + return nativeMapView.getAccessToken(); } // @@ -929,19 +929,19 @@ public String getAccessToken() { // LatLng fromScreenLocation(@NonNull PointF point) { - if (mDestroyed) { + if (destroyed) { return new LatLng(); } - point.set(point.x / mScreenDensity, point.y / mScreenDensity); - return mNativeMapView.latLngForPixel(point); + point.set(point.x / screenDensity, point.y / screenDensity); + return nativeMapView.latLngForPixel(point); } PointF toScreenLocation(@NonNull LatLng location) { - if (mDestroyed || location == null) { + if (destroyed || location == null) { return new PointF(); } - PointF pointF = mNativeMapView.pixelForLatLng(location); - pointF.set(pointF.x * mScreenDensity, pointF.y * mScreenDensity); + PointF pointF = nativeMapView.pixelForLatLng(location); + pointF.set(pointF.x * screenDensity, pointF.y * screenDensity); return pointF; } @@ -953,27 +953,27 @@ Icon loadIconForMarker(Marker marker) { Icon icon = marker.getIcon(); // calculating average before adding - int iconSize = mIcons.size() + 1; + int iconSize = icons.size() + 1; // TODO replace former if case with anchor implementation, // current workaround for having extra pixels is diving height by 2 if (icon == null) { icon = IconFactory.getInstance(getContext()).defaultMarker(); Bitmap bitmap = icon.getBitmap(); - mAverageIconHeight = mAverageIconHeight + (bitmap.getHeight() / 2 - mAverageIconHeight) / iconSize; - mAverageIconWidth = mAverageIconHeight + (bitmap.getWidth() - mAverageIconHeight) / iconSize; + averageIconHeight = averageIconHeight + (bitmap.getHeight() / 2 - averageIconHeight) / iconSize; + averageIconWidth = averageIconHeight + (bitmap.getWidth() - averageIconHeight) / iconSize; marker.setIcon(icon); } else { Bitmap bitmap = icon.getBitmap(); - mAverageIconHeight = mAverageIconHeight + (bitmap.getHeight() - mAverageIconHeight) / iconSize; - mAverageIconWidth = mAverageIconHeight + (bitmap.getWidth() - mAverageIconHeight) / iconSize; + averageIconHeight = averageIconHeight + (bitmap.getHeight() - averageIconHeight) / iconSize; + averageIconWidth = averageIconHeight + (bitmap.getWidth() - averageIconHeight) / iconSize; } - if (!mIcons.contains(icon)) { - mIcons.add(icon); + if (!icons.contains(icon)) { + icons.add(icon); loadIcon(icon); } else { - Icon oldIcon = mIcons.get(mIcons.indexOf(icon)); + Icon oldIcon = icons.get(icons.indexOf(icon)); if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) { throw new IconBitmapChangedException(); } @@ -982,7 +982,7 @@ Icon loadIconForMarker(Marker marker) { } void loadIcon(Icon icon) { - if (mDestroyed) { + if (destroyed) { return; } Bitmap bitmap = icon.getBitmap(); @@ -998,7 +998,7 @@ void loadIcon(Icon icon) { density = DisplayMetrics.DENSITY_DEFAULT; } float scale = density / DisplayMetrics.DENSITY_DEFAULT; - mNativeMapView.addAnnotationIcon( + nativeMapView.addAnnotationIcon( id, bitmap.getWidth(), bitmap.getHeight(), @@ -1006,15 +1006,15 @@ void loadIcon(Icon icon) { } void reloadIcons() { - int count = mIcons.size(); + int count = icons.size(); for (int i = 0; i < count; i++) { - Icon icon = mIcons.get(i); + Icon icon = icons.get(i); loadIcon(icon); } } void updateMarker(@NonNull Marker updatedMarker) { - if (mDestroyed) { + if (destroyed) { return; } if (updatedMarker == null) { @@ -1031,12 +1031,12 @@ void updateMarker(@NonNull Marker updatedMarker) { ensureIconLoaded(updatedMarker); } - mNativeMapView.updateMarker(updatedMarker); + nativeMapView.updateMarker(updatedMarker); } void updatePolygon(Polygon polygon) { - if (mDestroyed) { + if (destroyed) { return; } @@ -1050,11 +1050,11 @@ void updatePolygon(Polygon polygon) { return; } - mNativeMapView.updatePolygon(polygon); + nativeMapView.updatePolygon(polygon); } void updatePolyline(Polyline polyline) { - if (mDestroyed) { + if (destroyed) { return; } @@ -1068,7 +1068,7 @@ void updatePolyline(Polyline polyline) { return; } - mNativeMapView.updatePolyline(polyline); + nativeMapView.updatePolyline(polyline); } private void ensureIconLoaded(Marker marker) { @@ -1077,85 +1077,85 @@ private void ensureIconLoaded(Marker marker) { icon = IconFactory.getInstance(getContext()).defaultMarker(); marker.setIcon(icon); } - if (!mIcons.contains(icon)) { - mIcons.add(icon); + if (!icons.contains(icon)) { + icons.add(icon); loadIcon(icon); } else { - Icon oldIcon = mIcons.get(mIcons.indexOf(icon)); + Icon oldIcon = icons.get(icons.indexOf(icon)); if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) { throw new IconBitmapChangedException(); } } // this seems to be a costly operation according to the profiler so I'm trying to save some calls - Marker previousMarker = marker.getId() != -1 ? (Marker) mMapboxMap.getAnnotation(marker.getId()) : null; + Marker previousMarker = marker.getId() != -1 ? (Marker) mapboxMap.getAnnotation(marker.getId()) : null; if (previousMarker == null || previousMarker.getIcon() == null || previousMarker.getIcon() != marker.getIcon()) { marker.setTopOffsetPixels(getTopOffsetPixelsForIcon(icon)); } } long addMarker(@NonNull Marker marker) { - if (mDestroyed) { + if (destroyed) { return 0l; } - return mNativeMapView.addMarker(marker); + return nativeMapView.addMarker(marker); } long[] addMarkers(@NonNull List markerList) { - if (mDestroyed) { + if (destroyed) { return new long[]{}; } - return mNativeMapView.addMarkers(markerList); + return nativeMapView.addMarkers(markerList); } long addPolyline(@NonNull Polyline polyline) { - if (mDestroyed) { + if (destroyed) { return 0l; } - return mNativeMapView.addPolyline(polyline); + return nativeMapView.addPolyline(polyline); } long[] addPolylines(@NonNull List polylines) { - if (mDestroyed) { + if (destroyed) { return new long[]{}; } - return mNativeMapView.addPolylines(polylines); + return nativeMapView.addPolylines(polylines); } long addPolygon(@NonNull Polygon polygon) { - if (mDestroyed) { + if (destroyed) { return 0l; } - return mNativeMapView.addPolygon(polygon); + return nativeMapView.addPolygon(polygon); } long[] addPolygons(@NonNull List polygons) { - if (mDestroyed) { + if (destroyed) { return new long[]{}; } - return mNativeMapView.addPolygons(polygons); + return nativeMapView.addPolygons(polygons); } void removeAnnotation(long id) { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.removeAnnotation(id); + nativeMapView.removeAnnotation(id); } void removeAnnotations(@NonNull long[] ids) { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.removeAnnotations(ids); + nativeMapView.removeAnnotations(ids); } List getMarkersInRect(@NonNull RectF rect) { - if (mDestroyed || rect == null) { + if (destroyed || rect == null) { return new ArrayList<>(); } - long[] ids = mNativeMapView.queryPointAnnotations(rect); + long[] ids = nativeMapView.queryPointAnnotations(rect); List idsList = new ArrayList<>(ids.length); for (int i = 0; i < ids.length; i++) { @@ -1163,7 +1163,7 @@ List getMarkersInRect(@NonNull RectF rect) { } List annotations = new ArrayList<>(ids.length); - List annotationList = mMapboxMap.getAnnotations(); + List annotationList = mapboxMap.getAnnotations(); int count = annotationList.size(); for (int i = 0; i < count; i++) { Annotation annotation = annotationList.get(i); @@ -1176,11 +1176,11 @@ List getMarkersInRect(@NonNull RectF rect) { } public List getMarkerViewsInRect(@NonNull RectF rect) { - if (mDestroyed || rect == null) { + if (destroyed || rect == null) { return new ArrayList<>(); } - long[] ids = mNativeMapView.queryPointAnnotations(rect); + long[] ids = nativeMapView.queryPointAnnotations(rect); List idsList = new ArrayList<>(ids.length); for (int i = 0; i < ids.length; i++) { @@ -1188,7 +1188,7 @@ public List getMarkerViewsInRect(@NonNull RectF rect) { } List annotations = new ArrayList<>(ids.length); - List annotationList = mMapboxMap.getAnnotations(); + List annotationList = mapboxMap.getAnnotations(); int count = annotationList.size(); for (int i = 0; i < count; i++) { Annotation annotation = annotationList.get(i); @@ -1204,52 +1204,52 @@ public List getMarkerViewsInRect(@NonNull RectF rect) { * @return the ViewGroup containing the marker views */ public ViewGroup getMarkerViewContainer() { - return mMarkerViewContainer; + return markerViewContainer; } int getTopOffsetPixelsForIcon(Icon icon) { - if (mDestroyed) { + if (destroyed) { return 0; } - return (int) (mNativeMapView.getTopOffsetPixelsForAnnotationSymbol(icon.getId()) - * mScreenDensity); + return (int) (nativeMapView.getTopOffsetPixelsForAnnotationSymbol(icon.getId()) + * screenDensity); } void setContentPadding(int left, int top, int right, int bottom) { - if (mDestroyed) { + if (destroyed) { return; } -// if (left == mContentPaddingLeft && top == mContentPaddingTop && right == mContentPaddingRight && bottom == mContentPaddingBottom) { +// if (left == contentPaddingLeft && top == contentPaddingTop && right == contentPaddingRight && bottom == contentPaddingBottom) { // return; // } - mContentPaddingLeft = left; - mContentPaddingTop = top; - mContentPaddingRight = right; - mContentPaddingBottom = bottom; + contentPaddingLeft = left; + contentPaddingTop = top; + contentPaddingRight = right; + contentPaddingBottom = bottom; - int[] userLocationViewPadding = mMapboxMap.getMyLocationViewSettings().getPadding(); + int[] userLocationViewPadding = mapboxMap.getMyLocationViewSettings().getPadding(); left += userLocationViewPadding[0]; top += userLocationViewPadding[1]; right += userLocationViewPadding[2]; bottom += userLocationViewPadding[3]; - mNativeMapView.setContentPadding(top / mScreenDensity, left / mScreenDensity, bottom / mScreenDensity, right / mScreenDensity); + nativeMapView.setContentPadding(top / screenDensity, left / screenDensity, bottom / screenDensity, right / screenDensity); } public void invalidateContentPadding() { - setContentPadding(mContentPaddingLeft, mContentPaddingTop, mContentPaddingRight, mContentPaddingBottom); + setContentPadding(contentPaddingLeft, contentPaddingTop, contentPaddingRight, contentPaddingBottom); } double getMetersPerPixelAtLatitude(@FloatRange(from = -180, to = 180) double latitude) { - if (mDestroyed) { + if (destroyed) { return 0; } - return mNativeMapView.getMetersPerPixelAtLatitude(latitude, getZoom()) / mScreenDensity; + return nativeMapView.getMetersPerPixelAtLatitude(latitude, getZoom()) / screenDensity; } // @@ -1257,18 +1257,18 @@ public void invalidateContentPadding() { // void jumpTo(double bearing, LatLng center, double pitch, double zoom) { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.cancelTransitions(); - mNativeMapView.jumpTo(bearing, center, pitch, zoom); + nativeMapView.cancelTransitions(); + nativeMapView.jumpTo(bearing, center, pitch, zoom); } void easeTo(double bearing, LatLng center, long duration, double pitch, double zoom, boolean easingInterpolator, @Nullable final MapboxMap.CancelableCallback cancelableCallback) { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Register callbacks early enough if (cancelableCallback != null) { @@ -1285,14 +1285,14 @@ public void onMapChanged(@MapChange int change) { }); } - mNativeMapView.easeTo(bearing, center, duration, pitch, zoom, easingInterpolator); + nativeMapView.easeTo(bearing, center, duration, pitch, zoom, easingInterpolator); } void flyTo(double bearing, LatLng center, long duration, double pitch, double zoom, @Nullable final MapboxMap.CancelableCallback cancelableCallback) { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Register callbacks early enough if (cancelableCallback != null) { @@ -1309,11 +1309,11 @@ public void onMapChanged(@MapChange int change) { }); } - mNativeMapView.flyTo(bearing, center, duration, pitch, zoom); + nativeMapView.flyTo(bearing, center, duration, pitch, zoom); } private void adjustTopOffsetPixels() { - List annotations = mMapboxMap.getAnnotations(); + List annotations = mapboxMap.getAnnotations(); int count = annotations.size(); for (int i = 0; i < count; i++) { Annotation annotation = annotations.get(i); @@ -1324,26 +1324,26 @@ private void adjustTopOffsetPixels() { } } - for (Marker marker : mMapboxMap.getSelectedMarkers()) { + for (Marker marker : mapboxMap.getSelectedMarkers()) { if (marker.isInfoWindowShown()) { marker.hideInfoWindow(); - marker.showInfoWindow(mMapboxMap, this); + marker.showInfoWindow(mapboxMap, this); } } } private void reloadMarkers() { - if (mDestroyed) { + if (destroyed) { return; } - List annotations = mMapboxMap.getAnnotations(); + List annotations = mapboxMap.getAnnotations(); int count = annotations.size(); for (int i = 0; i < count; i++) { Annotation annotation = annotations.get(i); if (annotation instanceof Marker) { Marker marker = (Marker) annotation; - mNativeMapView.removeAnnotation(annotation.getId()); - long newId = mNativeMapView.addMarker(marker); + nativeMapView.removeAnnotation(annotation.getId()); + long newId = nativeMapView.addMarker(marker); marker.setId(newId); } } @@ -1366,34 +1366,34 @@ public void onDraw(Canvas canvas) { return; } - if (mDestroyed) { + if (destroyed) { return; } - if (!mHasSurface) { + if (!hasSurface) { return; } - mNativeMapView.render(); + nativeMapView.render(); } @Override protected void onSizeChanged(int width, int height, int oldw, int oldh) { - if (mDestroyed) { + if (destroyed) { return; } if (!isInEditMode()) { - mNativeMapView.resizeView((int) (width / mScreenDensity), (int) (height / mScreenDensity)); + nativeMapView.resizeView((int) (width / screenDensity), (int) (height / screenDensity)); } } double getScale() { - if (mDestroyed) { + if (destroyed) { return 0; } - return mNativeMapView.getScale(); + return nativeMapView.getScale(); } private class SurfaceCallback implements SurfaceHolder.Callback { @@ -1402,44 +1402,44 @@ private class SurfaceCallback implements SurfaceHolder.Callback { @Override public void surfaceCreated(SurfaceHolder holder) { - mNativeMapView.createSurface(mSurface = holder.getSurface()); - mHasSurface = true; + nativeMapView.createSurface(mSurface = holder.getSurface()); + hasSurface = true; } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - if (mDestroyed) { + if (destroyed) { return; } - mNativeMapView.resizeFramebuffer(width, height); + nativeMapView.resizeFramebuffer(width, height); } @Override public void surfaceDestroyed(SurfaceHolder holder) { - mHasSurface = false; + hasSurface = false; - if (mNativeMapView != null) { - mNativeMapView.destroySurface(); + if (nativeMapView != null) { + nativeMapView.destroySurface(); } mSurface.release(); } } CameraPosition invalidateCameraPosition() { - if (mDestroyed) { + if (destroyed) { return new CameraPosition.Builder().build(); } - CameraPosition position = new CameraPosition.Builder(mNativeMapView.getCameraValues()).build(); - mMyLocationView.setCameraPosition(position); + CameraPosition position = new CameraPosition.Builder(nativeMapView.getCameraValues()).build(); + myLocationView.setCameraPosition(position); return position; } double getBearing() { - if (mDestroyed) { + if (destroyed) { return 0; } - double direction = -mNativeMapView.getBearing(); + double direction = -nativeMapView.getBearing(); while (direction > 360) { direction -= 360; @@ -1452,27 +1452,27 @@ CameraPosition invalidateCameraPosition() { } void setBearing(float bearing) { - if (mDestroyed) { + if (destroyed) { return; } - mMyLocationView.setBearing(bearing); - mNativeMapView.setBearing(bearing); + myLocationView.setBearing(bearing); + nativeMapView.setBearing(bearing); } void setBearing(float bearing, long duration) { - if (mDestroyed) { + if (destroyed) { return; } - mMyLocationView.setBearing(bearing); - mNativeMapView.setBearing(bearing, duration); + myLocationView.setBearing(bearing); + nativeMapView.setBearing(bearing, duration); } void setBearing(double bearing, float focalX, float focalY) { - if (mDestroyed) { + if (destroyed) { return; } - mMyLocationView.setBearing(bearing); - mNativeMapView.setBearing(bearing, focalX, focalY); + myLocationView.setBearing(bearing); + nativeMapView.setBearing(bearing, focalX, focalY); } // @@ -1485,16 +1485,16 @@ void setBearing(double bearing, float focalX, float focalY) { protected void onDetachedFromWindow() { super.onDetachedFromWindow(); // Required by ZoomButtonController (from Android SDK documentation) - if (mMapboxMap.getUiSettings().isZoomControlsEnabled()) { - mZoomButtonsController.setVisible(false); + if (mapboxMap.getUiSettings().isZoomControlsEnabled()) { + zoomButtonsController.setVisible(false); } // make sure we don't leak location listener - if (mMyLocationListener != null) { + if (myLocationListener != null) { // cleanup to prevent memory leak LocationServices services = LocationServices.getLocationServices(getContext()); - services.removeLocationListener(mMyLocationListener); - mMyLocationListener = null; + services.removeLocationListener(myLocationListener); + myLocationListener = null; } } @@ -1506,11 +1506,11 @@ protected void onVisibilityChanged(@NonNull View changedView, int visibility) { } // Required by ZoomButtonController (from Android SDK documentation) - if (mMapboxMap.getUiSettings().isZoomControlsEnabled() && (visibility != View.VISIBLE)) { - mZoomButtonsController.setVisible(false); + if (mapboxMap.getUiSettings().isZoomControlsEnabled() && (visibility != View.VISIBLE)) { + zoomButtonsController.setVisible(false); } - if (mMapboxMap.getUiSettings().isZoomControlsEnabled() && (visibility == View.VISIBLE)) { - mZoomButtonsController.setVisible(true); + if (mapboxMap.getUiSettings().isZoomControlsEnabled() && (visibility == View.VISIBLE)) { + zoomButtonsController.setVisible(true); } } @@ -1545,7 +1545,7 @@ private void trackGestureEvent(@NonNull String gestureId, @NonNull float xCoordi evt.put(MapboxEvent.KEY_GESTURE_ID, gestureId); evt.put(MapboxEvent.KEY_LATITUDE, tapLatLng.getLatitude()); evt.put(MapboxEvent.KEY_LONGITUDE, tapLatLng.getLongitude()); - evt.put(MapboxEvent.KEY_ZOOM, mMapboxMap.getCameraPosition().zoom); + evt.put(MapboxEvent.KEY_ZOOM, mapboxMap.getCameraPosition().zoom); MapboxEventManager.getMapboxEventManager().pushEvent(evt); } @@ -1576,7 +1576,7 @@ private void trackGestureDragEndEvent(@NonNull float xCoordinate, @NonNull float evt.put(MapboxEvent.ATTRIBUTE_CREATED, MapboxEventManager.generateCreateDate()); evt.put(MapboxEvent.KEY_LATITUDE, tapLatLng.getLatitude()); evt.put(MapboxEvent.KEY_LONGITUDE, tapLatLng.getLongitude()); - evt.put(MapboxEvent.KEY_ZOOM, mMapboxMap.getCameraPosition().zoom); + evt.put(MapboxEvent.KEY_ZOOM, mapboxMap.getCameraPosition().zoom); MapboxEventManager.getMapboxEventManager().pushEvent(evt); } @@ -1585,7 +1585,7 @@ private void trackGestureDragEndEvent(@NonNull float xCoordinate, @NonNull float @Override public boolean onTouchEvent(@NonNull MotionEvent event) { // Check and ignore non touch or left clicks - if (mDestroyed) { + if (destroyed) { return super.onTouchEvent(event); } @@ -1594,22 +1594,22 @@ public boolean onTouchEvent(@NonNull MotionEvent event) { } // Check two finger gestures first - mRotateGestureDetector.onTouchEvent(event); - mScaleGestureDetector.onTouchEvent(event); - mShoveGestureDetector.onTouchEvent(event); + rotateGestureDetector.onTouchEvent(event); + scaleGestureDetector.onTouchEvent(event); + shoveGestureDetector.onTouchEvent(event); // Handle two finger tap switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: // First pointer down - mNativeMapView.setGestureInProgress(true); + nativeMapView.setGestureInProgress(true); break; case MotionEvent.ACTION_POINTER_DOWN: // Second pointer down - mTwoTap = event.getPointerCount() == 2 - && mMapboxMap.getUiSettings().isZoomGesturesEnabled(); - if (mTwoTap) { + twoTap = event.getPointerCount() == 2 + && mapboxMap.getUiSettings().isZoomGesturesEnabled(); + if (twoTap) { // Confirmed 2nd Finger Down trackGestureEvent(MapboxEvent.GESTURE_TWO_FINGER_SINGLETAP, event.getX(), event.getY()); } @@ -1623,38 +1623,38 @@ public boolean onTouchEvent(@NonNull MotionEvent event) { // First pointer up long tapInterval = event.getEventTime() - event.getDownTime(); boolean isTap = tapInterval <= ViewConfiguration.getTapTimeout(); - boolean inProgress = mRotateGestureDetector.isInProgress() - || mScaleGestureDetector.isInProgress() - || mShoveGestureDetector.isInProgress(); + boolean inProgress = rotateGestureDetector.isInProgress() + || scaleGestureDetector.isInProgress() + || shoveGestureDetector.isInProgress(); - if (mTwoTap && isTap && !inProgress) { - if (mFocalPoint != null) { - zoom(false, mFocalPoint.x / mScreenDensity, mFocalPoint.y / mScreenDensity); + if (twoTap && isTap && !inProgress) { + if (focalPoint != null) { + zoom(false, focalPoint.x / screenDensity, focalPoint.y / screenDensity); } else { PointF focalPoint = TwoFingerGestureDetector.determineFocalPoint(event); zoom(false, focalPoint.x, focalPoint.y); } - mTwoTap = false; + twoTap = false; return true; } // Scroll / Pan Has Stopped - if (mScrollInProgress) { + if (scrollInProgress) { trackGestureDragEndEvent(event.getX(), event.getY()); - mScrollInProgress = false; + scrollInProgress = false; } - mTwoTap = false; - mNativeMapView.setGestureInProgress(false); + twoTap = false; + nativeMapView.setGestureInProgress(false); break; case MotionEvent.ACTION_CANCEL: - mTwoTap = false; - mNativeMapView.setGestureInProgress(false); + twoTap = false; + nativeMapView.setGestureInProgress(false); break; } - boolean retVal = mGestureDetector.onTouchEvent(event); + boolean retVal = gestureDetectorCompat.onTouchEvent(event); return retVal || super.onTouchEvent(event); } @@ -1666,8 +1666,8 @@ private class GestureListener extends GestureDetector.SimpleOnGestureListener { @SuppressLint("ResourceType") public boolean onDown(MotionEvent event) { // Show the zoom controls - if (mMapboxMap.getUiSettings().isZoomControlsEnabled()) { - mZoomButtonsController.setVisible(true); + if (mapboxMap.getUiSettings().isZoomControlsEnabled()) { + zoomButtonsController.setVisible(true); } return true; } @@ -1675,7 +1675,7 @@ public boolean onDown(MotionEvent event) { // Called for double taps @Override public boolean onDoubleTapEvent(MotionEvent e) { - if (mDestroyed || !mMapboxMap.getUiSettings().isZoomGesturesEnabled()) { + if (destroyed || !mapboxMap.getUiSettings().isZoomGesturesEnabled()) { return false; } @@ -1685,16 +1685,16 @@ public boolean onDoubleTapEvent(MotionEvent e) { case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: - if (mQuickZoom) { + if (quickZoom) { // insert here? - mQuickZoom = false; + quickZoom = false; break; } // Single finger double tap - if (mFocalPoint != null) { + if (focalPoint != null) { // User provided focal point - zoom(true, mFocalPoint.x, mFocalPoint.y); + zoom(true, focalPoint.x, focalPoint.y); } else { // Zoom in on gesture zoom(true, e.getX(), e.getY()); @@ -1709,26 +1709,26 @@ public boolean onDoubleTapEvent(MotionEvent e) { @Override public boolean onSingleTapUp(MotionEvent e) { - if (mDestroyed) { + if (destroyed) { return false; } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); return true; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { - List selectedMarkers = mMapboxMap.getSelectedMarkers(); + List selectedMarkers = mapboxMap.getSelectedMarkers(); PointF tapPoint = new PointF(e.getX(), e.getY()); - float toleranceSides = 4 * mScreenDensity; - float toleranceTopBottom = 10 * mScreenDensity; + float toleranceSides = 4 * screenDensity; + float toleranceTopBottom = 10 * screenDensity; - RectF tapRect = new RectF((tapPoint.x - mAverageIconWidth / 2 - toleranceSides) / mScreenDensity, - (tapPoint.y - mAverageIconHeight / 2 - toleranceTopBottom) / mScreenDensity, - (tapPoint.x + mAverageIconWidth / 2 + toleranceSides) / mScreenDensity, - (tapPoint.y + mAverageIconHeight / 2 + toleranceTopBottom) / mScreenDensity); + RectF tapRect = new RectF((tapPoint.x - averageIconWidth / 2 - toleranceSides) / screenDensity, + (tapPoint.y - averageIconHeight / 2 - toleranceTopBottom) / screenDensity, + (tapPoint.x + averageIconWidth / 2 + toleranceSides) / screenDensity, + (tapPoint.y + averageIconHeight / 2 + toleranceTopBottom) / screenDensity); List nearbyMarkers = getMarkersInRect(tapRect); long newSelectedMarkerId = -1; @@ -1750,7 +1750,7 @@ public boolean onSingleTapConfirmed(MotionEvent e) { } if (newSelectedMarkerId >= 0) { - List annotations = mMapboxMap.getAnnotations(); + List annotations = mapboxMap.getAnnotations(); int count = annotations.size(); for (int i = 0; i < count; i++) { Annotation annotation = annotations.get(i); @@ -1759,7 +1759,7 @@ public boolean onSingleTapConfirmed(MotionEvent e) { if (selectedMarkers.isEmpty() || !selectedMarkers.contains(annotation)) { // only handle click if no marker view is available if (!(annotation instanceof MarkerView)) { - mMapboxMap.selectMarker((Marker) annotation); + mapboxMap.selectMarker((Marker) annotation); } } break; @@ -1767,13 +1767,13 @@ public boolean onSingleTapConfirmed(MotionEvent e) { } } } else { - if (mMapboxMap.getUiSettings().isDeselectMarkersOnTap()) { + if (mapboxMap.getUiSettings().isDeselectMarkersOnTap()) { // deselect any selected marker - mMapboxMap.deselectMarkers(); + mapboxMap.deselectMarkers(); } // notify app of map click - MapboxMap.OnMapClickListener listener = mMapboxMap.getOnMapClickListener(); + MapboxMap.OnMapClickListener listener = mapboxMap.getOnMapClickListener(); if (listener != null) { LatLng point = fromScreenLocation(tapPoint); listener.onMapClick(point); @@ -1787,8 +1787,8 @@ public boolean onSingleTapConfirmed(MotionEvent e) { // Called for a long press @Override public void onLongPress(MotionEvent e) { - MapboxMap.OnMapLongClickListener listener = mMapboxMap.getOnMapLongClickListener(); - if (listener != null && !mQuickZoom) { + MapboxMap.OnMapLongClickListener listener = mapboxMap.getOnMapLongClickListener(); + if (listener != null && !quickZoom) { LatLng point = fromScreenLocation(new PointF(e.getX(), e.getY())); listener.onMapLongClick(point); } @@ -1797,7 +1797,7 @@ public void onLongPress(MotionEvent e) { // Called for flings @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - if (mDestroyed || !mMapboxMap.getUiSettings().isScrollGesturesEnabled()) { + if (destroyed || !mapboxMap.getUiSettings().isScrollGesturesEnabled()) { return false; } @@ -1815,11 +1815,11 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve double duration = speed / (deceleration * ease); // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); - mNativeMapView.moveBy(velocityX * duration / 2.0 / mScreenDensity, velocityY * duration / 2.0 / mScreenDensity, (long) (duration * 1000.0f)); + nativeMapView.moveBy(velocityX * duration / 2.0 / screenDensity, velocityY * duration / 2.0 / screenDensity, (long) (duration * 1000.0f)); - MapboxMap.OnFlingListener listener = mMapboxMap.getOnFlingListener(); + MapboxMap.OnFlingListener listener = mapboxMap.getOnFlingListener(); if (listener != null) { listener.onFling(); } @@ -1831,14 +1831,14 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve // Called for drags @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { - if (!mScrollInProgress) { - mScrollInProgress = true; + if (!scrollInProgress) { + scrollInProgress = true; } - if (mDestroyed || !mMapboxMap.getUiSettings().isScrollGesturesEnabled()) { + if (destroyed || !mapboxMap.getUiSettings().isScrollGesturesEnabled()) { return false; } - if (mDragStarted) { + if (dragStarted) { return false; } @@ -1848,12 +1848,12 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float d resetTrackingModesIfRequired(); // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Scroll the map - mNativeMapView.moveBy(-distanceX / mScreenDensity, -distanceY / mScreenDensity); + nativeMapView.moveBy(-distanceX / screenDensity, -distanceY / screenDensity); - MapboxMap.OnScrollListener listener = mMapboxMap.getOnScrollListener(); + MapboxMap.OnScrollListener listener = mapboxMap.getOnScrollListener(); if (listener != null) { listener.onScroll(); } @@ -1870,7 +1870,7 @@ private class ScaleGestureListener extends ScaleGestureDetector.SimpleOnScaleGes // Called when two fingers first touch the screen @Override public boolean onScaleBegin(ScaleGestureDetector detector) { - if (mDestroyed || !mMapboxMap.getUiSettings().isZoomGesturesEnabled()) { + if (destroyed || !mapboxMap.getUiSettings().isZoomGesturesEnabled()) { return false; } @@ -1887,56 +1887,56 @@ public boolean onScaleBegin(ScaleGestureDetector detector) { public void onScaleEnd(ScaleGestureDetector detector) { mBeginTime = 0; mScaleFactor = 1.0f; - mZoomStarted = false; + zoomStarted = false; } // Called each time a finger moves // Called for pinch zooms and quickzooms/quickscales @Override public boolean onScale(ScaleGestureDetector detector) { - UiSettings uiSettings = mMapboxMap.getUiSettings(); - if (mDestroyed || !uiSettings.isZoomGesturesEnabled()) { + UiSettings uiSettings = mapboxMap.getUiSettings(); + if (destroyed || !uiSettings.isZoomGesturesEnabled()) { return super.onScale(detector); } // If scale is large enough ignore a tap mScaleFactor *= detector.getScaleFactor(); if ((mScaleFactor > 1.05f) || (mScaleFactor < 0.95f)) { - mZoomStarted = true; + zoomStarted = true; } // Ignore short touches in case it is a tap // Also ignore small scales long time = detector.getEventTime(); long interval = time - mBeginTime; - if (!mZoomStarted && (interval <= ViewConfiguration.getTapTimeout())) { + if (!zoomStarted && (interval <= ViewConfiguration.getTapTimeout())) { return false; } - if (!mZoomStarted) { + if (!zoomStarted) { return false; } - if (mDragStarted) { + if (dragStarted) { return false; } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Gesture is a quickzoom if there aren't two fingers - mQuickZoom = !mTwoTap; + quickZoom = !twoTap; // Scale the map - if (mFocalPoint != null) { + if (focalPoint != null) { // arround user provided focal point - mNativeMapView.scaleBy(detector.getScaleFactor(), mFocalPoint.x / mScreenDensity, mFocalPoint.y / mScreenDensity); - } else if (mQuickZoom) { + nativeMapView.scaleBy(detector.getScaleFactor(), focalPoint.x / screenDensity, focalPoint.y / screenDensity); + } else if (quickZoom) { // around center map - mNativeMapView.scaleBy(detector.getScaleFactor(), (getWidth() / 2) / mScreenDensity, (getHeight() / 2) / mScreenDensity); + nativeMapView.scaleBy(detector.getScaleFactor(), (getWidth() / 2) / screenDensity, (getHeight() / 2) / screenDensity); } else { // around gesture - mNativeMapView.scaleBy(detector.getScaleFactor(), detector.getFocusX() / mScreenDensity, detector.getFocusY() / mScreenDensity); + nativeMapView.scaleBy(detector.getScaleFactor(), detector.getFocusX() / screenDensity, detector.getFocusY() / screenDensity); } return true; @@ -1953,7 +1953,7 @@ private class RotateGestureListener extends RotateGestureDetector.SimpleOnRotate // Called when two fingers first touch the screen @Override public boolean onRotateBegin(RotateGestureDetector detector) { - if (mDestroyed || !mMapboxMap.getUiSettings().isRotateGesturesEnabled()) { + if (destroyed || !mapboxMap.getUiSettings().isRotateGesturesEnabled()) { return false; } @@ -1977,18 +1977,18 @@ public void onRotateEnd(RotateGestureDetector detector) { // Called for rotation @Override public boolean onRotate(RotateGestureDetector detector) { - if (mDestroyed || !mMapboxMap.getUiSettings().isRotateGesturesEnabled()) { + if (destroyed || !mapboxMap.getUiSettings().isRotateGesturesEnabled()) { return false; } - if (mDragStarted) { + if (dragStarted) { return false; } // If rotate is large enough ignore a tap // Also is zoom already started, don't rotate mTotalAngle += detector.getRotationDegreesDelta(); - if (!mZoomStarted && ((mTotalAngle > 20.0f) || (mTotalAngle < -20.0f))) { + if (!zoomStarted && ((mTotalAngle > 20.0f) || (mTotalAngle < -20.0f))) { mStarted = true; } @@ -2005,19 +2005,19 @@ public boolean onRotate(RotateGestureDetector detector) { } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Get rotate value - double bearing = mNativeMapView.getBearing(); + double bearing = nativeMapView.getBearing(); bearing += detector.getRotationDegreesDelta(); // Rotate the map - if (mFocalPoint != null) { + if (focalPoint != null) { // User provided focal point - setBearing(bearing, mFocalPoint.x / mScreenDensity, mFocalPoint.y / mScreenDensity); + setBearing(bearing, focalPoint.x / screenDensity, focalPoint.y / screenDensity); } else { // around gesture - setBearing(bearing, detector.getFocusX() / mScreenDensity, detector.getFocusY() / mScreenDensity); + setBearing(bearing, detector.getFocusX() / screenDensity, detector.getFocusY() / screenDensity); } return true; } @@ -2033,7 +2033,7 @@ private class ShoveGestureListener implements ShoveGestureDetector.OnShoveGestur @Override public boolean onShoveBegin(ShoveGestureDetector detector) { - if (!mMapboxMap.getUiSettings().isTiltGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isTiltGesturesEnabled()) { return false; } @@ -2050,19 +2050,19 @@ public void onShoveEnd(ShoveGestureDetector detector) { mBeginTime = 0; mTotalDelta = 0.0f; mStarted = false; - mDragStarted = false; + dragStarted = false; } @Override public boolean onShove(ShoveGestureDetector detector) { - if (mDestroyed || !mMapboxMap.getUiSettings().isTiltGesturesEnabled()) { + if (destroyed || !mapboxMap.getUiSettings().isTiltGesturesEnabled()) { return false; } // If tilt is large enough ignore a tap // Also if zoom already started, don't tilt mTotalDelta += detector.getShovePixelsDelta(); - if (!mZoomStarted && ((mTotalDelta > 10.0f) || (mTotalDelta < -10.0f))) { + if (!zoomStarted && ((mTotalDelta > 10.0f) || (mTotalDelta < -10.0f))) { mStarted = true; } @@ -2079,7 +2079,7 @@ public boolean onShove(ShoveGestureDetector detector) { } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Get tilt value (scale and clamp) double pitch = getTilt(); @@ -2087,9 +2087,9 @@ public boolean onShove(ShoveGestureDetector detector) { pitch = Math.max(MapboxConstants.MINIMUM_TILT, Math.min(MapboxConstants.MAXIMUM_TILT, pitch)); // Tilt the map - mMapboxMap.setTilt(pitch); + mapboxMap.setTilt(pitch); - mDragStarted = true; + dragStarted = true; return true; } @@ -2108,7 +2108,7 @@ public void onVisibilityChanged(boolean visible) { // Called when user pushes a zoom button @Override public void onZoom(boolean zoomIn) { - if (!mMapboxMap.getUiSettings().isZoomGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isZoomGesturesEnabled()) { return; } zoom(zoomIn); @@ -2123,7 +2123,7 @@ public void onZoom(boolean zoomIn) { // down @Override public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) { - if (mDestroyed) { + if (destroyed) { return super.onKeyDown(keyCode, event); } @@ -2141,51 +2141,51 @@ public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) { return true; case KeyEvent.KEYCODE_DPAD_LEFT: - if (!mMapboxMap.getUiSettings().isScrollGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isScrollGesturesEnabled()) { return false; } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Move left - mNativeMapView.moveBy(scrollDist / mScreenDensity, 0.0 / mScreenDensity); + nativeMapView.moveBy(scrollDist / screenDensity, 0.0 / screenDensity); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: - if (!mMapboxMap.getUiSettings().isScrollGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isScrollGesturesEnabled()) { return false; } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Move right - mNativeMapView.moveBy(-scrollDist / mScreenDensity, 0.0 / mScreenDensity); + nativeMapView.moveBy(-scrollDist / screenDensity, 0.0 / screenDensity); return true; case KeyEvent.KEYCODE_DPAD_UP: - if (!mMapboxMap.getUiSettings().isScrollGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isScrollGesturesEnabled()) { return false; } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Move up - mNativeMapView.moveBy(0.0 / mScreenDensity, scrollDist / mScreenDensity); + nativeMapView.moveBy(0.0 / screenDensity, scrollDist / screenDensity); return true; case KeyEvent.KEYCODE_DPAD_DOWN: - if (!mMapboxMap.getUiSettings().isScrollGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isScrollGesturesEnabled()) { return false; } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Move down - mNativeMapView.moveBy(0.0 / mScreenDensity, -scrollDist / mScreenDensity); + nativeMapView.moveBy(0.0 / screenDensity, -scrollDist / screenDensity); return true; default: @@ -2203,7 +2203,7 @@ public boolean onKeyLongPress(int keyCode, KeyEvent event) { // onKeyLongPress is fired case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: - if (!mMapboxMap.getUiSettings().isZoomGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isZoomGesturesEnabled()) { return false; } @@ -2233,7 +2233,7 @@ public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_DPAD_CENTER: - if (!mMapboxMap.getUiSettings().isZoomGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isZoomGesturesEnabled()) { return false; } @@ -2250,22 +2250,22 @@ public boolean onKeyUp(int keyCode, KeyEvent event) { // units @Override public boolean onTrackballEvent(MotionEvent event) { - if (mDestroyed) { + if (destroyed) { return false; } // Choose the action switch (event.getActionMasked()) { // The trackball was rotated case MotionEvent.ACTION_MOVE: - if (!mMapboxMap.getUiSettings().isScrollGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isScrollGesturesEnabled()) { return false; } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Scroll the map - mNativeMapView.moveBy(-10.0 * event.getX() / mScreenDensity, -10.0 * event.getY() / mScreenDensity); + nativeMapView.moveBy(-10.0 * event.getX() / screenDensity, -10.0 * event.getY() / screenDensity); return true; // Trackball was pushed in so start tracking and tell system we are @@ -2274,23 +2274,23 @@ public boolean onTrackballEvent(MotionEvent event) { case MotionEvent.ACTION_DOWN: // Set up a delayed callback to check if trackball is still // After waiting the system long press time out - if (mCurrentTrackballLongPressTimeOut != null) { - mCurrentTrackballLongPressTimeOut.cancel(); - mCurrentTrackballLongPressTimeOut = null; + if (trackballLongPressTimeOut != null) { + trackballLongPressTimeOut.cancel(); + trackballLongPressTimeOut = null; } - mCurrentTrackballLongPressTimeOut = new TrackballLongPressTimeOut(); - postDelayed(mCurrentTrackballLongPressTimeOut, + trackballLongPressTimeOut = new TrackballLongPressTimeOut(); + postDelayed(trackballLongPressTimeOut, ViewConfiguration.getLongPressTimeout()); return true; // Trackball was released case MotionEvent.ACTION_UP: - if (!mMapboxMap.getUiSettings().isZoomGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isZoomGesturesEnabled()) { return false; } // Only handle if we have not already long pressed - if (mCurrentTrackballLongPressTimeOut != null) { + if (trackballLongPressTimeOut != null) { // Zoom in zoom(true); } @@ -2298,9 +2298,9 @@ public boolean onTrackballEvent(MotionEvent event) { // Trackball was cancelled case MotionEvent.ACTION_CANCEL: - if (mCurrentTrackballLongPressTimeOut != null) { - mCurrentTrackballLongPressTimeOut.cancel(); - mCurrentTrackballLongPressTimeOut = null; + if (trackballLongPressTimeOut != null) { + trackballLongPressTimeOut.cancel(); + trackballLongPressTimeOut = null; } return true; @@ -2334,7 +2334,7 @@ public void run() { zoom(false); // Ensure the up action is not run - mCurrentTrackballLongPressTimeOut = null; + trackballLongPressTimeOut = null; } } } @@ -2343,7 +2343,7 @@ public void run() { // such as mouse scroll events, mouse moves, joystick, trackpad @Override public boolean onGenericMotionEvent(MotionEvent event) { - if (mDestroyed) { + if (destroyed) { return false; } // Mouse events @@ -2353,18 +2353,18 @@ public boolean onGenericMotionEvent(MotionEvent event) { switch (event.getActionMasked()) { // Mouse scrolls case MotionEvent.ACTION_SCROLL: - if (!mMapboxMap.getUiSettings().isZoomGesturesEnabled()) { + if (!mapboxMap.getUiSettings().isZoomGesturesEnabled()) { return false; } // Cancel any animation - mNativeMapView.cancelTransitions(); + nativeMapView.cancelTransitions(); // Get the vertical scroll amount, one click = 1 float scrollDist = event.getAxisValue(MotionEvent.AXIS_VSCROLL); // Scale the map by the appropriate power of two factor - mNativeMapView.scaleBy(Math.pow(2.0, scrollDist), event.getX() / mScreenDensity, event.getY() / mScreenDensity); + nativeMapView.scaleBy(Math.pow(2.0, scrollDist), event.getX() / screenDensity, event.getY() / screenDensity); return true; @@ -2386,15 +2386,15 @@ public boolean onHoverEvent(@NonNull MotionEvent event) { case MotionEvent.ACTION_HOVER_ENTER: case MotionEvent.ACTION_HOVER_MOVE: // Show the zoom controls - if (mMapboxMap.getUiSettings().isZoomControlsEnabled()) { - mZoomButtonsController.setVisible(true); + if (mapboxMap.getUiSettings().isZoomControlsEnabled()) { + zoomButtonsController.setVisible(true); } return true; case MotionEvent.ACTION_HOVER_EXIT: // Hide the zoom controls - if (mMapboxMap.getUiSettings().isZoomControlsEnabled()) { - mZoomButtonsController.setVisible(false); + if (mapboxMap.getUiSettings().isZoomControlsEnabled()) { + zoomButtonsController.setVisible(false); } default: @@ -2430,7 +2430,7 @@ private boolean isConnected() { // Called when our Internet connectivity has changed private void onConnectivityChanged(boolean isConnected) { - mNativeMapView.setReachability(isConnected); + nativeMapView.setReachability(isConnected); } // @@ -2448,7 +2448,7 @@ private void onConnectivityChanged(boolean isConnected) { */ public void addOnMapChangedListener(@Nullable OnMapChangedListener listener) { if (listener != null) { - mOnMapChangedListener.add(listener); + onMapChangedListener.add(listener); } } @@ -2460,7 +2460,7 @@ public void addOnMapChangedListener(@Nullable OnMapChangedListener listener) { */ public void removeOnMapChangedListener(@Nullable OnMapChangedListener listener) { if (listener != null) { - mOnMapChangedListener.remove(listener); + onMapChangedListener.remove(listener); } } @@ -2468,9 +2468,9 @@ public void removeOnMapChangedListener(@Nullable OnMapChangedListener listener) // Called via JNI from NativeMapView // Forward to any listeners protected void onMapChanged(int mapChange) { - if (mOnMapChangedListener != null) { + if (onMapChangedListener != null) { OnMapChangedListener listener; - final Iterator iterator = mOnMapChangedListener.iterator(); + final Iterator iterator = onMapChangedListener.iterator(); while (iterator.hasNext()) { listener = iterator.next(); listener.onMapChanged(mapChange); @@ -2483,16 +2483,16 @@ protected void onMapChanged(int mapChange) { // void setMyLocationEnabled(boolean enabled) { - mMyLocationView.setEnabled(enabled); + myLocationView.setEnabled(enabled); } Location getMyLocation() { - return mMyLocationView.getLocation(); + return myLocationView.getLocation(); } void setOnMyLocationChangeListener(@Nullable final MapboxMap.OnMyLocationChangeListener listener) { if (listener != null) { - mMyLocationListener = new LocationListener() { + myLocationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { if (listener != null) { @@ -2500,37 +2500,37 @@ public void onLocationChanged(Location location) { } } }; - LocationServices.getLocationServices(getContext()).addLocationListener(mMyLocationListener); + LocationServices.getLocationServices(getContext()).addLocationListener(myLocationListener); } else { - LocationServices.getLocationServices(getContext()).removeLocationListener(mMyLocationListener); - mMyLocationListener = null; + LocationServices.getLocationServices(getContext()).removeLocationListener(myLocationListener); + myLocationListener = null; } } void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) { - if (myLocationTrackingMode != MyLocationTracking.TRACKING_NONE && !mMapboxMap.isMyLocationEnabled()) { - mMapboxMap.setMyLocationEnabled(true); + if (myLocationTrackingMode != MyLocationTracking.TRACKING_NONE && !mapboxMap.isMyLocationEnabled()) { + mapboxMap.setMyLocationEnabled(true); } - mMyLocationView.setMyLocationTrackingMode(myLocationTrackingMode); + myLocationView.setMyLocationTrackingMode(myLocationTrackingMode); if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) { - setFocalPoint(new PointF(mMyLocationView.getCenterX(), mMyLocationView.getCenterY())); + setFocalPoint(new PointF(myLocationView.getCenterX(), myLocationView.getCenterY())); } else { setFocalPoint(null); } - MapboxMap.OnMyLocationTrackingModeChangeListener listener = mMapboxMap.getOnMyLocationTrackingModeChangeListener(); + MapboxMap.OnMyLocationTrackingModeChangeListener listener = mapboxMap.getOnMyLocationTrackingModeChangeListener(); if (listener != null) { listener.onMyLocationTrackingModeChange(myLocationTrackingMode); } } void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) { - if (myBearingTrackingMode != MyBearingTracking.NONE && !mMapboxMap.isMyLocationEnabled()) { - mMapboxMap.setMyLocationEnabled(true); + if (myBearingTrackingMode != MyBearingTracking.NONE && !mapboxMap.isMyLocationEnabled()) { + mapboxMap.setMyLocationEnabled(true); } - mMyLocationView.setMyBearingTrackingMode(myBearingTrackingMode); - MapboxMap.OnMyBearingTrackingModeChangeListener listener = mMapboxMap.getOnMyBearingTrackingModeChangeListener(); + myLocationView.setMyBearingTrackingMode(myBearingTrackingMode); + MapboxMap.OnMyBearingTrackingModeChangeListener listener = mapboxMap.getOnMyBearingTrackingModeChangeListener(); if (listener != null) { listener.onMyBearingTrackingModeChange(myBearingTrackingMode); } @@ -2542,7 +2542,7 @@ boolean isPermissionsAccepted() { } private void resetTrackingModesIfRequired() { - TrackingSettings trackingSettings = mMapboxMap.getTrackingSettings(); + TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); if (trackingSettings.isDismissLocationTrackingOnGesture()) { resetLocationTrackingMode(); } @@ -2553,7 +2553,7 @@ private void resetTrackingModesIfRequired() { private void resetLocationTrackingMode() { try { - TrackingSettings trackingSettings = mMapboxMap.getTrackingSettings(); + TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE); } catch (SecurityException ignore) { // User did not accept location permissions @@ -2573,15 +2573,15 @@ private void resetBearingTrackingMode() { // void setCompassEnabled(boolean compassEnabled) { - mCompassView.setEnabled(compassEnabled); + compassView.setEnabled(compassEnabled); } void setCompassGravity(int gravity) { - setWidgetGravity(mCompassView, gravity); + setWidgetGravity(compassView, gravity); } void setCompassMargins(int left, int top, int right, int bottom) { - setWidgetMargins(mCompassView, left, top, right, bottom); + setWidgetMargins(compassView, left, top, right, bottom); } // @@ -2589,15 +2589,15 @@ void setCompassMargins(int left, int top, int right, int bottom) { // void setLogoGravity(int gravity) { - setWidgetGravity(mLogoView, gravity); + setWidgetGravity(logoView, gravity); } void setLogoMargins(int left, int top, int right, int bottom) { - setWidgetMargins(mLogoView, left, top, right, bottom); + setWidgetMargins(logoView, left, top, right, bottom); } void setLogoEnabled(boolean visible) { - mLogoView.setVisibility(visible ? View.VISIBLE : View.GONE); + logoView.setVisibility(visible ? View.VISIBLE : View.GONE); } // @@ -2605,23 +2605,23 @@ void setLogoEnabled(boolean visible) { // void setAttributionGravity(int gravity) { - setWidgetGravity(mAttributionsView, gravity); + setWidgetGravity(attributionsView, gravity); } void setAttributionMargins(int left, int top, int right, int bottom) { - setWidgetMargins(mAttributionsView, left, top, right, bottom); + setWidgetMargins(attributionsView, left, top, right, bottom); } void setAttributionEnabled(int visibility) { - mAttributionsView.setVisibility(visibility); + attributionsView.setVisibility(visibility); } void setAtttibutionTintColor(int tintColor) { - ColorUtils.setTintList(mAttributionsView, tintColor); + ColorUtils.setTintList(attributionsView, tintColor); } int getAttributionTintColor() { - return mMapboxMap.getUiSettings().getAttributionTintColor(); + return mapboxMap.getUiSettings().getAttributionTintColor(); } /** @@ -2631,29 +2631,29 @@ int getAttributionTintColor() { */ @UiThread public void getMapAsync(final OnMapReadyCallback callback) { - if (!mInitialLoad && callback != null) { - callback.onMapReady(mMapboxMap); + if (!initialLoad && callback != null) { + callback.onMapReady(mapboxMap); } else { if (callback != null) { - mOnMapReadyCallbackList.add(callback); + onMapReadyCallbackList.add(callback); } } } MapboxMap getMapboxMap() { - return mMapboxMap; + return mapboxMap; } void setMapboxMap(MapboxMap mapboxMap) { - mMapboxMap = mapboxMap; + this.mapboxMap = mapboxMap; } MyLocationView getUserLocationView() { - return mMyLocationView; + return myLocationView; } NativeMapView getNativeMapView() { - return mNativeMapView; + return nativeMapView; } // @@ -2662,23 +2662,23 @@ NativeMapView getNativeMapView() { @UiThread void snapshot(@NonNull final MapboxMap.SnapshotReadyCallback callback, @Nullable final Bitmap bitmap) { - mSnapshotRequest = new SnapshotRequest(bitmap, callback); - mNativeMapView.scheduleTakeSnapshot(); - mNativeMapView.render(); + snapshotRequest = new SnapshotRequest(bitmap, callback); + nativeMapView.scheduleTakeSnapshot(); + nativeMapView.render(); } // Called when the snapshot method was executed // Called via JNI from NativeMapView // Forward to any listeners protected void onSnapshotReady(byte[] bytes) { - if (mSnapshotRequest != null && bytes != null) { + if (snapshotRequest != null && bytes != null) { BitmapFactory.Options options = new BitmapFactory.Options(); - options.inBitmap = mSnapshotRequest.getBitmap(); // the old Bitmap to be reused + options.inBitmap = snapshotRequest.getBitmap(); // the old Bitmap to be reused options.inMutable = true; options.inSampleSize = 1; Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options); - MapboxMap.SnapshotReadyCallback callback = mSnapshotRequest.getCallback(); + MapboxMap.SnapshotReadyCallback callback = snapshotRequest.getCallback(); if (callback != null) { callback.onSnapshotReady(bitmap); } @@ -2715,10 +2715,10 @@ private void setWidgetGravity(@NonNull final View view, int gravity) { private void setWidgetMargins(@NonNull final View view, int left, int top, int right, int bottom) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); - left += mContentPaddingLeft; - top += mContentPaddingTop; - right += mContentPaddingRight; - bottom += mContentPaddingBottom; + left += contentPaddingLeft; + top += contentPaddingTop; + right += contentPaddingRight; + bottom += contentPaddingBottom; layoutParams.setMargins(left, top, right, bottom); view.setLayoutParams(layoutParams); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 6a71f93a934..746284aac84 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -64,54 +64,60 @@ public class MapboxMap { private static final String TAG = MapboxMap.class.getSimpleName(); - private MapView mMapView; - private UiSettings mUiSettings; - private TrackingSettings mTrackingSettings; - private MyLocationViewSettings myLocationViewSettings; - private Projection mProjection; - private CameraPosition mCameraPosition; - private boolean mInvalidCameraPosition; - private LongSparseArray mAnnotations; - - private List mSelectedMarkers; - private MarkerViewManager mMarkerViewManager; - - private List mInfoWindows; - private MapboxMap.InfoWindowAdapter mInfoWindowAdapter; - - private boolean mMyLocationEnabled; - private boolean mAllowConcurrentMultipleInfoWindows; - - private MapboxMap.OnMapClickListener mOnMapClickListener; - private MapboxMap.OnMapLongClickListener mOnMapLongClickListener; - private MapboxMap.OnMarkerClickListener mOnMarkerClickListener; - private MapboxMap.OnInfoWindowClickListener mOnInfoWindowClickListener; - private MapboxMap.OnInfoWindowLongClickListener mOnInfoWindowLongClickListener; - private MapboxMap.OnInfoWindowCloseListener mOnInfoWindowCloseListener; - private MapboxMap.OnFlingListener mOnFlingListener; - private MapboxMap.OnScrollListener mOnScrollListener; - private MapboxMap.OnMyLocationTrackingModeChangeListener mOnMyLocationTrackingModeChangeListener; - private MapboxMap.OnMyBearingTrackingModeChangeListener mOnMyBearingTrackingModeChangeListener; - private MapboxMap.OnFpsChangedListener mOnFpsChangedListener; - private MapboxMap.OnCameraChangeListener mOnCameraChangeListener; - - private double mMaxZoomLevel = -1; - private double mMinZoomLevel = -1; - - MapboxMap(@NonNull MapView mapView) { - mMapView = mapView; - mMapView.addOnMapChangedListener(new MapChangeCameraPositionListener()); - mUiSettings = new UiSettings(mapView); - mTrackingSettings = new TrackingSettings(mMapView, mUiSettings); - mProjection = new Projection(mapView); - mAnnotations = new LongSparseArray<>(); - mSelectedMarkers = new ArrayList<>(); - mInfoWindows = new ArrayList<>(); - mMarkerViewManager = new MarkerViewManager(this, mapView); + private MapView mapView; + private UiSettings uiSettings; + private TrackingSettings trackingSettings; + private MyLocationViewSettings + myLocationViewSettings; + private Projection projection; + private CameraPosition cameraPosition; + private boolean invalidCameraPosition; + private LongSparseArray annotations; + + private List selectedMarkers; + private MarkerViewManager markerViewManager; + + private List infoWindows; + private MapboxMap.InfoWindowAdapter infoWindowAdapter; + + private boolean myLocationEnabled; + private boolean allowConcurrentMultipleInfoWindows; + + private MapboxMap.OnMapClickListener onMapClickListener; + private MapboxMap.OnMapLongClickListener onMapLongClickListener; + private MapboxMap.OnMarkerClickListener onMarkerClickListener; + private MapboxMap.OnInfoWindowClickListener onInfoWindowClickListener; + private MapboxMap.OnInfoWindowLongClickListener onInfoWindowLongClickListener; + private MapboxMap.OnInfoWindowCloseListener onInfoWindowCloseListener; + private MapboxMap.OnFlingListener onFlingListener; + private MapboxMap.OnScrollListener onScrollListener; + private MapboxMap.OnMyLocationTrackingModeChangeListener onMyLocationTrackingModeChangeListener; + private MapboxMap.OnMyBearingTrackingModeChangeListener onMyBearingTrackingModeChangeListener; + private MapboxMap.OnFpsChangedListener onFpsChangedListener; + private MapboxMap.OnCameraChangeListener onCameraChangeListener; + + private double maxZoomLevel = -1; + private double minZoomLevel = -1; + + MapboxMap(@NonNull MapView view) { + mapView = view; + mapView.addOnMapChangedListener(new MapChangeCameraPositionListener()); + uiSettings = new UiSettings(mapView); + trackingSettings = new TrackingSettings(this.mapView, uiSettings); + projection = new Projection(mapView); + annotations = new LongSparseArray<>(); + selectedMarkers = new ArrayList<>(); + infoWindows = new ArrayList<>(); + markerViewManager = new MarkerViewManager(this, mapView); } // Style + /** + * TODO Public API JAVADOC + * @param layerId + * @return + */ @Nullable @UiThread public Layer getLayer(@NonNull String layerId) { @@ -137,26 +143,49 @@ public T getLayerAs(@NonNull String layerId) { } } + /** + * TODO Public API JAVADOC + * @param layer + */ @UiThread public void addLayer(@NonNull Layer layer) { addLayer(layer, null); } + /** + * TODO Public API JAVADOC + * @param layer + * @param before + */ @UiThread public void addLayer(@NonNull Layer layer, String before) { getMapView().getNativeMapView().addLayer(layer, before); } + /** + * TODO Public API JAVADOC + * @param layerId + * @throws NoSuchLayerException + */ @UiThread public void removeLayer(@NonNull String layerId) throws NoSuchLayerException { getMapView().getNativeMapView().removeLayer(layerId); } + /** + * TODO Public API JAVADOC + * @param source + */ @UiThread public void addSource(@NonNull Source source) { getMapView().getNativeMapView().addSource(source); } + /** + * TODO Public API JAVADOC + * @param sourceId + * @throws NoSuchSourceException + */ @UiThread public void removeSource(@NonNull String sourceId) throws NoSuchSourceException { getMapView().getNativeMapView().removeSource(sourceId); @@ -179,8 +208,8 @@ public void setMinZoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = Map Log.e(MapboxConstants.TAG, "Not setting minZoom, value is in unsupported range: " + minZoom); return; } - mMinZoomLevel = minZoom; - mMapView.setMinZoom(minZoom); + minZoomLevel = minZoom; + mapView.setMinZoom(minZoom); } /** @@ -192,10 +221,10 @@ public void setMinZoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = Map */ @UiThread public double getMinZoom() { - if (mMinZoomLevel == -1) { - return mMinZoomLevel = mMapView.getMinZoom(); + if (minZoomLevel == -1) { + return minZoomLevel = mapView.getMinZoom(); } - return mMinZoomLevel; + return minZoomLevel; } // @@ -215,8 +244,8 @@ public void setMaxZoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = Map Log.e(MapboxConstants.TAG, "Not setting maxZoom, value is in unsupported range: " + maxZoom); return; } - mMaxZoomLevel = maxZoom; - mMapView.setMaxZoom(maxZoom); + maxZoomLevel = maxZoom; + mapView.setMaxZoom(maxZoom); } /** @@ -228,10 +257,10 @@ public void setMaxZoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = Map */ @UiThread public double getMaxZoom() { - if (mMaxZoomLevel == -1) { - return mMaxZoomLevel = mMapView.getMaxZoom(); + if (maxZoomLevel == -1) { + return maxZoomLevel = mapView.getMaxZoom(); } - return mMaxZoomLevel; + return maxZoomLevel; } // @@ -244,7 +273,7 @@ public double getMaxZoom() { * @return the UiSettings associated with this map */ public UiSettings getUiSettings() { - return mUiSettings; + return uiSettings; } // @@ -257,7 +286,7 @@ public UiSettings getUiSettings() { * @return the TrackingSettings asssociated with this map */ public TrackingSettings getTrackingSettings() { - return mTrackingSettings; + return trackingSettings; } // @@ -271,7 +300,7 @@ public TrackingSettings getTrackingSettings() { */ public MyLocationViewSettings getMyLocationViewSettings() { if (myLocationViewSettings == null) { - myLocationViewSettings = new MyLocationViewSettings(mMapView, mMapView.getUserLocationView()); + myLocationViewSettings = new MyLocationViewSettings(mapView, mapView.getUserLocationView()); } return myLocationViewSettings; } @@ -286,7 +315,7 @@ public MyLocationViewSettings getMyLocationViewSettings() { * @return the Projection associated with this map */ public Projection getProjection() { - return mProjection; + return projection; } // @@ -300,10 +329,10 @@ public Projection getProjection() { * @return The current position of the Camera. */ public final CameraPosition getCameraPosition() { - if (mInvalidCameraPosition) { + if (invalidCameraPosition) { invalidateCameraPosition(); } - return mCameraPosition; + return cameraPosition; } /** @@ -339,8 +368,8 @@ public final void moveCamera(CameraUpdate update) { */ @UiThread public final void moveCamera(CameraUpdate update, MapboxMap.CancelableCallback callback) { - mCameraPosition = update.getCameraPosition(this); - mMapView.jumpTo(mCameraPosition.bearing, mCameraPosition.target, mCameraPosition.tilt, mCameraPosition.zoom); + cameraPosition = update.getCameraPosition(this); + mapView.jumpTo(cameraPosition.bearing, cameraPosition.target, cameraPosition.tilt, cameraPosition.zoom); if (callback != null) { callback.onFinish(); } @@ -396,15 +425,28 @@ public final void easeCamera(CameraUpdate update, int durationMs, final MapboxMa easeCamera(update, durationMs, true, callback); } + /** + * TODO Public API JAVADOC + * @param update + * @param durationMs + * @param easingInterpolator + */ @UiThread public final void easeCamera(CameraUpdate update, int durationMs, boolean easingInterpolator) { easeCamera(update, durationMs, easingInterpolator, null); } + /** + * TODO Public API JAVADOC + * @param update + * @param durationMs + * @param easingInterpolator + * @param callback + */ @UiThread public final void easeCamera(CameraUpdate update, int durationMs, boolean easingInterpolator, final MapboxMap.CancelableCallback callback) { - mCameraPosition = update.getCameraPosition(this); - mMapView.easeTo(mCameraPosition.bearing, mCameraPosition.target, getDurationNano(durationMs), mCameraPosition.tilt, mCameraPosition.zoom, easingInterpolator, new CancelableCallback() { + cameraPosition = update.getCameraPosition(this); + mapView.easeTo(cameraPosition.bearing, cameraPosition.target, getDurationNano(durationMs), cameraPosition.tilt, cameraPosition.zoom, easingInterpolator, new CancelableCallback() { @Override public void onCancel() { if (callback != null) { @@ -490,8 +532,8 @@ public final void animateCamera(CameraUpdate update, int durationMs) { */ @UiThread public final void animateCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) { - mCameraPosition = update.getCameraPosition(this); - mMapView.flyTo(mCameraPosition.bearing, mCameraPosition.target, getDurationNano(durationMs), mCameraPosition.tilt, mCameraPosition.zoom, new CancelableCallback() { + cameraPosition = update.getCameraPosition(this); + mapView.flyTo(cameraPosition.bearing, cameraPosition.target, getDurationNano(durationMs), cameraPosition.tilt, cameraPosition.zoom, new CancelableCallback() { @Override public void onCancel() { if (callback != null) { @@ -502,8 +544,8 @@ public void onCancel() { @Override public void onFinish() { - if (mOnCameraChangeListener != null) { - mOnCameraChangeListener.onCameraChange(mCameraPosition); + if (onCameraChangeListener != null) { + onCameraChangeListener.onCameraChange(cameraPosition); } if (callback != null) { @@ -514,6 +556,11 @@ public void onFinish() { }); } + void setTilt(double tilt) { + markerViewManager.setTilt((float) tilt); + mapView.setTilt(tilt); + } + /** * Converts milliseconds to nanoseconds * @@ -528,15 +575,15 @@ private long getDurationNano(long durationMs) { * Invalidates the current camera position by reconstructing it from mbgl */ private void invalidateCameraPosition() { - mInvalidCameraPosition = false; + invalidCameraPosition = false; - CameraPosition cameraPosition = mMapView.invalidateCameraPosition(); + CameraPosition cameraPosition = mapView.invalidateCameraPosition(); if (cameraPosition != null) { - mCameraPosition = cameraPosition; + this.cameraPosition = cameraPosition; } - if (mOnCameraChangeListener != null) { - mOnCameraChangeListener.onCameraChange(mCameraPosition); + if (onCameraChangeListener != null) { + onCameraChangeListener.onCameraChange(this.cameraPosition); } } @@ -548,7 +595,7 @@ private void invalidateCameraPosition() { * Resets the map view to face north. */ public void resetNorth() { - mMapView.resetNorth(); + mapView.resetNorth(); } // @@ -562,7 +609,7 @@ public void resetNorth() { */ @UiThread public boolean isDebugActive() { - return mMapView.isDebugActive(); + return mapView.isDebugActive(); } /** @@ -575,7 +622,7 @@ public boolean isDebugActive() { */ @UiThread public void setDebugActive(boolean debugActive) { - mMapView.setDebugActive(debugActive); + mapView.setDebugActive(debugActive); } /** @@ -589,7 +636,7 @@ public void setDebugActive(boolean debugActive) { */ @UiThread public void cycleDebugOptions() { - mMapView.cycleDebugOptions(); + mapView.cycleDebugOptions(); } // @@ -626,7 +673,7 @@ public void cycleDebugOptions() { */ @UiThread public void setStyleUrl(@NonNull String url) { - mMapView.setStyleUrl(url); + mapView.setStyleUrl(url); } /** @@ -661,7 +708,7 @@ public void setStyle(@Style.StyleUrl String style) { @UiThread @NonNull public String getStyleUrl() { - return mMapView.getStyleUrl(); + return mapView.getStyleUrl(); } // @@ -683,7 +730,7 @@ public String getStyleUrl() { @Deprecated @UiThread public void setAccessToken(@NonNull String accessToken) { - mMapView.setAccessToken(accessToken); + mapView.setAccessToken(accessToken); } /** @@ -701,19 +748,13 @@ public void setAccessToken(@NonNull String accessToken) { @UiThread @Nullable public String getAccessToken() { - return mMapView.getAccessToken(); + return mapView.getAccessToken(); } // // Annotations // - void setTilt(double tilt) { - mMarkerViewManager.setTilt((float) tilt); - mMapView.setTilt(tilt); - } - - /** *

* Adds a marker to this map. @@ -744,10 +785,10 @@ public Marker addMarker(@NonNull MarkerOptions markerOptions) { @NonNull public Marker addMarker(@NonNull BaseMarkerOptions markerOptions) { Marker marker = prepareMarker(markerOptions); - long id = mMapView.addMarker(marker); + long id = mapView.addMarker(marker); marker.setMapboxMap(this); marker.setId(id); - mAnnotations.put(id, marker); + annotations.put(id, marker); return marker; } @@ -766,10 +807,10 @@ public Marker addMarker(@NonNull BaseMarkerOptions markerOptions) { public MarkerView addMarker(@NonNull BaseMarkerViewOptions markerOptions) { MarkerView marker = prepareViewMarker(markerOptions); marker.setMapboxMap(this); - long id = mMapView.addMarker(marker); + long id = mapView.addMarker(marker); marker.setId(id); - mAnnotations.put(id, marker); - mMarkerViewManager.invalidateViewMarkersInVisibleRegion(); + annotations.put(id, marker); + markerViewManager.invalidateViewMarkersInVisibleRegion(); return marker; } @@ -798,7 +839,7 @@ public List addMarkers(@NonNull List marker } if (markers.size() > 0) { - long[] ids = mMapView.addMarkers(markers); + long[] ids = mapView.addMarkers(markers); // if unittests or markers are correctly added to map if (ids == null || ids.length == markers.size()) { @@ -814,7 +855,7 @@ public List addMarkers(@NonNull List marker id++; } m.setId(id); - mAnnotations.put(id, m); + annotations.put(id, m); } } } @@ -831,11 +872,11 @@ public List addMarkers(@NonNull List marker */ @UiThread public void updateMarker(@NonNull Marker updatedMarker) { - mMapView.updateMarker(updatedMarker); + mapView.updateMarker(updatedMarker); - int index = mAnnotations.indexOfKey(updatedMarker.getId()); + int index = annotations.indexOfKey(updatedMarker.getId()); if (index > -1) { - mAnnotations.setValueAt(index, updatedMarker); + annotations.setValueAt(index, updatedMarker); } } @@ -846,11 +887,11 @@ public void updateMarker(@NonNull Marker updatedMarker) { */ @UiThread public void updatePolygon(Polygon polygon) { - mMapView.updatePolygon(polygon); + mapView.updatePolygon(polygon); - int index = mAnnotations.indexOfKey(polygon.getId()); + int index = annotations.indexOfKey(polygon.getId()); if (index > -1) { - mAnnotations.setValueAt(index, polygon); + annotations.setValueAt(index, polygon); } } @@ -861,11 +902,11 @@ public void updatePolygon(Polygon polygon) { */ @UiThread public void updatePolyline(Polyline polyline) { - mMapView.updatePolyline(polyline); + mapView.updatePolyline(polyline); - int index = mAnnotations.indexOfKey(polyline.getId()); + int index = annotations.indexOfKey(polyline.getId()); if (index > -1) { - mAnnotations.setValueAt(index, polyline); + annotations.setValueAt(index, polyline); } } @@ -880,10 +921,10 @@ public void updatePolyline(Polyline polyline) { public Polyline addPolyline(@NonNull PolylineOptions polylineOptions) { Polyline polyline = polylineOptions.getPolyline(); if (!polyline.getPoints().isEmpty()) { - long id = mMapView.addPolyline(polyline); + long id = mapView.addPolyline(polyline); polyline.setMapboxMap(this); polyline.setId(id); - mAnnotations.put(id, polyline); + annotations.put(id, polyline); } return polyline; } @@ -909,7 +950,7 @@ public List addPolylines(@NonNull List polylineOption } } - long[] ids = mMapView.addPolylines(polylines); + long[] ids = mapView.addPolylines(polylines); // if unit tests or polylines are correctly added to map if (ids == null || ids.length == polylines.size()) { @@ -926,7 +967,7 @@ public List addPolylines(@NonNull List polylineOption id++; } p.setId(id); - mAnnotations.put(id, p); + annotations.put(id, p); } } } @@ -944,10 +985,10 @@ public List addPolylines(@NonNull List polylineOption public Polygon addPolygon(@NonNull PolygonOptions polygonOptions) { Polygon polygon = polygonOptions.getPolygon(); if (!polygon.getPoints().isEmpty()) { - long id = mMapView.addPolygon(polygon); + long id = mapView.addPolygon(polygon); polygon.setId(id); polygon.setMapboxMap(this); - mAnnotations.put(id, polygon); + annotations.put(id, polygon); } return polygon; } @@ -973,7 +1014,7 @@ public List addPolygons(@NonNull List polygonOptionsLis } } - long[] ids = mMapView.addPolygons(polygons); + long[] ids = mapView.addPolygons(polygons); // if unit tests or polygons correctly added to map if (ids == null || ids.length == polygons.size()) { @@ -988,7 +1029,7 @@ public List addPolygons(@NonNull List polygonOptionsLis id++; } polygon.setId(id); - mAnnotations.put(id, polygon); + annotations.put(id, polygon); } } } @@ -1045,12 +1086,12 @@ public void removeAnnotation(@NonNull Annotation annotation) { Marker marker = (Marker) annotation; marker.hideInfoWindow(); if (marker instanceof MarkerView) { - mMarkerViewManager.removeMarkerView((MarkerView) marker); + markerViewManager.removeMarkerView((MarkerView) marker); } } long id = annotation.getId(); - mMapView.removeAnnotation(id); - mAnnotations.remove(id); + mapView.removeAnnotation(id); + annotations.remove(id); } /** @@ -1060,8 +1101,8 @@ public void removeAnnotation(@NonNull Annotation annotation) { */ @UiThread public void removeAnnotation(long id) { - mMapView.removeAnnotation(id); - mAnnotations.remove(id); + mapView.removeAnnotation(id); + annotations.remove(id); } /** @@ -1079,14 +1120,14 @@ public void removeAnnotations(@NonNull List annotationList Marker marker = (Marker) annotation; marker.hideInfoWindow(); if (marker instanceof MarkerView) { - mMarkerViewManager.removeMarkerView((MarkerView) marker); + markerViewManager.removeMarkerView((MarkerView) marker); } } ids[i] = annotationList.get(i).getId(); } - mMapView.removeAnnotations(ids); + mapView.removeAnnotations(ids); for (long id : ids) { - mAnnotations.remove(id); + annotations.remove(id); } } @@ -1096,21 +1137,21 @@ public void removeAnnotations(@NonNull List annotationList @UiThread public void removeAnnotations() { Annotation annotation; - int count = mAnnotations.size(); + int count = annotations.size(); long[] ids = new long[count]; for (int i = 0; i < count; i++) { - ids[i] = mAnnotations.keyAt(i); - annotation = mAnnotations.get(ids[i]); + ids[i] = annotations.keyAt(i); + annotation = annotations.get(ids[i]); if (annotation instanceof Marker) { Marker marker = (Marker) annotation; marker.hideInfoWindow(); if (marker instanceof MarkerView) { - mMarkerViewManager.removeMarkerView((MarkerView) marker); + markerViewManager.removeMarkerView((MarkerView) marker); } } } - mMapView.removeAnnotations(ids); - mAnnotations.clear(); + mapView.removeAnnotations(ids); + annotations.clear(); } /** @@ -1129,7 +1170,7 @@ public void clear() { */ @Nullable public Annotation getAnnotation(long id) { - return mAnnotations.get(id); + return annotations.get(id); } /** @@ -1141,8 +1182,8 @@ public Annotation getAnnotation(long id) { @NonNull public List getAnnotations() { List annotations = new ArrayList<>(); - for (int i = 0; i < mAnnotations.size(); i++) { - annotations.add(mAnnotations.get(mAnnotations.keyAt(i))); + for (int i = 0; i < this.annotations.size(); i++) { + annotations.add(this.annotations.get(this.annotations.keyAt(i))); } return annotations; } @@ -1157,8 +1198,8 @@ public List getAnnotations() { public List getMarkers() { List markers = new ArrayList<>(); Annotation annotation; - for (int i = 0; i < mAnnotations.size(); i++) { - annotation = mAnnotations.get(mAnnotations.keyAt(i)); + for (int i = 0; i < annotations.size(); i++) { + annotation = annotations.get(annotations.keyAt(i)); if (annotation instanceof Marker) { markers.add((Marker) annotation); } @@ -1176,8 +1217,8 @@ public List getMarkers() { public List getPolygons() { List polygons = new ArrayList<>(); Annotation annotation; - for (int i = 0; i < mAnnotations.size(); i++) { - annotation = mAnnotations.get(mAnnotations.keyAt(i)); + for (int i = 0; i < annotations.size(); i++) { + annotation = annotations.get(annotations.keyAt(i)); if (annotation instanceof Polygon) { polygons.add((Polygon) annotation); } @@ -1195,8 +1236,8 @@ public List getPolygons() { public List getPolylines() { List polylines = new ArrayList<>(); Annotation annotation; - for (int i = 0; i < mAnnotations.size(); i++) { - annotation = mAnnotations.get(mAnnotations.keyAt(i)); + for (int i = 0; i < annotations.size(); i++) { + annotation = annotations.get(annotations.keyAt(i)); if (annotation instanceof Polyline) { polylines.add((Polyline) annotation); } @@ -1221,7 +1262,7 @@ public void selectMarker(@NonNull Marker marker) { return; } - if (mSelectedMarkers.contains(marker)) { + if (selectedMarkers.contains(marker)) { return; } @@ -1231,23 +1272,23 @@ public void selectMarker(@NonNull Marker marker) { } boolean handledDefaultClick = false; - if (mOnMarkerClickListener != null) { + if (onMarkerClickListener != null) { // end developer has provided a custom click listener - handledDefaultClick = mOnMarkerClickListener.onMarkerClick(marker); + handledDefaultClick = onMarkerClickListener.onMarkerClick(marker); } if (!handledDefaultClick) { if (marker instanceof MarkerView) { - mMarkerViewManager.select((MarkerView) marker, false); - mMarkerViewManager.ensureInfoWindowOffset((MarkerView) marker); + markerViewManager.select((MarkerView) marker, false); + markerViewManager.ensureInfoWindowOffset((MarkerView) marker); } if (isInfoWindowValidForMarker(marker) || getInfoWindowAdapter() != null) { - mInfoWindows.add(marker.showInfoWindow(this, mMapView)); + infoWindows.add(marker.showInfoWindow(this, mapView)); } } - mSelectedMarkers.add(marker); + selectedMarkers.add(marker); } /** @@ -1255,22 +1296,22 @@ public void selectMarker(@NonNull Marker marker) { */ @UiThread public void deselectMarkers() { - if (mSelectedMarkers.isEmpty()) { + if (selectedMarkers.isEmpty()) { return; } - for (Marker marker : mSelectedMarkers) { + for (Marker marker : selectedMarkers) { if (marker.isInfoWindowShown()) { marker.hideInfoWindow(); } if (marker instanceof MarkerView) { - mMarkerViewManager.deselect((MarkerView) marker, false); + markerViewManager.deselect((MarkerView) marker, false); } } // Removes all selected markers from the list - mSelectedMarkers.clear(); + selectedMarkers.clear(); } /** @@ -1280,7 +1321,7 @@ public void deselectMarkers() { */ @UiThread public void deselectMarker(@NonNull Marker marker) { - if (!mSelectedMarkers.contains(marker)) { + if (!selectedMarkers.contains(marker)) { return; } @@ -1289,10 +1330,10 @@ public void deselectMarker(@NonNull Marker marker) { } if (marker instanceof MarkerView) { - mMarkerViewManager.deselect((MarkerView) marker, false); + markerViewManager.deselect((MarkerView) marker, false); } - mSelectedMarkers.remove(marker); + selectedMarkers.remove(marker); } /** @@ -1302,13 +1343,13 @@ public void deselectMarker(@NonNull Marker marker) { */ @UiThread public List getSelectedMarkers() { - return mSelectedMarkers; + return selectedMarkers; } private Marker prepareMarker(BaseMarkerOptions markerOptions) { Marker marker = markerOptions.getMarker(); - Icon icon = mMapView.loadIconForMarker(marker); - marker.setTopOffsetPixels(mMapView.getTopOffsetPixelsForIcon(icon)); + Icon icon = mapView.loadIconForMarker(marker); + marker.setTopOffsetPixels(mapView.getTopOffsetPixelsForIcon(icon)); return marker; } @@ -1317,7 +1358,7 @@ private MarkerView prepareViewMarker(BaseMarkerViewOptions markerViewOptions) { Icon icon = markerViewOptions.getIcon(); if (icon == null) { - icon = IconFactory.getInstance(mMapView.getContext()).defaultMarkerView(); + icon = IconFactory.getInstance(mapView.getContext()).defaultMarkerView(); } marker.setIcon(icon); return marker; @@ -1329,7 +1370,7 @@ private MarkerView prepareViewMarker(BaseMarkerViewOptions markerViewOptions) { * @return the associated MarkerViewManager */ public MarkerViewManager getMarkerViewManager() { - return mMarkerViewManager; + return markerViewManager; } // @@ -1348,7 +1389,7 @@ public MarkerViewManager getMarkerViewManager() { */ @UiThread public void setInfoWindowAdapter(@Nullable InfoWindowAdapter infoWindowAdapter) { - mInfoWindowAdapter = infoWindowAdapter; + this.infoWindowAdapter = infoWindowAdapter; } /** @@ -1359,7 +1400,7 @@ public void setInfoWindowAdapter(@Nullable InfoWindowAdapter infoWindowAdapter) @UiThread @Nullable public InfoWindowAdapter getInfoWindowAdapter() { - return mInfoWindowAdapter; + return infoWindowAdapter; } /** @@ -1369,7 +1410,7 @@ public InfoWindowAdapter getInfoWindowAdapter() { */ @UiThread public void setAllowConcurrentMultipleOpenInfoWindows(boolean allow) { - mAllowConcurrentMultipleInfoWindows = allow; + allowConcurrentMultipleInfoWindows = allow; } /** @@ -1379,12 +1420,12 @@ public void setAllowConcurrentMultipleOpenInfoWindows(boolean allow) { */ @UiThread public boolean isAllowConcurrentMultipleOpenInfoWindows() { - return mAllowConcurrentMultipleInfoWindows; + return allowConcurrentMultipleInfoWindows; } // used by MapView List getInfoWindows() { - return mInfoWindows; + return infoWindows; } private boolean isInfoWindowValidForMarker(@NonNull Marker marker) { @@ -1414,8 +1455,8 @@ private boolean isInfoWindowValidForMarker(@NonNull Marker marker) { * @param bottom The bottom margin in pixels. */ public void setPadding(int left, int top, int right, int bottom) { - mMapView.setContentPadding(left, top, right, bottom); - mUiSettings.invalidate(); + mapView.setContentPadding(left, top, right, bottom); + uiSettings.invalidate(); } /** @@ -1424,10 +1465,10 @@ public void setPadding(int left, int top, int right, int bottom) { * @return An array with length 4 in the LTRB order. */ public int[] getPadding() { - return new int[]{mMapView.getContentPaddingLeft(), - mMapView.getContentPaddingTop(), - mMapView.getContentPaddingRight(), - mMapView.getContentPaddingBottom()}; + return new int[]{mapView.getContentPaddingLeft(), + mapView.getContentPaddingTop(), + mapView.getContentPaddingRight(), + mapView.getContentPaddingBottom()}; } // @@ -1442,7 +1483,7 @@ public int[] getPadding() { */ @UiThread public void setOnCameraChangeListener(@Nullable OnCameraChangeListener listener) { - mOnCameraChangeListener = listener; + onCameraChangeListener = listener; } /** @@ -1453,12 +1494,12 @@ public void setOnCameraChangeListener(@Nullable OnCameraChangeListener listener) */ @UiThread public void setOnFpsChangedListener(@Nullable OnFpsChangedListener listener) { - mOnFpsChangedListener = listener; + onFpsChangedListener = listener; } // used by MapView OnFpsChangedListener getOnFpsChangedListener() { - return mOnFpsChangedListener; + return onFpsChangedListener; } /** @@ -1469,12 +1510,12 @@ OnFpsChangedListener getOnFpsChangedListener() { */ @UiThread public void setOnScrollListener(@Nullable OnScrollListener listener) { - mOnScrollListener = listener; + onScrollListener = listener; } // used by MapView OnScrollListener getOnScrollListener() { - return mOnScrollListener; + return onScrollListener; } /** @@ -1485,12 +1526,12 @@ OnScrollListener getOnScrollListener() { */ @UiThread public void setOnFlingListener(@Nullable OnFlingListener listener) { - mOnFlingListener = listener; + onFlingListener = listener; } // used by MapView OnFlingListener getOnFlingListener() { - return mOnFlingListener; + return onFlingListener; } /** @@ -1501,12 +1542,12 @@ OnFlingListener getOnFlingListener() { */ @UiThread public void setOnMapClickListener(@Nullable OnMapClickListener listener) { - mOnMapClickListener = listener; + onMapClickListener = listener; } // used by MapView OnMapClickListener getOnMapClickListener() { - return mOnMapClickListener; + return onMapClickListener; } /** @@ -1517,12 +1558,12 @@ OnMapClickListener getOnMapClickListener() { */ @UiThread public void setOnMapLongClickListener(@Nullable OnMapLongClickListener listener) { - mOnMapLongClickListener = listener; + onMapLongClickListener = listener; } // used by MapView OnMapLongClickListener getOnMapLongClickListener() { - return mOnMapLongClickListener; + return onMapLongClickListener; } /** @@ -1533,7 +1574,7 @@ OnMapLongClickListener getOnMapLongClickListener() { */ @UiThread public void setOnMarkerClickListener(@Nullable OnMarkerClickListener listener) { - mOnMarkerClickListener = listener; + onMarkerClickListener = listener; } /** @@ -1544,7 +1585,7 @@ public void setOnMarkerClickListener(@Nullable OnMarkerClickListener listener) { */ @UiThread public void setOnInfoWindowClickListener(@Nullable OnInfoWindowClickListener listener) { - mOnInfoWindowClickListener = listener; + onInfoWindowClickListener = listener; } /** @@ -1554,7 +1595,7 @@ public void setOnInfoWindowClickListener(@Nullable OnInfoWindowClickListener lis */ @UiThread public OnInfoWindowClickListener getOnInfoWindowClickListener() { - return mOnInfoWindowClickListener; + return onInfoWindowClickListener; } /** @@ -1564,7 +1605,7 @@ public OnInfoWindowClickListener getOnInfoWindowClickListener() { */ @UiThread public void setOnInfoWindowLongClickListener(@Nullable OnInfoWindowLongClickListener listener) { - mOnInfoWindowLongClickListener = listener; + onInfoWindowLongClickListener = listener; } /** @@ -1573,11 +1614,11 @@ public void setOnInfoWindowLongClickListener(@Nullable OnInfoWindowLongClickList * @return Current active InfoWindow long Click Listener */ public OnInfoWindowLongClickListener getOnInfoWindowLongClickListener() { - return mOnInfoWindowLongClickListener; + return onInfoWindowLongClickListener; } public void setOnInfoWindowCloseListener(@Nullable OnInfoWindowCloseListener listener) { - mOnInfoWindowCloseListener = listener; + onInfoWindowCloseListener = listener; } /** @@ -1587,7 +1628,7 @@ public void setOnInfoWindowCloseListener(@Nullable OnInfoWindowCloseListener lis */ @UiThread public OnInfoWindowCloseListener getOnInfoWindowCloseListener() { - return mOnInfoWindowCloseListener; + return onInfoWindowCloseListener; } // @@ -1601,7 +1642,7 @@ public OnInfoWindowCloseListener getOnInfoWindowCloseListener() { */ @UiThread public boolean isMyLocationEnabled() { - return mMyLocationEnabled; + return myLocationEnabled; } /** @@ -1618,13 +1659,13 @@ public boolean isMyLocationEnabled() { */ @UiThread public void setMyLocationEnabled(boolean enabled) { - if (!mMapView.isPermissionsAccepted()) { + if (!mapView.isPermissionsAccepted()) { Log.e(MapboxConstants.TAG, "Could not activate user location tracking: " + "user did not accept the permission or permissions were not requested."); return; } - mMyLocationEnabled = enabled; - mMapView.setMyLocationEnabled(enabled); + myLocationEnabled = enabled; + mapView.setMyLocationEnabled(enabled); } /** @@ -1635,7 +1676,7 @@ public void setMyLocationEnabled(boolean enabled) { @UiThread @Nullable public Location getMyLocation() { - return mMapView.getMyLocation(); + return mapView.getMyLocation(); } /** @@ -1647,7 +1688,7 @@ public Location getMyLocation() { */ @UiThread public void setOnMyLocationChangeListener(@Nullable MapboxMap.OnMyLocationChangeListener listener) { - mMapView.setOnMyLocationChangeListener(listener); + mapView.setOnMyLocationChangeListener(listener); } /** @@ -1658,12 +1699,12 @@ public void setOnMyLocationChangeListener(@Nullable MapboxMap.OnMyLocationChange */ @UiThread public void setOnMyLocationTrackingModeChangeListener(@Nullable MapboxMap.OnMyLocationTrackingModeChangeListener listener) { - mOnMyLocationTrackingModeChangeListener = listener; + onMyLocationTrackingModeChangeListener = listener; } // used by MapView MapboxMap.OnMyLocationTrackingModeChangeListener getOnMyLocationTrackingModeChangeListener() { - return mOnMyLocationTrackingModeChangeListener; + return onMyLocationTrackingModeChangeListener; } /** @@ -1674,24 +1715,24 @@ MapboxMap.OnMyLocationTrackingModeChangeListener getOnMyLocationTrackingModeChan */ @UiThread public void setOnMyBearingTrackingModeChangeListener(@Nullable OnMyBearingTrackingModeChangeListener listener) { - mOnMyBearingTrackingModeChangeListener = listener; + onMyBearingTrackingModeChangeListener = listener; } // used by MapView OnMyBearingTrackingModeChangeListener getOnMyBearingTrackingModeChangeListener() { - return mOnMyBearingTrackingModeChangeListener; + return onMyBearingTrackingModeChangeListener; } MapView getMapView() { - return mMapView; + return mapView; } void setUiSettings(UiSettings uiSettings) { - mUiSettings = uiSettings; + this.uiSettings = uiSettings; } void setProjection(Projection projection) { - mProjection = projection; + this.projection = projection; } // @@ -1702,7 +1743,7 @@ void setProjection(Projection projection) { * Triggers an invalidation of the map view. */ public void invalidate() { - mMapView.invalidate(); + mapView.invalidate(); } /** @@ -1713,7 +1754,7 @@ public void invalidate() { */ @UiThread public void snapshot(@NonNull SnapshotReadyCallback callback, @Nullable final Bitmap bitmap) { - mMapView.snapshot(callback, bitmap); + mapView.snapshot(callback, bitmap); } /** @@ -1723,7 +1764,7 @@ public void snapshot(@NonNull SnapshotReadyCallback callback, @Nullable final Bi */ @UiThread public void snapshot(@NonNull SnapshotReadyCallback callback) { - mMapView.snapshot(callback, null); + mapView.snapshot(callback, null); } /** @@ -1736,7 +1777,7 @@ public void snapshot(@NonNull SnapshotReadyCallback callback) { @UiThread @NonNull public List queryRenderedFeatures(@NonNull PointF coordinates, @Nullable String... layerIds) { - return mMapView.getNativeMapView().queryRenderedFeatures(coordinates, layerIds); + return mapView.getNativeMapView().queryRenderedFeatures(coordinates, layerIds); } /** @@ -1749,7 +1790,7 @@ public List queryRenderedFeatures(@NonNull PointF coordinates, @Nullabl @UiThread @NonNull public List queryRenderedFeatures(@NonNull RectF coordinates, @Nullable String... layerIds) { - return mMapView.getNativeMapView().queryRenderedFeatures(coordinates, layerIds); + return mapView.getNativeMapView().queryRenderedFeatures(coordinates, layerIds); } @@ -2126,7 +2167,7 @@ private class MapChangeCameraPositionListener implements MapView.OnMapChangedLis @Override public void onMapChanged(@MapView.MapChange int change) { if (change >= MapView.REGION_WILL_CHANGE && change <= MapView.REGION_DID_CHANGE_ANIMATED) { - mInvalidCameraPosition = true; + invalidCameraPosition = true; long currentTime = SystemClock.elapsedRealtime(); if (currentTime < mPreviousUpdateTimestamp) { return; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java index 1693b5b3406..1c39790ebfb 100755 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java @@ -14,7 +14,6 @@ import com.mapbox.mapboxsdk.annotations.Polygon; import com.mapbox.mapboxsdk.annotations.Polyline; import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.geometry.ProjectedMeters; import com.mapbox.mapboxsdk.offline.OfflineManager; import com.mapbox.mapboxsdk.style.layers.Layer; @@ -38,13 +37,13 @@ final class NativeMapView { // Instance members // - boolean mDestroyed = false; + boolean destroyed = false; // Holds the pointer to JNI NativeMapView - private long mNativeMapViewPtr = 0; + private long nativeMapViewPtr = 0; // Used for callbacks - private MapView mMapView; + private MapView mapView; private final float pixelRatio; @@ -88,8 +87,8 @@ public NativeMapView(MapView mapView) { throw new IllegalArgumentException("totalMemory cannot be negative."); } - mMapView = mapView; - mNativeMapViewPtr = nativeCreate(cachePath, dataPath, apkPath, pixelRatio, availableProcessors, totalMemory); + this.mapView = mapView; + nativeMapViewPtr = nativeCreate(cachePath, dataPath, apkPath, pixelRatio, availableProcessors, totalMemory); } // @@ -97,46 +96,46 @@ public NativeMapView(MapView mapView) { // public void destroy() { - nativeDestroy(mNativeMapViewPtr); - mNativeMapViewPtr = 0; - mMapView = null; - mDestroyed = true; + nativeDestroy(nativeMapViewPtr); + nativeMapViewPtr = 0; + mapView = null; + destroyed = true; } public boolean wasDestroyed() { - return mDestroyed; + return destroyed; } public void initializeDisplay() { - nativeInitializeDisplay(mNativeMapViewPtr); + nativeInitializeDisplay(nativeMapViewPtr); } public void terminateDisplay() { - nativeTerminateDisplay(mNativeMapViewPtr); + nativeTerminateDisplay(nativeMapViewPtr); } public void initializeContext() { - nativeInitializeContext(mNativeMapViewPtr); + nativeInitializeContext(nativeMapViewPtr); } public void terminateContext() { - nativeTerminateContext(mNativeMapViewPtr); + nativeTerminateContext(nativeMapViewPtr); } public void createSurface(Surface surface) { - nativeCreateSurface(mNativeMapViewPtr, surface); + nativeCreateSurface(nativeMapViewPtr, surface); } public void destroySurface() { - nativeDestroySurface(mNativeMapViewPtr); + nativeDestroySurface(nativeMapViewPtr); } public void update() { - nativeUpdate(mNativeMapViewPtr); + nativeUpdate(nativeMapViewPtr); } public void render() { - nativeRender(mNativeMapViewPtr); + nativeRender(nativeMapViewPtr); } public void resizeView(int width, int height) { @@ -157,7 +156,7 @@ public void resizeView(int width, int height) { throw new IllegalArgumentException( "height cannot be greater than 65535."); } - nativeViewResize(mNativeMapViewPtr, width, height); + nativeViewResize(nativeMapViewPtr, width, height); } public void resizeFramebuffer(int fbWidth, int fbHeight) { @@ -178,55 +177,55 @@ public void resizeFramebuffer(int fbWidth, int fbHeight) { throw new IllegalArgumentException( "fbHeight cannot be greater than 65535."); } - nativeFramebufferResize(mNativeMapViewPtr, fbWidth, fbHeight); + nativeFramebufferResize(nativeMapViewPtr, fbWidth, fbHeight); } public void addClass(String clazz) { - nativeAddClass(mNativeMapViewPtr, clazz); + nativeAddClass(nativeMapViewPtr, clazz); } public void removeClass(String clazz) { - nativeRemoveClass(mNativeMapViewPtr, clazz); + nativeRemoveClass(nativeMapViewPtr, clazz); } public boolean hasClass(String clazz) { - return nativeHasClass(mNativeMapViewPtr, clazz); + return nativeHasClass(nativeMapViewPtr, clazz); } public void setClasses(List classes) { - nativeSetClasses(mNativeMapViewPtr, classes); + nativeSetClasses(nativeMapViewPtr, classes); } public List getClasses() { - return nativeGetClasses(mNativeMapViewPtr); + return nativeGetClasses(nativeMapViewPtr); } public void setStyleUrl(String url) { - nativeSetStyleUrl(mNativeMapViewPtr, url); + nativeSetStyleUrl(nativeMapViewPtr, url); } public void setStyleJson(String newStyleJson) { - nativeSetStyleJson(mNativeMapViewPtr, newStyleJson); + nativeSetStyleJson(nativeMapViewPtr, newStyleJson); } public String getStyleJson() { - return nativeGetStyleJson(mNativeMapViewPtr); + return nativeGetStyleJson(nativeMapViewPtr); } public void setAccessToken(String accessToken) { - nativeSetAccessToken(mNativeMapViewPtr, accessToken); + nativeSetAccessToken(nativeMapViewPtr, accessToken); } public String getAccessToken() { - return nativeGetAccessToken(mNativeMapViewPtr); + return nativeGetAccessToken(nativeMapViewPtr); } public void cancelTransitions() { - nativeCancelTransitions(mNativeMapViewPtr); + nativeCancelTransitions(nativeMapViewPtr); } public void setGestureInProgress(boolean inProgress) { - nativeSetGestureInProgress(mNativeMapViewPtr, inProgress); + nativeSetGestureInProgress(nativeMapViewPtr, inProgress); } public void moveBy(double dx, double dy) { @@ -234,7 +233,7 @@ public void moveBy(double dx, double dy) { } public void moveBy(double dx, double dy, long duration) { - nativeMoveBy(mNativeMapViewPtr, dx, dy, duration); + nativeMoveBy(nativeMapViewPtr, dx, dy, duration); } public void setLatLng(LatLng latLng) { @@ -242,23 +241,23 @@ public void setLatLng(LatLng latLng) { } public void setLatLng(LatLng latLng, long duration) { - nativeSetLatLng(mNativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude(), duration); + nativeSetLatLng(nativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude(), duration); } public LatLng getLatLng() { - return nativeGetLatLng(mNativeMapViewPtr); + return nativeGetLatLng(nativeMapViewPtr); } public void resetPosition() { - nativeResetPosition(mNativeMapViewPtr); + nativeResetPosition(nativeMapViewPtr); } public double getPitch() { - return nativeGetPitch(mNativeMapViewPtr); + return nativeGetPitch(nativeMapViewPtr); } public void setPitch(double pitch, long duration) { - nativeSetPitch(mNativeMapViewPtr, pitch, duration); + nativeSetPitch(nativeMapViewPtr, pitch, duration); } public void scaleBy(double ds) { @@ -270,7 +269,7 @@ public void scaleBy(double ds, double cx, double cy) { } public void scaleBy(double ds, double cx, double cy, long duration) { - nativeScaleBy(mNativeMapViewPtr, ds, cx, cy, duration); + nativeScaleBy(nativeMapViewPtr, ds, cx, cy, duration); } public void setScale(double scale) { @@ -282,11 +281,11 @@ public void setScale(double scale, double cx, double cy) { } public void setScale(double scale, double cx, double cy, long duration) { - nativeSetScale(mNativeMapViewPtr, scale, cx, cy, duration); + nativeSetScale(nativeMapViewPtr, scale, cx, cy, duration); } public double getScale() { - return nativeGetScale(mNativeMapViewPtr); + return nativeGetScale(nativeMapViewPtr); } public void setZoom(double zoom) { @@ -294,31 +293,31 @@ public void setZoom(double zoom) { } public void setZoom(double zoom, long duration) { - nativeSetZoom(mNativeMapViewPtr, zoom, duration); + nativeSetZoom(nativeMapViewPtr, zoom, duration); } public double getZoom() { - return nativeGetZoom(mNativeMapViewPtr); + return nativeGetZoom(nativeMapViewPtr); } public void resetZoom() { - nativeResetZoom(mNativeMapViewPtr); + nativeResetZoom(nativeMapViewPtr); } public void setMinZoom(double zoom) { - nativeSetMinZoom(mNativeMapViewPtr, zoom); + nativeSetMinZoom(nativeMapViewPtr, zoom); } public double getMinZoom() { - return nativeGetMinZoom(mNativeMapViewPtr); + return nativeGetMinZoom(nativeMapViewPtr); } public void setMaxZoom(double zoom) { - nativeSetMaxZoom(mNativeMapViewPtr, zoom); + nativeSetMaxZoom(nativeMapViewPtr, zoom); } public double getMaxZoom() { - return nativeGetMaxZoom(mNativeMapViewPtr); + return nativeGetMaxZoom(nativeMapViewPtr); } public void rotateBy(double sx, double sy, double ex, double ey) { @@ -327,11 +326,11 @@ public void rotateBy(double sx, double sy, double ex, double ey) { public void rotateBy(double sx, double sy, double ex, double ey, long duration) { - nativeRotateBy(mNativeMapViewPtr, sx, sy, ex, ey, duration); + nativeRotateBy(nativeMapViewPtr, sx, sy, ex, ey, duration); } public void setContentPadding(double top, double left, double bottom, double right) { - nativeSetContentPadding(mNativeMapViewPtr, top, left, bottom, right); + nativeSetContentPadding(nativeMapViewPtr, top, left, bottom, right); } public void setBearing(double degrees) { @@ -339,63 +338,63 @@ public void setBearing(double degrees) { } public void setBearing(double degrees, long duration) { - nativeSetBearing(mNativeMapViewPtr, degrees, duration); + nativeSetBearing(nativeMapViewPtr, degrees, duration); } public void setBearing(double degrees, double cx, double cy) { - nativeSetBearingXY(mNativeMapViewPtr, degrees, cx, cy); + nativeSetBearingXY(nativeMapViewPtr, degrees, cx, cy); } public double getBearing() { - return nativeGetBearing(mNativeMapViewPtr); + return nativeGetBearing(nativeMapViewPtr); } public void resetNorth() { - nativeResetNorth(mNativeMapViewPtr); + nativeResetNorth(nativeMapViewPtr); } public long addMarker(Marker marker) { Marker[] markers = {marker}; - return nativeAddMarkers(mNativeMapViewPtr, markers)[0]; + return nativeAddMarkers(nativeMapViewPtr, markers)[0]; } public long[] addMarkers(List markers) { - return nativeAddMarkers(mNativeMapViewPtr, markers.toArray(new Marker[markers.size()])); + return nativeAddMarkers(nativeMapViewPtr, markers.toArray(new Marker[markers.size()])); } public long addPolyline(Polyline polyline) { Polyline[] polylines = {polyline}; - return nativeAddPolylines(mNativeMapViewPtr, polylines)[0]; + return nativeAddPolylines(nativeMapViewPtr, polylines)[0]; } public long[] addPolylines(List polylines) { - return nativeAddPolylines(mNativeMapViewPtr, polylines.toArray(new Polyline[polylines.size()])); + return nativeAddPolylines(nativeMapViewPtr, polylines.toArray(new Polyline[polylines.size()])); } public long addPolygon(Polygon polygon) { Polygon[] polygons = {polygon}; - return nativeAddPolygons(mNativeMapViewPtr, polygons)[0]; + return nativeAddPolygons(nativeMapViewPtr, polygons)[0]; } public long[] addPolygons(List polygons) { - return nativeAddPolygons(mNativeMapViewPtr, polygons.toArray(new Polygon[polygons.size()])); + return nativeAddPolygons(nativeMapViewPtr, polygons.toArray(new Polygon[polygons.size()])); } public void updateMarker(Marker marker) { LatLng position = marker.getPosition(); Icon icon = marker.getIcon(); - nativeUpdateMarker(mNativeMapViewPtr, marker.getId(), position.getLatitude(), position.getLongitude(), icon.getId()); + nativeUpdateMarker(nativeMapViewPtr, marker.getId(), position.getLatitude(), position.getLongitude(), icon.getId()); } public void updatePolygon(Polygon polygon) { //TODO remove new id assignment, https://github.com/mapbox/mapbox-gl-native/issues/5844 - long newId = nativeUpdatePolygon(mNativeMapViewPtr, polygon.getId(), polygon); + long newId = nativeUpdatePolygon(nativeMapViewPtr, polygon.getId(), polygon); polygon.setId(newId); } public void updatePolyline(Polyline polyline) { //TODO remove new id assignment, https://github.com/mapbox/mapbox-gl-native/issues/5844 - long newId = nativeUpdatePolyline(mNativeMapViewPtr, polyline.getId(), polyline); + long newId = nativeUpdatePolyline(nativeMapViewPtr, polyline.getId(), polyline); polyline.setId(newId); } @@ -405,120 +404,120 @@ public void removeAnnotation(long id) { } public void removeAnnotations(long[] ids) { - nativeRemoveAnnotations(mNativeMapViewPtr, ids); + nativeRemoveAnnotations(nativeMapViewPtr, ids); } public long[] queryPointAnnotations(RectF rect) { - return nativeQueryPointAnnotations(mNativeMapViewPtr, rect); + return nativeQueryPointAnnotations(nativeMapViewPtr, rect); } public void addAnnotationIcon(String symbol, int width, int height, float scale, byte[] pixels) { - nativeAddAnnotationIcon(mNativeMapViewPtr, symbol, width, height, scale, pixels); + nativeAddAnnotationIcon(nativeMapViewPtr, symbol, width, height, scale, pixels); } public void setVisibleCoordinateBounds(LatLng[] coordinates, RectF padding, double direction, long duration) { - nativeSetVisibleCoordinateBounds(mNativeMapViewPtr, coordinates, padding, direction, duration); + nativeSetVisibleCoordinateBounds(nativeMapViewPtr, coordinates, padding, direction, duration); } public void onLowMemory() { - nativeOnLowMemory(mNativeMapViewPtr); + nativeOnLowMemory(nativeMapViewPtr); } public void setDebug(boolean debug) { - nativeSetDebug(mNativeMapViewPtr, debug); + nativeSetDebug(nativeMapViewPtr, debug); } public void cycleDebugOptions() { - nativeToggleDebug(mNativeMapViewPtr); + nativeToggleDebug(nativeMapViewPtr); } public boolean getDebug() { - return nativeGetDebug(mNativeMapViewPtr); + return nativeGetDebug(nativeMapViewPtr); } public boolean isFullyLoaded() { - return nativeIsFullyLoaded(mNativeMapViewPtr); + return nativeIsFullyLoaded(nativeMapViewPtr); } public void setReachability(boolean status) { - nativeSetReachability(mNativeMapViewPtr, status); + nativeSetReachability(nativeMapViewPtr, status); } public double getMetersPerPixelAtLatitude(double lat, double zoom) { - return nativeGetMetersPerPixelAtLatitude(mNativeMapViewPtr, lat, zoom); + return nativeGetMetersPerPixelAtLatitude(nativeMapViewPtr, lat, zoom); } public ProjectedMeters projectedMetersForLatLng(LatLng latLng) { - return nativeProjectedMetersForLatLng(mNativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude()); + return nativeProjectedMetersForLatLng(nativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude()); } public LatLng latLngForProjectedMeters(ProjectedMeters projectedMeters) { - return nativeLatLngForProjectedMeters(mNativeMapViewPtr, projectedMeters.getNorthing(), projectedMeters.getEasting()); + return nativeLatLngForProjectedMeters(nativeMapViewPtr, projectedMeters.getNorthing(), projectedMeters.getEasting()); } public PointF pixelForLatLng(LatLng latLng) { - return nativePixelForLatLng(mNativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude()); + return nativePixelForLatLng(nativeMapViewPtr, latLng.getLatitude(), latLng.getLongitude()); } public LatLng latLngForPixel(PointF pixel) { - return nativeLatLngForPixel(mNativeMapViewPtr, pixel.x, pixel.y); + return nativeLatLngForPixel(nativeMapViewPtr, pixel.x, pixel.y); } public double getTopOffsetPixelsForAnnotationSymbol(String symbolName) { - return nativeGetTopOffsetPixelsForAnnotationSymbol(mNativeMapViewPtr, symbolName); + return nativeGetTopOffsetPixelsForAnnotationSymbol(nativeMapViewPtr, symbolName); } public void jumpTo(double angle, LatLng center, double pitch, double zoom) { - nativeJumpTo(mNativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), pitch, zoom); + nativeJumpTo(nativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), pitch, zoom); } public void easeTo(double angle, LatLng center, long duration, double pitch, double zoom, boolean easingInterpolator) { - nativeEaseTo(mNativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom, easingInterpolator); + nativeEaseTo(nativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom, easingInterpolator); } public void flyTo(double angle, LatLng center, long duration, double pitch, double zoom) { - nativeFlyTo(mNativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom); + nativeFlyTo(nativeMapViewPtr, angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom); } public double[] getCameraValues() { - return nativeGetCameraValues(mNativeMapViewPtr); + return nativeGetCameraValues(nativeMapViewPtr); } // Runtime style Api public Layer getLayer(String layerId) { - return nativeGetLayer(mNativeMapViewPtr, layerId); + return nativeGetLayer(nativeMapViewPtr, layerId); } public void addLayer(@NonNull Layer layer, @Nullable String before) { - nativeAddLayer(mNativeMapViewPtr, layer.getNativePtr(), before); + nativeAddLayer(nativeMapViewPtr, layer.getNativePtr(), before); layer.invalidate(); } public void removeLayer(@NonNull String layerId) throws NoSuchLayerException { - nativeRemoveLayer(mNativeMapViewPtr, layerId); + nativeRemoveLayer(nativeMapViewPtr, layerId); } public void addSource(@NonNull Source source) { - nativeAddSource(mNativeMapViewPtr, source.getId(), source); + nativeAddSource(nativeMapViewPtr, source.getId(), source); } public void removeSource(@NonNull String sourceId) throws NoSuchSourceException { - nativeRemoveSource(mNativeMapViewPtr, sourceId); + nativeRemoveSource(nativeMapViewPtr, sourceId); } // Feature querying @NonNull public List queryRenderedFeatures(PointF coordinates, String... layerIds) { - Feature[] features = nativeQueryRenderedFeaturesForPoint(mNativeMapViewPtr, coordinates.x / pixelRatio, coordinates.y / pixelRatio, layerIds); + Feature[] features = nativeQueryRenderedFeaturesForPoint(nativeMapViewPtr, coordinates.x / pixelRatio, coordinates.y / pixelRatio, layerIds); return features != null ? Arrays.asList(features) : new ArrayList(); } @NonNull public List queryRenderedFeatures(RectF coordinates, String... layerIds) { Feature[] features = nativeQueryRenderedFeaturesForBox( - mNativeMapViewPtr, + nativeMapViewPtr, coordinates.left / pixelRatio, coordinates.top / pixelRatio, coordinates.right / pixelRatio, @@ -528,7 +527,7 @@ public List queryRenderedFeatures(RectF coordinates, String... layerIds } public void scheduleTakeSnapshot() { - nativeScheduleTakeSnapshot(mNativeMapViewPtr); + nativeScheduleTakeSnapshot(nativeMapViewPtr); } // @@ -536,19 +535,19 @@ public void scheduleTakeSnapshot() { // protected void onInvalidate() { - mMapView.onInvalidate(); + mapView.onInvalidate(); } protected void onMapChanged(int rawChange) { - mMapView.onMapChanged(rawChange); + mapView.onMapChanged(rawChange); } protected void onFpsChanged(double fps) { - mMapView.onFpsChanged(fps); + mapView.onFpsChanged(fps); } protected void onSnapshotReady(byte[] bytes) { - mMapView.onSnapshotReady(bytes); + mapView.onSnapshotReady(bytes); } // diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java index a41b2606a5d..17d4a7c6572 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java @@ -15,10 +15,10 @@ */ public class Projection { - private MapView mMapView; + private MapView mapView; Projection(@NonNull MapView mapView) { - this.mMapView = mapView; + this.mapView = mapView; } /** @@ -32,7 +32,7 @@ public class Projection { * @return The distance measured in meters. */ public double getMetersPerPixelAtLatitude(@FloatRange(from = -90, to = 90) double latitude) { - return mMapView.getMetersPerPixelAtLatitude(latitude); + return mapView.getMetersPerPixelAtLatitude(latitude); } /** @@ -45,7 +45,7 @@ public double getMetersPerPixelAtLatitude(@FloatRange(from = -90, to = 90) doubl * the given screen point does not intersect the ground plane. */ public LatLng fromScreenLocation(PointF point) { - return mMapView.fromScreenLocation(point); + return mapView.fromScreenLocation(point); } /** @@ -57,10 +57,10 @@ public LatLng fromScreenLocation(PointF point) { public VisibleRegion getVisibleRegion() { LatLngBounds.Builder builder = new LatLngBounds.Builder(); - float left = mMapView.getContentPaddingLeft(); - float right = mMapView.getWidth() - mMapView.getContentPaddingRight(); - float top = mMapView.getContentPaddingTop(); - float bottom = mMapView.getHeight() - mMapView.getContentPaddingBottom(); + float left = mapView.getContentPaddingLeft(); + float right = mapView.getWidth() - mapView.getContentPaddingRight(); + float top = mapView.getContentPaddingTop(); + float bottom = mapView.getHeight() - mapView.getContentPaddingBottom(); LatLng topLeft = fromScreenLocation(new PointF(left, top)); LatLng topRight = fromScreenLocation(new PointF(right, top)); @@ -84,7 +84,7 @@ public VisibleRegion getVisibleRegion() { * @return A Point representing the screen location in screen pixels. */ public PointF toScreenLocation(LatLng location) { - return mMapView.toScreenLocation(location); + return mapView.toScreenLocation(location); } /** @@ -94,6 +94,6 @@ public PointF toScreenLocation(LatLng location) { * @return zoom level that fits the MapView. */ public double calculateZoom(float minScale) { - return Math.log(mMapView.getScale() * minScale) / Math.log(2); + return Math.log(mapView.getScale() * minScale) / Math.log(2); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java index 3d967277587..2a52ff24f02 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java @@ -31,8 +31,8 @@ */ public class SupportMapFragment extends Fragment { - private MapView mMap; - private OnMapReadyCallback mOnMapReadyCallback; + private MapView map; + private OnMapReadyCallback onMapReadyCallback; /** * Creates a MapFragment instance @@ -93,7 +93,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa options.accessToken(token); } } - return mMap = new MapView(inflater.getContext(), options); + return map = new MapView(inflater.getContext(), options); } /** @@ -136,7 +136,7 @@ private String getToken(@NonNull Context context) { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - mMap.onCreate(savedInstanceState); + map.onCreate(savedInstanceState); } /** @@ -145,7 +145,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) { @Override public void onStart() { super.onStart(); - mMap.getMapAsync(mOnMapReadyCallback); + map.getMapAsync(onMapReadyCallback); } /** @@ -154,7 +154,7 @@ public void onStart() { @Override public void onResume() { super.onResume(); - mMap.onResume(); + map.onResume(); } /** @@ -163,7 +163,7 @@ public void onResume() { @Override public void onPause() { super.onPause(); - mMap.onPause(); + map.onPause(); } /** @@ -174,7 +174,7 @@ public void onPause() { @Override public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); - mMap.onSaveInstanceState(outState); + map.onSaveInstanceState(outState); } /** @@ -191,7 +191,7 @@ public void onStop() { @Override public void onLowMemory() { super.onLowMemory(); - mMap.onLowMemory(); + map.onLowMemory(); } /** @@ -200,7 +200,7 @@ public void onLowMemory() { @Override public void onDestroyView() { super.onDestroyView(); - mMap.onDestroy(); + map.onDestroy(); } /** @@ -209,6 +209,6 @@ public void onDestroyView() { * @param onMapReadyCallback The callback to be invoked. */ public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) { - mOnMapReadyCallback = onMapReadyCallback; + this.onMapReadyCallback = onMapReadyCallback; } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java index 794a4f60869..d7d3e77f69c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java @@ -25,9 +25,9 @@ */ public final class CompassView extends ImageView { - private Timer mNorthTimer; - private double mDirection = 0.0f; - private ViewPropertyAnimatorCompat mFadeAnimator; + private Timer northTimer; + private double direction = 0.0f; + private ViewPropertyAnimatorCompat fadeAnimator; public CompassView(Context context) { super(context); @@ -65,33 +65,33 @@ public void setMapboxMap(@NonNull MapboxMap mapboxMap){ public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (enabled) { - if (mDirection != 0.0) { - if (mNorthTimer != null){ - mNorthTimer.cancel(); - mNorthTimer = null; + if (direction != 0.0) { + if (northTimer != null){ + northTimer.cancel(); + northTimer = null; } - if (mFadeAnimator != null) { - mFadeAnimator.cancel(); + if (fadeAnimator != null) { + fadeAnimator.cancel(); } - mFadeAnimator = null; + fadeAnimator = null; setAlpha(1.0f); setVisibility(View.VISIBLE); } } else { - if (mNorthTimer != null){ - mNorthTimer.cancel(); - mNorthTimer = null; + if (northTimer != null){ + northTimer.cancel(); + northTimer = null; } - if (mFadeAnimator != null) { - mFadeAnimator.cancel(); + if (fadeAnimator != null) { + fadeAnimator.cancel(); } - mFadeAnimator = null; + fadeAnimator = null; setVisibility(View.INVISIBLE); } } public void update(double direction) { - mDirection = direction; + this.direction = direction; setRotation((float) direction); if (!isEnabled()) { @@ -103,26 +103,26 @@ public void update(double direction) { return; } - if (mNorthTimer == null) { - if (mFadeAnimator != null) { - mFadeAnimator.cancel(); + if (northTimer == null) { + if (fadeAnimator != null) { + fadeAnimator.cancel(); } - mFadeAnimator = null; + fadeAnimator = null; - mNorthTimer = new Timer("CompassView North timer"); - mNorthTimer.schedule(new TimerTask() { + northTimer = new Timer("CompassView North timer"); + northTimer.schedule(new TimerTask() { @Override public void run() { post(new Runnable() { @Override public void run() { setAlpha(1.0f); - mFadeAnimator = ViewCompat.animate(CompassView.this).alpha(0.0f).setDuration(1000).withLayer(); - mFadeAnimator.setListener(new ViewPropertyAnimatorListenerAdapter() { + fadeAnimator = ViewCompat.animate(CompassView.this).alpha(0.0f).setDuration(1000).withLayer(); + fadeAnimator.setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { setVisibility(View.INVISIBLE); - mNorthTimer = null; + northTimer = null; } }); } @@ -131,12 +131,12 @@ public void onAnimationEnd(View view) { }, 1000); } } else { - if (mNorthTimer != null){ - mNorthTimer.cancel(); - mNorthTimer = null; + if (northTimer != null){ + northTimer.cancel(); + northTimer = null; } - if (mFadeAnimator != null) { - mFadeAnimator.cancel(); + if (fadeAnimator != null) { + fadeAnimator.cancel(); } setAlpha(1.0f); setVisibility(View.VISIBLE); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java index 80d5ff7db08..4809931ec40 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java @@ -41,7 +41,7 @@ public class OfflineManager { private final static long DEFAULT_MAX_CACHE_SIZE = 50 * 1024 * 1024; // Holds the pointer to JNI DefaultFileSource - private long mDefaultFileSourcePtr = 0; + private long defaultFileSourcePtr = 0; // Makes sure callbacks come back to the main thread private Handler handler; @@ -97,10 +97,10 @@ private OfflineManager(Context context) { // Get a pointer to the DefaultFileSource instance String assetRoot = getDatabasePath(context); String cachePath = assetRoot + File.separator + DATABASE_NAME; - mDefaultFileSourcePtr = createDefaultFileSource(cachePath, assetRoot, DEFAULT_MAX_CACHE_SIZE); + defaultFileSourcePtr = createDefaultFileSource(cachePath, assetRoot, DEFAULT_MAX_CACHE_SIZE); if (MapboxAccountManager.getInstance() != null) { - setAccessToken(mDefaultFileSourcePtr, MapboxAccountManager.getInstance().getAccessToken()); + setAccessToken(defaultFileSourcePtr, MapboxAccountManager.getInstance().getAccessToken()); } // Delete any existing previous ambient cache database @@ -200,7 +200,7 @@ public static synchronized OfflineManager getInstance(Context context) { */ @Deprecated public void setAccessToken(String accessToken) { - setAccessToken(mDefaultFileSourcePtr, accessToken); + setAccessToken(defaultFileSourcePtr, accessToken); } /** @@ -211,7 +211,7 @@ public void setAccessToken(String accessToken) { */ @Deprecated public String getAccessToken() { - return getAccessToken(mDefaultFileSourcePtr); + return getAccessToken(defaultFileSourcePtr); } private Handler getHandler() { @@ -232,7 +232,7 @@ private Handler getHandler() { * @param callback the callback to be invoked */ public void listOfflineRegions(@NonNull final ListOfflineRegionsCallback callback) { - listOfflineRegions(mDefaultFileSourcePtr, new ListOfflineRegionsCallback() { + listOfflineRegions(defaultFileSourcePtr, new ListOfflineRegionsCallback() { @Override public void onList(final OfflineRegion[] offlineRegions) { getHandler().post(new Runnable() { @@ -276,7 +276,7 @@ public void createOfflineRegion( @NonNull byte[] metadata, @NonNull final CreateOfflineRegionCallback callback) { - createOfflineRegion(mDefaultFileSourcePtr, definition, metadata, new CreateOfflineRegionCallback() { + createOfflineRegion(defaultFileSourcePtr, definition, metadata, new CreateOfflineRegionCallback() { @Override public void onCreate(final OfflineRegion offlineRegion) { getHandler().post(new Runnable() { @@ -304,7 +304,7 @@ public void run() { * by the Mapbox Terms of Service. */ public void setOfflineMapboxTileCountLimit(long limit) { - setOfflineMapboxTileCountLimit(mDefaultFileSourcePtr, limit); + setOfflineMapboxTileCountLimit(defaultFileSourcePtr, limit); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java index 22cb034f085..acb47671ea0 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineRegion.java @@ -30,18 +30,18 @@ public class OfflineRegion { private OfflineManager offlineManager; // Members - private long mId = 0; - private OfflineRegionDefinition mDefinition = null; + private long id = 0; + private OfflineRegionDefinition definition = null; /** * Arbitrary binary region metadata. The contents are opaque to the SDK implementation; * it just stores and retrieves a byte[]. Check the `OfflineActivity` in the TestApp * for a sample implementation that uses JSON to store an offline region name. */ - private byte[] mMetadata = null; + private byte[] metadata = null; // Holds the pointer to JNI OfflineRegion - private long mOfflineRegionPtr = 0; + private long offlineRegionPtr = 0; // Makes sure callbacks come back to the main thread private Handler handler; @@ -194,15 +194,15 @@ private OfflineRegion() { */ public long getID() { - return mId; + return id; } public OfflineRegionDefinition getDefinition() { - return mDefinition; + return definition; } public byte[] getMetadata() { - return mMetadata; + return metadata; } private Handler getHandler() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java index 282ac9b18c1..f3ed3c1a86e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java @@ -31,10 +31,10 @@ public class AnimatedMarkerActivity extends AppCompatActivity { - private MapView mMapView; - private MapboxMap mapboxMap; + private final static LatLng DUPONT_CIRCLE = new LatLng(38.90962, -77.04341); - private LatLng dupontCircle = new LatLng(38.90962, -77.04341); + private MapView mapView; + private MapboxMap mapboxMap; private Marker passengerMarker = null; private MarkerView carMarker = null; @@ -53,9 +53,9 @@ protected void onCreate(Bundle savedInstanceState) { actionBar.setDisplayShowHomeEnabled(true); } - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull final MapboxMap mapboxMap) { @@ -75,7 +75,7 @@ public void onMapReady(@NonNull final MapboxMap mapboxMap) { private void setupMap() { CameraPosition cameraPosition = new CameraPosition.Builder() - .target(dupontCircle) + .target(DUPONT_CIRCLE) .zoom(15) .build(); mapboxMap.setCameraPosition(cameraPosition); @@ -187,31 +187,31 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } /** diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java index f49407626d1..cbb7f0180f6 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java @@ -44,9 +44,9 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { private MapboxMap mapboxMap; - private MapView mMapView; - private boolean mCustomMarkerView; - private List mLocations; + private MapView mapView; + private boolean customMarkerView; + private List locations; @Override protected void onCreate(Bundle savedInstanceState) { @@ -63,9 +63,9 @@ protected void onCreate(Bundle savedInstanceState) { actionBar.setDisplayShowHomeEnabled(true); } - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { BulkMarkerActivity.this.mapboxMap = mapboxMap; @@ -89,7 +89,7 @@ public void onMapReady(@NonNull MapboxMap mapboxMap) { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { int amount = Integer.valueOf(getResources().getStringArray(R.array.bulk_marker_list)[position]); - if (mLocations == null) { + if (locations == null) { new LoadLocationTask(this, amount).execute(); } else { showMarkers(amount); @@ -97,18 +97,18 @@ public void onItemSelected(AdapterView parent, View view, int position, long } private void onLatLngListLoaded(List latLngs, int amount) { - mLocations = latLngs; + locations = latLngs; showMarkers(amount); } private void showMarkers(int amount) { mapboxMap.clear(); - if (mLocations.size() < amount) { - amount = mLocations.size(); + if (locations.size() < amount) { + amount = locations.size(); } - if (mCustomMarkerView) { + if (customMarkerView) { showViewMarkers(amount); } else { showGlMarkers(amount); @@ -126,8 +126,8 @@ private void showViewMarkers(int amount) { Icon icon = IconFactory.getInstance(this).fromDrawable(drawable); for (int i = 0; i < amount; i++) { - randomIndex = random.nextInt(mLocations.size()); - LatLng latLng = mLocations.get(randomIndex); + randomIndex = random.nextInt(locations.size()); + LatLng latLng = locations.get(randomIndex); mapboxMap.addMarker(new MarkerViewOptions() .position(latLng) .icon(icon) @@ -143,8 +143,8 @@ private void showGlMarkers(int amount) { int randomIndex; for (int i = 0; i < amount; i++) { - randomIndex = random.nextInt(mLocations.size()); - LatLng latLng = mLocations.get(randomIndex); + randomIndex = random.nextInt(locations.size()); + LatLng latLng = locations.get(randomIndex); markerOptionsList.add(new MarkerOptions() .position(latLng) .title(String.valueOf(i)) @@ -162,31 +162,31 @@ public void onNothingSelected(AdapterView parent) { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } @Override @@ -204,7 +204,7 @@ private class FabClickListener implements View.OnClickListener { @Override public void onClick(final View v) { if (mapboxMap != null) { - mCustomMarkerView = true; + customMarkerView = true; // remove fab v.animate().alpha(0).setListener(new AnimatorListenerAdapter() { @@ -222,13 +222,13 @@ public void onAnimationEnd(Animator animation) { showMarkers(amount); } - mMapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { + mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { @Override public void onMapChanged(@MapView.MapChange int change) { if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) { if (!mapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) { TextView viewCountView = (TextView) findViewById(R.id.countView); - viewCountView.setText("ViewCache size " + (mMapView.getChildCount() - 5)); + viewCountView.setText("ViewCache size " + (mapView.getChildCount() - 5)); } } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java index ce86a780995..63eae4a5faf 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java @@ -42,7 +42,7 @@ public class MarkerViewActivity extends AppCompatActivity { private MapboxMap mapboxMap; - private MapView mMapView; + private MapView mapView; private MarkerView movingMarkerOne, movingMarkerTwo; private Random randomAnimator = new Random(); @@ -74,9 +74,9 @@ protected void onCreate(Bundle savedInstanceState) { } final TextView viewCountView = (TextView) findViewById(R.id.countView); - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { MarkerViewActivity.this.mapboxMap = mapboxMap; @@ -131,12 +131,12 @@ public void onMapReady(@NonNull MapboxMap mapboxMap) { markerViewManager.addMarkerViewAdapter(new TextAdapter(MarkerViewActivity.this, mapboxMap)); // add a change listener to validate the size of amount of child views - mMapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { + mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { @Override public void onMapChanged(@MapView.MapChange int change) { if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) { if (!markerViewManager.getMarkerViewAdapters().isEmpty() && viewCountView != null) { - viewCountView.setText("ViewCache size " + (mMapView.getChildCount() - 5)); + viewCountView.setText("ViewCache size " + (mapView.getChildCount() - 5)); } } } @@ -153,13 +153,13 @@ public boolean onMarkerClick(@NonNull Marker marker, @NonNull View view, @NonNul movingMarkerOne = MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions() .position(CarLocation.CAR_0_LNGS[0]) - .icon(IconFactory.getInstance(mMapView.getContext()) + .icon(IconFactory.getInstance(mapView.getContext()) .fromResource(R.drawable.ic_chelsea)) ); movingMarkerTwo = mapboxMap.addMarker(new MarkerViewOptions() .position(CarLocation.CAR_1_LNGS[0]) - .icon(IconFactory.getInstance(mMapView.getContext()) + .icon(IconFactory.getInstance(mapView.getContext()) .fromResource(R.drawable.ic_arsenal)) ); } @@ -366,31 +366,31 @@ private static class ViewHolder { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java index 7dec4e90389..3c37cf90496 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java @@ -37,9 +37,9 @@ public class PolylineActivity extends AppCompatActivity { private static final float PARTIAL_ALPHA = 0.5f; private static final float NO_ALPHA = 0.0f; - private List mPolylines; - private ArrayList mPolylineOptions = new ArrayList<>(); - private MapView mMapView; + private List polylines; + private ArrayList polylineOptions = new ArrayList<>(); + private MapView mapView; private MapboxMap mapboxMap; private boolean fullAlpha = true; @@ -62,18 +62,18 @@ protected void onCreate(Bundle savedInstanceState) { } if (savedInstanceState != null) { - mPolylineOptions = savedInstanceState.getParcelableArrayList(STATE_POLYLINE_OPTIONS); + polylineOptions = savedInstanceState.getParcelableArrayList(STATE_POLYLINE_OPTIONS); } else { - mPolylineOptions.addAll(getAllPolylines()); + polylineOptions.addAll(getAllPolylines()); } - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { PolylineActivity.this.mapboxMap = mapboxMap; - mPolylines = mapboxMap.addPolylines(mPolylineOptions); + polylines = mapboxMap.addPolylines(polylineOptions); } }); @@ -83,18 +83,18 @@ public void onMapReady(@NonNull MapboxMap mapboxMap) { @Override public void onClick(View v) { if (mapboxMap != null) { - if (mPolylines != null && mPolylines.size() > 0) { - if (mPolylines.size() == 1) { + if (polylines != null && polylines.size() > 0) { + if (polylines.size() == 1) { // test for removing annotation - mapboxMap.removeAnnotation(mPolylines.get(0)); + mapboxMap.removeAnnotation(polylines.get(0)); } else { // test for removing annotations - mapboxMap.removeAnnotations(mPolylines); + mapboxMap.removeAnnotations(polylines); } } - mPolylineOptions.clear(); - mPolylineOptions.addAll(getRandomLine()); - mPolylines = mapboxMap.addPolylines(mPolylineOptions); + polylineOptions.clear(); + polylineOptions.addAll(getRandomLine()); + polylines = mapboxMap.addPolylines(polylineOptions); } } @@ -132,32 +132,32 @@ public List getRandomLine() { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); - outState.putParcelableArrayList(STATE_POLYLINE_OPTIONS, mPolylineOptions); + mapView.onSaveInstanceState(outState); + outState.putParcelableArrayList(STATE_POLYLINE_OPTIONS, polylineOptions); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } @Override @@ -171,34 +171,34 @@ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_id_remove: // test to remove all annotations - mPolylineOptions.clear(); + polylineOptions.clear(); mapboxMap.clear(); return true; case R.id.action_id_alpha: fullAlpha = !fullAlpha; - for (Polyline p : mPolylines) { + for (Polyline p : polylines) { p.setAlpha(fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA); } return true; case R.id.action_id_color: color = !color; - for (Polyline p : mPolylines) { + for (Polyline p : polylines) { p.setColor(color ? Color.RED : Color.BLUE); } return true; case R.id.action_id_width: width = !width; - for (Polyline p : mPolylines) { + for (Polyline p : polylines) { p.setWidth(width ? 3.0f : 5.0f); } return true; case R.id.action_id_visible: visible = !visible; - for (Polyline p : mPolylines) { + for (Polyline p : polylines) { p.setAlpha(visible ? (fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA) : NO_ALPHA); } return true; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java index 6784ac09149..f131bcd2d9e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java @@ -22,13 +22,12 @@ public class PressForMarkerActivity extends AppCompatActivity { - private MapView mapView; - private MapboxMap mapboxMap; - private ArrayList mMarkerList = new ArrayList<>(); - private static final DecimalFormat LAT_LON_FORMATTER = new DecimalFormat("#.#####"); + private static final String STATE_MARKER_LIST = "markerList"; - private static String STATE_MARKER_LIST = "markerList"; + private MapView mapView; + private MapboxMap mapboxMap; + private ArrayList markerList; @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { @@ -52,6 +51,13 @@ public void onMapReady(final MapboxMap map) { mapboxMap = map; resetMap(); + if (savedInstanceState != null) { + markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST); + mapboxMap.addMarkers(markerList); + }else{ + markerList = new ArrayList<>(); + } + mapboxMap.setOnMapLongClickListener(new MapboxMap.OnMapLongClickListener() { @Override public void onMapLongClick(@NonNull LatLng point) { @@ -65,15 +71,12 @@ public void onMapLongClick(@NonNull LatLng point) { .title(title) .snippet(snippet); - mMarkerList.add(marker); + markerList.add(marker); mapboxMap.addMarker(marker); } }); - if (savedInstanceState != null) { - mMarkerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST); - mapboxMap.addMarkers(mMarkerList); - } + } }); } @@ -96,7 +99,7 @@ protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); - outState.putParcelableArrayList(STATE_MARKER_LIST, mMarkerList); + outState.putParcelableArrayList(STATE_MARKER_LIST, markerList); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java index 477ef64e867..ae1e2279492 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java @@ -21,7 +21,7 @@ public class ManualZoomActivity extends AppCompatActivity { private MapboxMap mapboxMap; - private MapView mMapView; + private MapView mapView; @Override protected void onCreate(Bundle savedInstanceState) { @@ -37,10 +37,10 @@ protected void onCreate(Bundle savedInstanceState) { actionBar.setDisplayShowHomeEnabled(true); } - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.setStyleUrl(Style.SATELLITE); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView = (MapView) findViewById(R.id.mapView); + mapView.setStyleUrl(Style.SATELLITE); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull final MapboxMap mapboxMap) { ManualZoomActivity.this.mapboxMap = mapboxMap; @@ -94,30 +94,30 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java index c725d9a7d71..fb3a7e4887e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java @@ -34,7 +34,7 @@ public class DirectionsActivity extends AppCompatActivity { private final static String LOG_TAG = "DirectionsActivity"; - private MapView mMapView; + private MapView mapView; private MapboxMap mapboxMap; @Override @@ -51,9 +51,9 @@ protected void onCreate(Bundle savedInstanceState) { actionBar.setDisplayShowHomeEnabled(true); } - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { DirectionsActivity.this.mapboxMap = mapboxMap; @@ -148,31 +148,31 @@ private void drawRoute(DirectionsRoute route) { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java index 935851c445b..12b9a8f55ee 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java @@ -17,7 +17,7 @@ public class PrintActivity extends AppCompatActivity implements MapboxMap.SnapshotReadyCallback { - private MapView mMapView; + private MapView mapView; private MapboxMap mapboxMap; @Override @@ -34,9 +34,9 @@ protected void onCreate(Bundle savedInstanceState) { actionBar.setDisplayShowHomeEnabled(true); } - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { PrintActivity.this.mapboxMap = mapboxMap; @@ -66,31 +66,31 @@ public void onSnapshotReady(Bitmap snapshot) { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java index f90741ee837..30360889593 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java @@ -21,7 +21,7 @@ public class MapPaddingActivity extends AppCompatActivity { - private MapView mMapView; + private MapView mapView; private MapboxMap mapboxMap; @Override @@ -38,11 +38,11 @@ protected void onCreate(Bundle savedInstanceState) { actionBar.setDisplayShowHomeEnabled(true); } - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.setTag(true); - mMapView.onCreate(savedInstanceState); + mapView = (MapView) findViewById(R.id.mapView); + mapView.setTag(true); + mapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { MapPaddingActivity.this.mapboxMap = mapboxMap; @@ -60,31 +60,31 @@ public void onMapReady(@NonNull MapboxMap mapboxMap) { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SurfaceViewMediaControlActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SurfaceViewMediaControlActivity.java index ed87d75ca07..496ffcba511 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SurfaceViewMediaControlActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SurfaceViewMediaControlActivity.java @@ -21,7 +21,7 @@ public class SurfaceViewMediaControlActivity extends AppCompatActivity implements OnMapReadyCallback { - private MapView mMapView; + private MapView mapView; private MapboxMap mapboxMap; @Override @@ -38,9 +38,9 @@ protected void onCreate(Bundle savedInstanceState) { actionBar.setDisplayShowHomeEnabled(true); } - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(this); + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(this); // add another SurfaceView to the Layout FrameLayout container = (FrameLayout) findViewById(R.id.container); @@ -57,31 +57,31 @@ public void onMapReady(MapboxMap mapboxMap) { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java index 4d5e2552fd0..d79851d0400 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java @@ -46,9 +46,9 @@ public class OfflineActivity extends AppCompatActivity /* * UI elements */ - private MapView mMapView; + private MapView mapView; private MapboxMap mapboxMap; - private ProgressBar mProgressBar; + private ProgressBar progressBar; private Button downloadRegion; private Button listRegions; @@ -57,8 +57,8 @@ public class OfflineActivity extends AppCompatActivity /* * Offline objects */ - private OfflineManager mOfflineManager; - private OfflineRegion mOfflineRegion; + private OfflineManager offlineManager; + private OfflineRegion offlineRegion; @Override protected void onCreate(Bundle savedInstanceState) { @@ -75,10 +75,10 @@ protected void onCreate(Bundle savedInstanceState) { } // Set up map - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.setStyleUrl(Style.MAPBOX_STREETS); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView = (MapView) findViewById(R.id.mapView); + mapView.setStyleUrl(Style.MAPBOX_STREETS); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { Log.d(LOG_TAG, "Map is ready"); @@ -96,7 +96,7 @@ public void onMapReady(@NonNull MapboxMap mapboxMap) { }); // The progress bar - mProgressBar = (ProgressBar) findViewById(R.id.progress_bar); + progressBar = (ProgressBar) findViewById(R.id.progress_bar); // Set up button listeners downloadRegion = (Button) findViewById(R.id.button_download_region); @@ -116,37 +116,37 @@ public void onClick(View v) { }); // Set up the OfflineManager - mOfflineManager = OfflineManager.getInstance(this); + offlineManager = OfflineManager.getInstance(this); } @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } @Override @@ -176,7 +176,7 @@ private void handleListRegions() { Log.d(LOG_TAG, "handleListRegions"); // Query the DB asynchronously - mOfflineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { + offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { @Override public void onList(OfflineRegion[] offlineRegions) { // Check result @@ -261,11 +261,11 @@ public void onDownloadRegionDialogPositiveClick(final String regionName) { } // Create region - mOfflineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() { + offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() { @Override public void onCreate(OfflineRegion offlineRegion) { Log.d(LOG_TAG, "Offline region created: " + regionName); - mOfflineRegion = offlineRegion; + OfflineActivity.this.offlineRegion = offlineRegion; launchDownload(); } @@ -278,7 +278,7 @@ public void onError(String error) { private void launchDownload() { // Set an observer - mOfflineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() { + offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() { @Override public void onStatusChanged(OfflineRegionStatus status) { // Compute a percentage @@ -315,7 +315,7 @@ public void mapboxTileCountLimitExceeded(long limit) { }); // Change the region state - mOfflineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE); + offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE); } /* @@ -329,13 +329,13 @@ private void startProgress() { // Start and show the progress bar isEndNotified = false; - mProgressBar.setIndeterminate(true); - mProgressBar.setVisibility(View.VISIBLE); + progressBar.setIndeterminate(true); + progressBar.setVisibility(View.VISIBLE); } private void setPercentage(final int percentage) { - mProgressBar.setIndeterminate(false); - mProgressBar.setProgress(percentage); + progressBar.setIndeterminate(false); + progressBar.setProgress(percentage); } private void endProgress(final String message) { @@ -348,8 +348,8 @@ private void endProgress(final String message) { // Stop and hide the progress bar isEndNotified = true; - mProgressBar.setIndeterminate(false); - mProgressBar.setVisibility(View.GONE); + progressBar.setIndeterminate(false); + progressBar.setVisibility(View.GONE); // Show a toast Toast.makeText(OfflineActivity.this, message, Toast.LENGTH_LONG).show(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java index d65eeda9f03..f4d0ff0472e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java @@ -34,12 +34,13 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity implements MapboxMap.OnMyLocationChangeListener, AdapterView.OnItemSelectedListener { - private MapView mMapView; - private MapboxMap mapboxMap; - private Spinner mLocationSpinner, mBearingSpinner; - private Location mLocation; private static final int PERMISSIONS_LOCATION = 0; + private MapView mapView; + private MapboxMap mapboxMap; + private Spinner locationSpinner, bearingSpinner; + private Location location; + @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -55,9 +56,9 @@ protected void onCreate(final Bundle savedInstanceState) { actionBar.setDisplayShowHomeEnabled(true); } - mMapView = (MapView) findViewById(R.id.mapView); - mMapView.onCreate(savedInstanceState); - mMapView.getMapAsync(new OnMapReadyCallback() { + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { MyLocationTrackingModeActivity.this.mapboxMap = mapboxMap; @@ -71,23 +72,23 @@ public void onMapReady(@NonNull MapboxMap mapboxMap) { ArrayAdapter locationTrackingAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item); locationTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mLocationSpinner = (Spinner) findViewById(R.id.spinner_location); - mLocationSpinner.setAdapter(locationTrackingAdapter); - mLocationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); + locationSpinner = (Spinner) findViewById(R.id.spinner_location); + locationSpinner.setAdapter(locationTrackingAdapter); + locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); ArrayAdapter bearingTrackingAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(), R.array.user_bearing_mode, android.R.layout.simple_spinner_item); bearingTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mBearingSpinner = (Spinner) findViewById(R.id.spinner_bearing); - mBearingSpinner.setAdapter(bearingTrackingAdapter); - mBearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); + bearingSpinner = (Spinner) findViewById(R.id.spinner_bearing); + bearingSpinner.setAdapter(bearingTrackingAdapter); + bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); mapboxMap.setOnMyLocationTrackingModeChangeListener(new MapboxMap.OnMyLocationTrackingModeChangeListener() { @Override public void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocationTrackingMode) { if (MyLocationTracking.TRACKING_NONE == myLocationTrackingMode) { - mLocationSpinner.setOnItemSelectedListener(null); - mLocationSpinner.setSelection(0); - mLocationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); + locationSpinner.setOnItemSelectedListener(null); + locationSpinner.setSelection(0); + locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); } } }); @@ -96,9 +97,9 @@ public void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocati @Override public void onMyBearingTrackingModeChange(@MyBearingTracking.Mode int myBearingTrackingMode) { if (MyBearingTracking.NONE == myBearingTrackingMode) { - mBearingSpinner.setOnItemSelectedListener(null); - mBearingSpinner.setSelection(0); - mBearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); + bearingSpinner.setOnItemSelectedListener(null); + bearingSpinner.setSelection(0); + bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); } } }); @@ -150,18 +151,18 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String permissi private void setInitialPosition(LatLng latLng) { mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14)); mapboxMap.setMyLocationEnabled(true); - mLocationSpinner.setEnabled(true); - mBearingSpinner.setEnabled(true); + locationSpinner.setEnabled(true); + bearingSpinner.setEnabled(true); } @Override public void onMyLocationChange(@Nullable Location location) { if (location != null) { - if (mLocation == null) { + if (this.location == null) { // initial location to reposition map setInitialPosition(new LatLng(location)); } - mLocation = location; + this.location = location; showSnackBar(); } } @@ -169,16 +170,16 @@ public void onMyLocationChange(@Nullable Location location) { private void showSnackBar() { String desc = "Loc Chg: "; boolean noInfo = true; - if (mLocation.hasSpeed()) { - desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Spd = %.1f km/h ", mLocation.getSpeed() * 3.6f); + if (location.hasSpeed()) { + desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Spd = %.1f km/h ", location.getSpeed() * 3.6f); noInfo = false; } - if (mLocation.hasAltitude()) { - desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Alt = %.0f m ", mLocation.getAltitude()); + if (location.hasAltitude()) { + desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Alt = %.0f m ", location.getAltitude()); noInfo = false; } - if (mLocation.hasAccuracy()) { - desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Acc = %.0f m", mLocation.getAccuracy()); + if (location.hasAccuracy()) { + desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Acc = %.0f m", location.getAccuracy()); } if (noInfo) { @@ -225,31 +226,31 @@ public void onNothingSelected(AdapterView parent) { @Override public void onResume() { super.onResume(); - mMapView.onResume(); + mapView.onResume(); } @Override public void onPause() { super.onPause(); - mMapView.onPause(); + mapView.onPause(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - mMapView.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); } @Override protected void onDestroy() { super.onDestroy(); - mMapView.onDestroy(); + mapView.onDestroy(); } @Override public void onLowMemory() { super.onLowMemory(); - mMapView.onLowMemory(); + mapView.onLowMemory(); } @Override