@@ -124,7 +124,7 @@ public MyLocationView(Context context, AttributeSet attrs, int defStyleAttr) {
124
124
}
125
125
126
126
private void init (Context context ) {
127
- if (isInEditMode ()){
127
+ if (isInEditMode ()) {
128
128
return ;
129
129
}
130
130
@@ -168,7 +168,6 @@ public final void setForegroundDrawables(Drawable defaultDrawable, Drawable bear
168
168
169
169
foregroundDrawable = defaultDrawable ;
170
170
foregroundBearingDrawable = bearingDrawable ;
171
- setForegroundDrawableTint (foregroundTintColor );
172
171
173
172
invalidateBounds ();
174
173
}
@@ -199,7 +198,6 @@ public final void setShadowDrawable(Drawable drawable, int left, int top, int ri
199
198
backgroundOffsetTop = top ;
200
199
backgroundOffsetRight = right ;
201
200
backgroundOffsetBottom = bottom ;
202
- setShadowDrawableTint (backgroundTintColor );
203
201
204
202
invalidateBounds ();
205
203
}
@@ -389,8 +387,8 @@ protected Parcelable onSaveInstanceState() {
389
387
}
390
388
391
389
@ Override
392
- public void onRestoreInstanceState (Parcelable state ){
393
- if (state instanceof Bundle ){
390
+ public void onRestoreInstanceState (Parcelable state ) {
391
+ if (state instanceof Bundle ) {
394
392
Bundle bundle = (Bundle ) state ;
395
393
tilt = bundle .getFloat ("tilt" );
396
394
state = bundle .getParcelable ("superState" );
@@ -496,11 +494,11 @@ private void setCompass(float bearing) {
496
494
}
497
495
498
496
public float getCenterX () {
499
- return getX () + getMeasuredWidth () / 2 ;
497
+ return ( getX () + contentPadding [ 0 ] - contentPadding [ 2 ] + getMeasuredWidth () ) / 2 ;
500
498
}
501
499
502
500
public float getCenterY () {
503
- return getY () + getMeasuredHeight () / 2 ;
501
+ return ( getY () + contentPadding [ 1 ] - contentPadding [ 3 ] + getMeasuredHeight () ) / 2 ;
504
502
}
505
503
506
504
public void setContentPadding (int [] padding ) {
@@ -564,34 +562,35 @@ public void onSensorChanged(SensorEvent event) {
564
562
return ;
565
563
}
566
564
567
- if ( event .sensor .getType () == Sensor .TYPE_ROTATION_VECTOR ) {
565
+ if ( event .sensor .getType () == Sensor .TYPE_ROTATION_VECTOR ) {
568
566
569
567
// calculate the rotation matrix
570
- SensorManager .getRotationMatrixFromVector (matrix , event .values );
571
- SensorManager .getOrientation (matrix , orientation );
568
+ SensorManager .getRotationMatrixFromVector (matrix , event .values );
569
+ SensorManager .getOrientation (matrix , orientation );
572
570
573
- float magneticHeading = (float ) Math .toDegrees (SensorManager .getOrientation (matrix , orientation )[0 ]);
571
+ float magneticHeading = (float ) Math .toDegrees (SensorManager .getOrientation (matrix , orientation )[0 ]);
574
572
currentDegree = (int ) (magneticHeading );
575
573
576
574
// Change the user location view orientation to reflect the device orientation
577
575
setCompass (currentDegree );
578
576
579
- if (myLocationTrackingMode == MyLocationTracking .TRACKING_FOLLOW ){
577
+ if (myLocationTrackingMode == MyLocationTracking .TRACKING_FOLLOW ) {
580
578
rotateCamera ();
581
579
}
582
580
583
581
compassUpdateNextTimestamp = currentTime + COMPASS_UPDATE_RATE_MS ;
584
582
}
585
583
}
586
584
587
- private void rotateCamera (){
585
+ private void rotateCamera () {
588
586
CameraPosition .Builder builder = new CameraPosition .Builder ();
589
587
builder .bearing (currentDegree );
590
588
mapboxMap .easeCamera (CameraUpdateFactory .newCameraPosition (builder .build ()), COMPASS_UPDATE_RATE_MS , false /*linear interpolator*/ );
591
589
}
592
590
593
591
@ Override
594
- public void onAccuracyChanged (Sensor sensor , int accuracy ) {}
592
+ public void onAccuracyChanged (Sensor sensor , int accuracy ) {
593
+ }
595
594
596
595
}
597
596
0 commit comments