diff options
Diffstat (limited to 'main/src/cgeo/geocaching/ui/CompassMiniView.java')
-rw-r--r-- | main/src/cgeo/geocaching/ui/CompassMiniView.java | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/ui/CompassMiniView.java b/main/src/cgeo/geocaching/ui/CompassMiniView.java index 50823fd..d50d806 100644 --- a/main/src/cgeo/geocaching/ui/CompassMiniView.java +++ b/main/src/cgeo/geocaching/ui/CompassMiniView.java @@ -1,7 +1,7 @@ package cgeo.geocaching.ui; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.AngleUtils; @@ -50,18 +50,19 @@ final public class CompassMiniView extends View { private static final float MINIMUM_ROTATION_DEGREES_FOR_REPAINT = 5; private float azimuthRelative; - public CompassMiniView(Context context) { + public CompassMiniView(final Context context) { super(context); } - public CompassMiniView(Context context, AttributeSet attrs) { + public CompassMiniView(final Context context, final AttributeSet attrs) { super(context, attrs); } @Override public void onAttachedToWindow() { if (instances++ == 0) { - compassArrow = BitmapFactory.decodeResource(getResources(), Settings.isLightSkin() ? R.drawable.compass_arrow_mini_black : R.drawable.compass_arrow_mini_white); + final int drawable = isInEditMode() || !Settings.isLightSkin() ? R.drawable.compass_arrow_mini_white : R.drawable.compass_arrow_mini_black; + compassArrow = BitmapFactory.decodeResource(getResources(), drawable); compassArrowWidth = compassArrow.getWidth(); compassArrowHeight = compassArrow.getWidth(); } @@ -79,12 +80,12 @@ final public class CompassMiniView extends View { targetCoords = point; } - public void updateAzimuth(float azimuth) { + public void updateAzimuth(final float azimuth) { this.azimuth = azimuth; updateDirection(); } - public void updateHeading(float heading) { + public void updateHeading(final float heading) { this.heading = heading; updateDirection(); } @@ -106,7 +107,7 @@ final public class CompassMiniView extends View { azimuthRelative = AngleUtils.normalize(azimuth - heading); // avoid updates on very small changes, which are not visible to the user - float change = Math.abs(azimuthRelative - lastDrawnAzimuth); + final float change = Math.abs(azimuthRelative - lastDrawnAzimuth); if (change < MINIMUM_ROTATION_DEGREES_FOR_REPAINT) { return; } @@ -119,7 +120,7 @@ final public class CompassMiniView extends View { } @Override - protected void onDraw(Canvas canvas) { + protected void onDraw(final Canvas canvas) { super.onDraw(canvas); lastDrawnAzimuth = azimuthRelative; @@ -137,11 +138,11 @@ final public class CompassMiniView extends View { } @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) { setMeasuredDimension(measureWidth(widthMeasureSpec), measureHeight(heightMeasureSpec)); } - private int measureWidth(int measureSpec) { + private int measureWidth(final int measureSpec) { final int specMode = MeasureSpec.getMode(measureSpec); final int specSize = MeasureSpec.getSize(measureSpec); @@ -158,7 +159,7 @@ final public class CompassMiniView extends View { return result; } - private int measureHeight(int measureSpec) { + private int measureHeight(final int measureSpec) { final int specMode = MeasureSpec.getMode(measureSpec); final int specSize = MeasureSpec.getSize(measureSpec); |