diff options
Diffstat (limited to 'main/src')
5 files changed, 21 insertions, 44 deletions
diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java index 8e853d6..cd88071 100644 --- a/main/src/cgeo/geocaching/StaticMapsProvider.java +++ b/main/src/cgeo/geocaching/StaticMapsProvider.java @@ -142,7 +142,7 @@ public class StaticMapsProvider { String wpMarkerUrl = getWpMarkerUrl(waypoint); if (!hasAllStaticMapsForWaypoint(geocode, waypoint)) { // download map images in separate background thread for higher performance - downloadMaps(geocode, wpMarkerUrl, WAYPOINT_PREFIX + waypoint.getId() + '_' + waypoint.calculateStaticMapsHashcode() + "_", wpLatlonMap, edge, null, waitForResult); + downloadMaps(geocode, wpMarkerUrl, WAYPOINT_PREFIX + waypoint.getId() + '_' + waypoint.getStaticMapsHashcode() + "_", wpLatlonMap, edge, null, waitForResult); } } @@ -233,7 +233,7 @@ public class StaticMapsProvider { return; } int waypointId = waypoint.getId(); - int waypointMapHash = waypoint.calculateStaticMapsHashcode(); + int waypointMapHash = waypoint.getStaticMapsHashcode(); for (int level = 1; level <= 5; level++) { try { StaticMapsProvider.getMapFile(geocode, WAYPOINT_PREFIX + waypointId + "_" + waypointMapHash + '_' + level, false).delete(); @@ -245,9 +245,9 @@ public class StaticMapsProvider { /** * Check if at least one map file exists for the given cache. - * + * * @param cache - * @return <code>true</code> if at least one mapfile exists; <code>false</code> otherwise + * @return <code>true</code> if at least one map file exists; <code>false</code> otherwise */ public static boolean hasStaticMap(final Geocache cache) { if (cache == null) { @@ -259,7 +259,7 @@ public class StaticMapsProvider { } for (int level = 1; level <= 5; level++) { File mapFile = StaticMapsProvider.getMapFile(geocode, String.valueOf(level), false); - if (mapFile != null && mapFile.exists()) { + if (mapFile.exists()) { return true; } } @@ -268,17 +268,17 @@ public class StaticMapsProvider { /** * Checks if at least one map file exists for the given geocode and waypoint ID. - * + * * @param geocode * @param waypoint - * @return <code>true</code> if at least one mapfile exists; <code>false</code> otherwise + * @return <code>true</code> if at least one map file exists; <code>false</code> otherwise */ public static boolean hasStaticMapForWaypoint(String geocode, Waypoint waypoint) { int waypointId = waypoint.getId(); - int waypointMapHash = waypoint.calculateStaticMapsHashcode(); + int waypointMapHash = waypoint.getStaticMapsHashcode(); for (int level = 1; level <= 5; level++) { File mapFile = StaticMapsProvider.getMapFile(geocode, WAYPOINT_PREFIX + waypointId + "_" + waypointMapHash + "_" + level, false); - if (mapFile != null && mapFile.exists()) { + if (mapFile.exists()) { return true; } } @@ -286,20 +286,17 @@ public class StaticMapsProvider { } /** - * Checks if at least one map file exists for the given geocode and waypoint ID. - * + * Checks if all map files exist for the given geocode and waypoint ID. + * * @param geocode * @param waypoint - * @return <code>true</code> if at least one mapfile exists; <code>false</code> otherwise + * @return <code>true</code> if all map files exist; <code>false</code> otherwise */ public static boolean hasAllStaticMapsForWaypoint(String geocode, Waypoint waypoint) { int waypointId = waypoint.getId(); - int waypointMapHash = waypoint.calculateStaticMapsHashcode(); + int waypointMapHash = waypoint.getStaticMapsHashcode(); for (int level = 1; level <= 5; level++) { File mapFile = StaticMapsProvider.getMapFile(geocode, WAYPOINT_PREFIX + waypointId + "_" + waypointMapHash + "_" + level, false); - if (mapFile == null) { - return false; - } boolean mapExists = mapFile.exists(); if (!mapExists) { return false; @@ -314,7 +311,7 @@ public class StaticMapsProvider { public static Bitmap getWaypointMap(final String geocode, Waypoint waypoint, int level) { int waypointId = waypoint.getId(); - int waypointMapHash = waypoint.calculateStaticMapsHashcode(); + int waypointMapHash = waypoint.getStaticMapsHashcode(); return decodeFile(StaticMapsProvider.getMapFile(geocode, WAYPOINT_PREFIX + waypointId + "_" + waypointMapHash + "_" + level, false)); } diff --git a/main/src/cgeo/geocaching/Waypoint.java b/main/src/cgeo/geocaching/Waypoint.java index 53160e5..48c9bc5 100644 --- a/main/src/cgeo/geocaching/Waypoint.java +++ b/main/src/cgeo/geocaching/Waypoint.java @@ -270,7 +270,7 @@ public class Waypoint implements IWaypoint, Comparable<Waypoint> { return visited; } - public int calculateStaticMapsHashcode() { + public int getStaticMapsHashcode() { long hash = 0; if (coords != null) { hash = coords.hashCode(); diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel8.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel8.java index e250934..1189ff5 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel8.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel8.java @@ -6,7 +6,6 @@ import android.annotation.TargetApi; import android.app.Activity; import android.app.backup.BackupManager; import android.os.Environment; -import android.view.Display; import android.view.Surface; import java.io.File; @@ -15,12 +14,6 @@ import java.io.File; public class AndroidLevel8 implements AndroidLevel8Interface { @Override - public int getRotation(final Activity activity) { - Display display = activity.getWindowManager().getDefaultDisplay(); - return display.getRotation(); - } - - @Override public void dataChanged(final String name) { Log.i("Requesting settings backup with settings manager"); BackupManager.dataChanged(name); @@ -28,21 +21,16 @@ public class AndroidLevel8 implements AndroidLevel8Interface { @Override public int getRotationOffset(final Activity activity) { - try { - final int rotation = getRotation(activity); - if (rotation == Surface.ROTATION_90) { + switch (activity.getWindowManager().getDefaultDisplay().getRotation()) { + case Surface.ROTATION_90: return 90; - } else if (rotation == Surface.ROTATION_180) { + case Surface.ROTATION_180: return 180; - } else if (rotation == Surface.ROTATION_270) { + case Surface.ROTATION_270: return 270; - } - } catch (final Exception e) { - // This should never happen: IllegalArgumentException, IllegalAccessException or InvocationTargetException - Log.e("Cannot call getRotation()", e); + default: + return 0; } - - return 0; } @Override diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel8Emulation.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel8Emulation.java index 996c527..a60b48d 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel8Emulation.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel8Emulation.java @@ -12,11 +12,6 @@ import java.io.File; public class AndroidLevel8Emulation implements AndroidLevel8Interface { @Override - public int getRotation(final Activity activity) { - return 0; - } - - @Override public void dataChanged(final String name) { // do nothing } diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel8Interface.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel8Interface.java index 75998aa..2ba3708 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel8Interface.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel8Interface.java @@ -5,10 +5,7 @@ import android.app.Activity; import java.io.File; public interface AndroidLevel8Interface { - public int getRotation(final Activity activity); public void dataChanged(final String name); - public int getRotationOffset(final Activity activity); - public File getExternalPictureDir(); }
\ No newline at end of file |
