aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/compatibility
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2012-05-31 13:33:34 +0200
committerSamuel Tardieu <sam@rfc1149.net>2012-05-31 13:33:34 +0200
commit0034e358668d5911639628468be7409b2696d6c5 (patch)
tree3f0201411526129b7417aa4be7285da00f3fc005 /main/src/cgeo/geocaching/compatibility
parent452a8d10efabb873f780788350aba639d2abfdc5 (diff)
downloadcgeo-0034e358668d5911639628468be7409b2696d6c5.zip
cgeo-0034e358668d5911639628468be7409b2696d6c5.tar.gz
cgeo-0034e358668d5911639628468be7409b2696d6c5.tar.bz2
Fix #1685: make sure the compass range fits within bounds
Diffstat (limited to 'main/src/cgeo/geocaching/compatibility')
-rw-r--r--main/src/cgeo/geocaching/compatibility/Compatibility.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/compatibility/Compatibility.java b/main/src/cgeo/geocaching/compatibility/Compatibility.java
index f88ec2d..d869c58 100644
--- a/main/src/cgeo/geocaching/compatibility/Compatibility.java
+++ b/main/src/cgeo/geocaching/compatibility/Compatibility.java
@@ -38,8 +38,16 @@ public final class Compatibility {
}
}
- public static float getDirectionNow(final float directionNowPre,
- final Activity activity) {
+ /**
+ * Add 90, 180 or 270 degrees to the given rotation.
+ * <br/>
+ * Note: the result is not normalized and may fall outside your desired range.
+ *
+ * @param directionNowPre the direction in degrees before adjustment
+ * @param activity the activity whose rotation is used to adjust the direction
+ * @return the adjusted direction
+ */
+ public static float getDirectionNow(final float directionNowPre, final Activity activity) {
if (isLevel8) {
try {
final int rotation = level8.getRotation(activity);
@@ -55,8 +63,7 @@ public final class Compatibility {
Log.e("Cannot call getRotation()", e);
}
} else {
- final Display display = activity.getWindowManager()
- .getDefaultDisplay();
+ final Display display = activity.getWindowManager().getDefaultDisplay();
final int rotation = display.getOrientation();
if (rotation == Configuration.ORIENTATION_LANDSCAPE) {
return directionNowPre + 90;