aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java58
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractNavigationApp.java26
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java18
-rw-r--r--main/src/cgeo/geocaching/cgCache.java36
-rw-r--r--main/src/cgeo/geocaching/enumerations/CacheAttribute.java9
-rw-r--r--main/src/cgeo/geocaching/files/ParserException.java4
-rw-r--r--main/src/cgeo/geocaching/ui/ImagesList.java4
7 files changed, 33 insertions, 122 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 73412e7..9759684 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -112,7 +112,6 @@ import java.util.regex.Pattern;
*/
public class CacheDetailActivity extends AbstractActivity {
- private static final String EXTRAS_PAGE = "page";
private static final int MENU_FIELD_COPY = 1;
private static final int MENU_FIELD_TRANSLATE = 2;
private static final int MENU_FIELD_TRANSLATE_EN = 3;
@@ -345,13 +344,7 @@ public class CacheDetailActivity extends AbstractActivity {
});
// switch to entry page (last used or 2)
- int entryPageIndex;
- if (extras != null && extras.get(EXTRAS_PAGE) != null) {
- entryPageIndex = extras.getInt(EXTRAS_PAGE);
- }
- else {
- entryPageIndex = Settings.isOpenLastDetailsPage() ? Settings.getLastDetailsPage() : 1;
- }
+ int entryPageIndex = Settings.isOpenLastDetailsPage() ? Settings.getLastDetailsPage() : 1;
if (viewPagerAdapter.getCount() < entryPageIndex) {
for (int i = 0; i <= entryPageIndex; i++) {
// we can't switch to a page that is out of bounds, so we add null-pages
@@ -511,46 +504,44 @@ public class CacheDetailActivity extends AbstractActivity {
}
break;
- case CONTEXT_MENU_WAYPOINT_EDIT: {
- final cgWaypoint waypoint = cache.getWaypoint(index);
- if (waypoint != null) {
- EditWaypointActivity.startActivityEditWaypoint(this, waypoint.getId());
+ case CONTEXT_MENU_WAYPOINT_EDIT:
+ final cgWaypoint waypointEdit = cache.getWaypoint(index);
+ if (waypointEdit != null) {
+ EditWaypointActivity.startActivityEditWaypoint(this, waypointEdit.getId());
refreshOnResume = true;
}
break;
- }
case CONTEXT_MENU_WAYPOINT_DUPLICATE:
- if (cache.duplicateWaypoint(index)) {
+ final cgWaypoint waypointDuplicate = cache.getWaypoint(index);
+ if (cache.duplicateWaypoint(waypointDuplicate)) {
cgData.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
notifyDataSetChanged();
}
break;
case CONTEXT_MENU_WAYPOINT_DELETE:
- if (cache.deleteWaypoint(index)) {
+ final cgWaypoint waypointDelete = cache.getWaypoint(index);
+ if (cache.deleteWaypoint(waypointDelete)) {
cgData.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
notifyDataSetChanged();
}
break;
- case CONTEXT_MENU_WAYPOINT_DEFAULT_NAVIGATION: {
- final cgWaypoint waypoint = cache.getWaypoint(index);
- if (waypoint != null) {
- NavigationAppFactory.startDefaultNavigationApplication(1, this, waypoint);
+ case CONTEXT_MENU_WAYPOINT_DEFAULT_NAVIGATION:
+ final cgWaypoint waypointNavigation = cache.getWaypoint(index);
+ if (waypointNavigation != null) {
+ NavigationAppFactory.startDefaultNavigationApplication(1, this, waypointNavigation);
}
- }
break;
- case CONTEXT_MENU_WAYPOINT_NAVIGATE: {
- final cgWaypoint waypoint = cache.getWaypoint(contextMenuWPIndex);
- if (waypoint != null) {
- NavigationAppFactory.showNavigationMenu(this, null, waypoint, null);
+ case CONTEXT_MENU_WAYPOINT_NAVIGATE:
+ final cgWaypoint waypointNav = cache.getWaypoint(contextMenuWPIndex);
+ if (waypointNav != null) {
+ NavigationAppFactory.showNavigationMenu(this, null, waypointNav, null);
}
- }
break;
- case CONTEXT_MENU_WAYPOINT_CACHES_AROUND: {
- final cgWaypoint waypoint = cache.getWaypoint(index);
- if (waypoint != null) {
- cgeocaches.startActivityCoordinates(this, waypoint.getCoords());
+ case CONTEXT_MENU_WAYPOINT_CACHES_AROUND:
+ final cgWaypoint waypointAround = cache.getWaypoint(index);
+ if (waypointAround != null) {
+ cgeocaches.startActivityCoordinates(this, waypointAround.getCoords());
}
- }
break;
default: {
if (imagesList != null && imagesList.onContextItemSelected(item)) {
@@ -966,13 +957,6 @@ public class CacheDetailActivity extends AbstractActivity {
context.startActivity(detailIntent);
}
- public static void startActivity(final Context context, final String geocode, final int page) {
- final Intent detailIntent = new Intent(context, CacheDetailActivity.class);
- detailIntent.putExtra("geocode", geocode);
- detailIntent.putExtra(EXTRAS_PAGE, page);
- context.startActivity(detailIntent);
- }
-
/**
* The ViewPagerAdapter for scrolling through pages of the CacheDetailActivity.
*/
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractNavigationApp.java
deleted file mode 100644
index 27cb47c..0000000
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractNavigationApp.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package cgeo.geocaching.apps.cache.navi;
-
-import cgeo.geocaching.cgWaypoint;
-import cgeo.geocaching.apps.AbstractApp;
-import cgeo.geocaching.geopoint.Geopoint;
-
-abstract class AbstractNavigationApp extends AbstractApp implements NavigationApp {
-
- protected AbstractNavigationApp(String name, String intent, String packageName) {
- super(name, intent, packageName);
- }
-
- protected AbstractNavigationApp(String name, String intent) {
- super(name, intent);
- }
-
- @Override
- public boolean isEnabled(cgWaypoint waypoint) {
- return waypoint != null;
- }
-
- @Override
- public boolean isEnabled(Geopoint geopoint) {
- return geopoint != null;
- }
-}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
deleted file mode 100644
index 52d16cf..0000000
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cgeo.geocaching.apps.cache.navi;
-
-import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
-import cgeo.geocaching.apps.App;
-import cgeo.geocaching.geopoint.Geopoint;
-
-import android.app.Activity;
-
-public interface NavigationApp extends App {
- public boolean invoke(final Activity activity,
- final cgCache cache, final cgWaypoint waypoint,
- final Geopoint coords);
-
- boolean isEnabled(final cgWaypoint waypoint);
-
- boolean isEnabled(final Geopoint geopoint);
-}
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index 6ce2dcc..a0f16e9 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -1203,15 +1203,16 @@ public class cgCache implements ICache, IWaypoint {
/**
* Duplicate a waypoint.
- *
- * @param index the waypoint to duplicate
+ *
+ * @param original
+ * the waypoint to duplicate
* @return <code>true</code> if the waypoint was duplicated, <code>false</code> otherwise (invalid index)
*/
- public boolean duplicateWaypoint(final int index) {
- final cgWaypoint original = getWaypoint(index);
+ public boolean duplicateWaypoint(final cgWaypoint original) {
if (original == null) {
return false;
}
+ final int index = getWaypointIndex(original);
final cgWaypoint copy = new cgWaypoint(original);
copy.setUserDefined();
copy.setName(cgeoapplication.getInstance().getString(R.string.waypoint_copy_of) + " " + copy.getName());
@@ -1222,16 +1223,19 @@ public class cgCache implements ICache, IWaypoint {
/**
* delete a user defined waypoint
*
- * @param index
- * of the waypoint in cache's waypoint list
+ * @param waypoint
+ * to be removed from cache
* @return <code>true</code>, if the waypoint was deleted
*/
- public boolean deleteWaypoint(final int index) {
- final cgWaypoint waypoint = getWaypoint(index);
+ public boolean deleteWaypoint(final cgWaypoint waypoint) {
if (waypoint == null) {
return false;
}
+ if (waypoint.getId() <= 0) {
+ return false;
+ }
if (waypoint.isUserDefined()) {
+ final int index = getWaypointIndex(waypoint);
waypoints.remove(index);
cgData.deleteWaypoint(waypoint.getId());
cgData.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE));
@@ -1245,22 +1249,6 @@ public class cgCache implements ICache, IWaypoint {
}
/**
- * delete a user defined waypoint
- *
- * @param waypoint
- * to be removed from cache
- * @return <code>true</code>, if the waypoint was deleted
- */
- public boolean deleteWaypoint(final cgWaypoint waypoint) {
- if (waypoint.getId() <= 0) {
- return false;
- }
-
- final int index = getWaypointIndex(waypoint);
- return index >= 0 && deleteWaypoint(index);
- }
-
- /**
* Find index of given <code>waypoint</code> in cache's <code>waypoints</code> list
*
* @param waypoint
diff --git a/main/src/cgeo/geocaching/enumerations/CacheAttribute.java b/main/src/cgeo/geocaching/enumerations/CacheAttribute.java
index a31b0cc..e29e176 100644
--- a/main/src/cgeo/geocaching/enumerations/CacheAttribute.java
+++ b/main/src/cgeo/geocaching/enumerations/CacheAttribute.java
@@ -110,15 +110,6 @@ public enum CacheAttribute {
FIND_BY_GCRAWNAME = Collections.unmodifiableMap(mapGcRawNames);
}
- public static CacheAttribute getById(final int id) {
- for (CacheAttribute attr : values()) {
- if (attr.id == id) {
- return attr;
- }
- }
- return UNKNOWN;
- }
-
public static CacheAttribute getByGcRawName(final String gcRawName) {
final CacheAttribute result = gcRawName != null ? FIND_BY_GCRAWNAME.get(gcRawName) : null;
if (result == null) {
diff --git a/main/src/cgeo/geocaching/files/ParserException.java b/main/src/cgeo/geocaching/files/ParserException.java
index 5aa152c..c0076cc 100644
--- a/main/src/cgeo/geocaching/files/ParserException.java
+++ b/main/src/cgeo/geocaching/files/ParserException.java
@@ -13,10 +13,6 @@ public class ParserException extends Exception {
super(detailMessage);
}
- public ParserException(Throwable throwable) {
- super(throwable);
- }
-
public ParserException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
diff --git a/main/src/cgeo/geocaching/ui/ImagesList.java b/main/src/cgeo/geocaching/ui/ImagesList.java
index 3d6f95c..91b4fde 100644
--- a/main/src/cgeo/geocaching/ui/ImagesList.java
+++ b/main/src/cgeo/geocaching/ui/ImagesList.java
@@ -179,10 +179,6 @@ public class ImagesList {
bitmaps.clear();
}
- public cgImage getImage(int id) {
- return images.get(id);
- }
-
public void onCreateContextMenu(ContextMenu menu, View v) {
final Resources res = activity.getResources();
menu.setHeaderTitle(res.getString(R.string.cache_image));