aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/AbstractLoggingActivity.java2
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java42
-rw-r--r--main/src/cgeo/geocaching/EditWaypointActivity.java6
-rw-r--r--main/src/cgeo/geocaching/ICache.java4
-rw-r--r--main/src/cgeo/geocaching/Image.java (renamed from main/src/cgeo/geocaching/cgImage.java)18
-rw-r--r--main/src/cgeo/geocaching/ImagesActivity.java10
-rw-r--r--main/src/cgeo/geocaching/LogEntry.java10
-rw-r--r--main/src/cgeo/geocaching/LogTrackableActivity.java6
-rw-r--r--main/src/cgeo/geocaching/StaticMapsActivity.java4
-rw-r--r--main/src/cgeo/geocaching/StaticMapsProvider.java10
-rw-r--r--main/src/cgeo/geocaching/Trackable.java (renamed from main/src/cgeo/geocaching/cgTrackable.java)4
-rw-r--r--main/src/cgeo/geocaching/TrackableActivity.java20
-rw-r--r--main/src/cgeo/geocaching/Waypoint.java (renamed from main/src/cgeo/geocaching/cgWaypoint.java)18
-rw-r--r--main/src/cgeo/geocaching/WaypointPopup.java2
-rw-r--r--main/src/cgeo/geocaching/apps/AbstractLocusApp.java10
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java20
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java6
-rw-r--r--main/src/cgeo/geocaching/cgCache.java71
-rw-r--r--main/src/cgeo/geocaching/cgData.java510
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java20
-rw-r--r--main/src/cgeo/geocaching/connector/ConnectorFactory.java4
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java44
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java121
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OCXMLClient.java12
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OkapiClient.java8
-rw-r--r--main/src/cgeo/geocaching/export/GpxExport.java16
-rw-r--r--main/src/cgeo/geocaching/files/GPXParser.java18
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java14
-rw-r--r--main/src/cgeo/geocaching/twitter/Twitter.java4
-rw-r--r--main/src/cgeo/geocaching/ui/Formatter.java6
-rw-r--r--main/src/cgeo/geocaching/ui/ImagesList.java14
-rw-r--r--main/src/cgeo/geocaching/utils/LogTemplateProvider.java10
40 files changed, 477 insertions, 635 deletions
diff --git a/main/src/cgeo/geocaching/AbstractLoggingActivity.java b/main/src/cgeo/geocaching/AbstractLoggingActivity.java
index 4816dee..eaeffb0 100644
--- a/main/src/cgeo/geocaching/AbstractLoggingActivity.java
+++ b/main/src/cgeo/geocaching/AbstractLoggingActivity.java
@@ -55,7 +55,7 @@ public abstract class AbstractLoggingActivity extends AbstractActivity {
if (cache != null && ConnectorFactory.getConnector(cache).equals(GCConnector.getInstance())) {
smileyVisible = true;
}
- final cgTrackable trackable = getLogContext().getTrackable();
+ final Trackable trackable = getLogContext().getTrackable();
if (trackable != null && ConnectorFactory.getConnector(trackable).equals(GCConnector.getInstance())) {
smileyVisible = true;
}
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 37a24ad..813d1da 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -373,9 +373,9 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
final ViewGroup parent = ((ViewGroup) view.getParent());
for (int i = 0; i < parent.getChildCount(); i++) {
if (parent.getChildAt(i) == view) {
- final List<cgWaypoint> sortedWaypoints = new ArrayList<cgWaypoint>(cache.getWaypoints());
+ final List<Waypoint> sortedWaypoints = new ArrayList<Waypoint>(cache.getWaypoints());
Collections.sort(sortedWaypoints);
- final cgWaypoint waypoint = sortedWaypoints.get(i);
+ final Waypoint waypoint = sortedWaypoints.get(i);
final int index = cache.getWaypoints().indexOf(waypoint);
menu.setHeaderTitle(res.getString(R.string.waypoint));
if (waypoint.getWaypointType().equals(WaypointType.ORIGINAL)) {
@@ -458,40 +458,40 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
break;
case CONTEXT_MENU_WAYPOINT_EDIT:
- final cgWaypoint waypointEdit = cache.getWaypoint(index);
+ final Waypoint waypointEdit = cache.getWaypoint(index);
if (waypointEdit != null) {
EditWaypointActivity.startActivityEditWaypoint(this, waypointEdit.getId());
refreshOnResume = true;
}
break;
case CONTEXT_MENU_WAYPOINT_DUPLICATE:
- final cgWaypoint waypointDuplicate = cache.getWaypoint(index);
+ final Waypoint waypointDuplicate = cache.getWaypoint(index);
if (cache.duplicateWaypoint(waypointDuplicate)) {
cgData.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
notifyDataSetChanged();
}
break;
case CONTEXT_MENU_WAYPOINT_DELETE:
- final cgWaypoint waypointDelete = cache.getWaypoint(index);
+ final Waypoint 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 waypointNavigation = cache.getWaypoint(index);
+ final Waypoint waypointNavigation = cache.getWaypoint(index);
if (waypointNavigation != null) {
NavigationAppFactory.startDefaultNavigationApplication(1, this, waypointNavigation);
}
break;
case CONTEXT_MENU_WAYPOINT_NAVIGATE:
- final cgWaypoint waypointNav = cache.getWaypoint(contextMenuWPIndex);
+ final Waypoint waypointNav = cache.getWaypoint(contextMenuWPIndex);
if (waypointNav != null) {
NavigationAppFactory.showNavigationMenu(this, null, waypointNav, null);
}
break;
case CONTEXT_MENU_WAYPOINT_CACHES_AROUND:
- final cgWaypoint waypointAround = cache.getWaypoint(index);
+ final Waypoint waypointAround = cache.getWaypoint(index);
if (waypointAround != null) {
cgeocaches.startActivityCoordinates(this, waypointAround.getCoords());
}
@@ -903,9 +903,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
private ViewGroup attributeDescriptionsLayout; // layout for attribute descriptions
private boolean attributesShowAsIcons = true; // default: show icons
/**
- * True, if the cache was imported with an older version of c:geo.
- * These older versions parsed the attribute description from the tooltip in the web
- * page and put them into the DB. No icons can be matched for these.
+ * If the cache is from a non GC source, it might be without icons. Disable switching in those cases.
*/
private boolean noAttributeIconsFound = false;
private int attributeBoxMaxWidth;
@@ -1074,10 +1072,6 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
buffer.append(attributeName);
}
- if (noAttributeIconsFound) {
- buffer.append("\n\n").append(res.getString(R.string.cache_attributes_no_icons));
- }
-
attribView.setText(buffer);
return descriptions;
@@ -2035,7 +2029,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
holder.images.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- ImagesActivity.startActivityLogImages(CacheDetailActivity.this, cache.getGeocode(), new ArrayList<cgImage>(log.getLogImages()));
+ ImagesActivity.startActivityLogImages(CacheDetailActivity.this, cache.getGeocode(), new ArrayList<Image>(log.getLogImages()));
}
});
} else {
@@ -2102,10 +2096,10 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
final LinearLayout waypoints = (LinearLayout) view.findViewById(R.id.waypoints);
// sort waypoints: PP, Sx, FI, OWN
- final List<cgWaypoint> sortedWaypoints = new ArrayList<cgWaypoint>(cache.getWaypoints());
+ final List<Waypoint> sortedWaypoints = new ArrayList<Waypoint>(cache.getWaypoints());
Collections.sort(sortedWaypoints);
- for (final cgWaypoint wpt : sortedWaypoints) {
+ for (final Waypoint wpt : sortedWaypoints) {
final LinearLayout waypointView = (LinearLayout) getLayoutInflater().inflate(R.layout.waypoint_item, null);
// coordinates
@@ -2200,13 +2194,13 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
// TODO: fix layout, then switch back to Android-resource and delete copied one
// this copy is modified to respect the text color
- view.setAdapter(new ArrayAdapter<cgTrackable>(CacheDetailActivity.this, R.layout.simple_list_item_1, cache.getInventory()));
+ view.setAdapter(new ArrayAdapter<Trackable>(CacheDetailActivity.this, R.layout.simple_list_item_1, cache.getInventory()));
view.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Object selection = arg0.getItemAtPosition(arg2);
- if (selection instanceof cgTrackable) {
- cgTrackable trackable = (cgTrackable) selection;
+ if (selection instanceof Trackable) {
+ Trackable trackable = (Trackable) selection;
TrackableActivity.startActivity(CacheDetailActivity.this, trackable.getGuid(), trackable.getGeocode(), trackable.getName());
}
}
@@ -2254,7 +2248,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
final RadioButton resetBoth;
final RadioButton resetLocal;
- public ResetCacheCoordinatesDialog(final cgCache cache, final cgWaypoint wpt, final Activity activity) {
+ public ResetCacheCoordinatesDialog(final cgCache cache, final Waypoint wpt, final Activity activity) {
super(activity);
View layout = activity.getLayoutInflater().inflate(R.layout.reset_cache_coords_dialog, null);
@@ -2303,12 +2297,12 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
private final Handler handler;
private final boolean local;
private final boolean remote;
- private final cgWaypoint wpt;
+ private final Waypoint wpt;
private ProgressDialog progress;
public static final int LOCAL = 0;
public static final int ON_WEBSITE = 1;
- public ResetCoordsThread(cgCache cache, Handler handler, final cgWaypoint wpt, boolean local, boolean remote, final ProgressDialog progress) {
+ public ResetCoordsThread(cgCache cache, Handler handler, final Waypoint wpt, boolean local, boolean remote, final ProgressDialog progress) {
this.cache = cache;
this.handler = handler;
this.local = local;
diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java
index 5701540..0d06ede 100644
--- a/main/src/cgeo/geocaching/EditWaypointActivity.java
+++ b/main/src/cgeo/geocaching/EditWaypointActivity.java
@@ -43,7 +43,7 @@ public class EditWaypointActivity extends AbstractActivity {
private String geocode = null;
private int id = -1;
private ProgressDialog waitDialog = null;
- private cgWaypoint waypoint = null;
+ private Waypoint waypoint = null;
private Geopoint gpTemp = null;
private WaypointType type = WaypointType.OWN;
private String prefix = "OWN";
@@ -416,7 +416,7 @@ public class EditWaypointActivity extends AbstractActivity {
}
final String note = ((EditText) findViewById(R.id.note)).getText().toString().trim();
- final cgWaypoint waypoint = new cgWaypoint(name, type, own);
+ final Waypoint waypoint = new Waypoint(name, type, own);
waypoint.setGeocode(geocode);
waypoint.setPrefix(prefix);
waypoint.setLookup(lookup);
@@ -435,7 +435,7 @@ public class EditWaypointActivity extends AbstractActivity {
final RadioButton modifyBoth = (RadioButton) findViewById(R.id.modify_cache_coordinates_local_and_remote);
if (modifyLocal.isChecked() || modifyBoth.isChecked()) {
if (!cache.hasUserModifiedCoords()) {
- final cgWaypoint origWaypoint = new cgWaypoint(cgeoapplication.getInstance().getString(R.string.cache_coordinates_original), WaypointType.ORIGINAL, false);
+ final Waypoint origWaypoint = new Waypoint(cgeoapplication.getInstance().getString(R.string.cache_coordinates_original), WaypointType.ORIGINAL, false);
origWaypoint.setCoords(cache.getCoords());
cache.addOrChangeWaypoint(origWaypoint, false);
cache.setUserModifiedCoords(true);
diff --git a/main/src/cgeo/geocaching/ICache.java b/main/src/cgeo/geocaching/ICache.java
index 8f8baf9..030c53f 100644
--- a/main/src/cgeo/geocaching/ICache.java
+++ b/main/src/cgeo/geocaching/ICache.java
@@ -112,12 +112,12 @@ public interface ICache extends IBasicCache {
/**
* @return the list of trackables in this cache
*/
- public List<cgTrackable> getInventory();
+ public List<Trackable> getInventory();
/**
* @return the list of spoiler images
*/
- public List<cgImage> getSpoilers();
+ public List<Image> getSpoilers();
/**
* @return a statistic how often the caches has been found, disabled, archived etc.
diff --git a/main/src/cgeo/geocaching/cgImage.java b/main/src/cgeo/geocaching/Image.java
index b313ef5..22c76aa 100644
--- a/main/src/cgeo/geocaching/cgImage.java
+++ b/main/src/cgeo/geocaching/Image.java
@@ -8,22 +8,22 @@ import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
-public class cgImage implements Parcelable {
+public class Image implements Parcelable {
private final String url;
private final String title;
private final String description;
- public cgImage(final String url, final String title, final String description) {
+ public Image(final String url, final String title, final String description) {
this.url = url;
this.title = title;
this.description = description;
}
- public cgImage(final String url, final String title) {
+ public Image(final String url, final String title) {
this(url, title, null);
}
- public cgImage(final Parcel in) {
+ public Image(final Parcel in) {
url = in.readString();
title = in.readString();
description = in.readString();
@@ -41,15 +41,15 @@ public class cgImage implements Parcelable {
dest.writeString(description);
}
- public static final Parcelable.Creator<cgImage> CREATOR = new Parcelable.Creator<cgImage>() {
+ public static final Parcelable.Creator<Image> CREATOR = new Parcelable.Creator<Image>() {
@Override
- public cgImage createFromParcel(Parcel in) {
- return new cgImage(in);
+ public Image createFromParcel(Parcel in) {
+ return new Image(in);
}
@Override
- public cgImage[] newArray(int size) {
- return new cgImage[size];
+ public Image[] newArray(int size) {
+ return new Image[size];
}
};
diff --git a/main/src/cgeo/geocaching/ImagesActivity.java b/main/src/cgeo/geocaching/ImagesActivity.java
index 82902b5..71be14c 100644
--- a/main/src/cgeo/geocaching/ImagesActivity.java
+++ b/main/src/cgeo/geocaching/ImagesActivity.java
@@ -24,7 +24,7 @@ public class ImagesActivity extends AbstractActivity {
private static final String EXTRAS_GEOCODE = "geocode";
private boolean offline;
- private ArrayList<cgImage> imageNames;
+ private ArrayList<Image> imageNames;
private ImagesList imagesList;
private ImageType imgType = ImageType.SpoilerImages;
@@ -78,11 +78,11 @@ public class ImagesActivity extends AbstractActivity {
super.onStop();
}
- public static void startActivityLogImages(final Context fromActivity, final String geocode, List<cgImage> logImages) {
+ public static void startActivityLogImages(final Context fromActivity, final String geocode, List<Image> logImages) {
startActivity(fromActivity, geocode, logImages, ImageType.LogImages);
}
- private static void startActivity(final Context fromActivity, final String geocode, List<cgImage> logImages, ImageType imageType) {
+ private static void startActivity(final Context fromActivity, final String geocode, List<Image> logImages, ImageType imageType) {
final Intent logImgIntent = new Intent(fromActivity, ImagesActivity.class);
// if resuming our app within this activity, finish it and return to the cache activity
logImgIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
@@ -90,12 +90,12 @@ public class ImagesActivity extends AbstractActivity {
.putExtra(EXTRAS_TYPE, imageType);
// avoid forcing the array list as parameter type
- final ArrayList<cgImage> arrayList = new ArrayList<cgImage>(logImages);
+ final ArrayList<Image> arrayList = new ArrayList<Image>(logImages);
logImgIntent.putParcelableArrayListExtra(EXTRAS_IMAGES, arrayList);
fromActivity.startActivity(logImgIntent);
}
- public static void startActivitySpoilerImages(final Context fromActivity, String geocode, List<cgImage> spoilers) {
+ public static void startActivitySpoilerImages(final Context fromActivity, String geocode, List<Image> spoilers) {
startActivity(fromActivity, geocode, spoilers, ImageType.SpoilerImages);
}
diff --git a/main/src/cgeo/geocaching/LogEntry.java b/main/src/cgeo/geocaching/LogEntry.java
index 1cb3de3..060478f 100644
--- a/main/src/cgeo/geocaching/LogEntry.java
+++ b/main/src/cgeo/geocaching/LogEntry.java
@@ -25,7 +25,7 @@ public final class LogEntry {
public int found = -1;
/** Friend's log entry */
public boolean friend = false;
- private List<cgImage> logImages = null;
+ private List<Image> logImages = null;
public String cacheName = ""; // used for trackables
public String cacheGuid = ""; // used for trackables
@@ -64,9 +64,9 @@ public final class LogEntry {
log.compareTo(otherLog.log) == 0;
}
- public void addLogImage(final cgImage image) {
+ public void addLogImage(final Image image) {
if (logImages == null) {
- logImages = new ArrayList<cgImage>();
+ logImages = new ArrayList<Image>();
}
logImages.add(image);
}
@@ -74,7 +74,7 @@ public final class LogEntry {
/**
* @return the log images or an empty list, never <code>null</code>
*/
- public List<cgImage> getLogImages() {
+ public List<Image> getLogImages() {
if (logImages == null) {
return Collections.emptyList();
}
@@ -87,7 +87,7 @@ public final class LogEntry {
public CharSequence getImageTitles() {
final List<String> titles = new ArrayList<String>(5);
- for (cgImage image : getLogImages()) {
+ for (Image image : getLogImages()) {
if (StringUtils.isNotBlank(image.getTitle())) {
titles.add(image.getTitle());
}
diff --git a/main/src/cgeo/geocaching/LogTrackableActivity.java b/main/src/cgeo/geocaching/LogTrackableActivity.java
index a4677d0..168b1ee 100644
--- a/main/src/cgeo/geocaching/LogTrackableActivity.java
+++ b/main/src/cgeo/geocaching/LogTrackableActivity.java
@@ -47,7 +47,7 @@ public class LogTrackableActivity extends AbstractLoggingActivity implements Dat
private int attempts = 0;
private CheckBox tweetCheck = null;
private LinearLayout tweetBox = null;
- private cgTrackable trackable;
+ private Trackable trackable;
private Handler showProgressHandler = new Handler() {
@Override
@@ -207,7 +207,7 @@ public class LogTrackableActivity extends AbstractLoggingActivity implements Dat
tweetCheck.setChecked(true);
if (CollectionUtils.isEmpty(possibleLogTypes)) {
- possibleLogTypes = cgTrackable.getPossibleLogTypes();
+ possibleLogTypes = Trackable.getPossibleLogTypes();
}
final Button buttonPost = (Button) findViewById(R.id.post);
@@ -355,7 +355,7 @@ public class LogTrackableActivity extends AbstractLoggingActivity implements Dat
return StatusCode.LOG_POST_ERROR;
}
- public static void startActivity(final Context context, final cgTrackable trackable) {
+ public static void startActivity(final Context context, final Trackable trackable) {
final Intent logTouchIntent = new Intent(context, LogTrackableActivity.class);
logTouchIntent.putExtra("geocode", trackable.getGeocode());
logTouchIntent.putExtra("guid", trackable.getGuid());
diff --git a/main/src/cgeo/geocaching/StaticMapsActivity.java b/main/src/cgeo/geocaching/StaticMapsActivity.java
index c0a7f47..a15aa73 100644
--- a/main/src/cgeo/geocaching/StaticMapsActivity.java
+++ b/main/src/cgeo/geocaching/StaticMapsActivity.java
@@ -183,7 +183,7 @@ public class StaticMapsActivity extends AbstractActivity {
StaticMapsProvider.storeCacheStaticMap(cache, true);
return cache.hasStaticMap();
}
- final cgWaypoint waypoint = cache.getWaypointById(waypoint_id);
+ final Waypoint waypoint = cache.getWaypointById(waypoint_id);
if (waypoint != null) {
showToast(res.getString(R.string.info_storing_static_maps));
StaticMapsProvider.storeWaypointStaticMap(cache, waypoint, true);
@@ -193,7 +193,7 @@ public class StaticMapsActivity extends AbstractActivity {
return false;
}
- public static void startActivity(final Context activity, final String geocode, final boolean download, final cgWaypoint waypoint) {
+ public static void startActivity(final Context activity, final String geocode, final boolean download, final Waypoint waypoint) {
final Intent intent = new Intent(activity, StaticMapsActivity.class);
// if resuming our app within this activity, finish it and return to the cache activity
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java
index 132619a..d587efd 100644
--- a/main/src/cgeo/geocaching/StaticMapsProvider.java
+++ b/main/src/cgeo/geocaching/StaticMapsProvider.java
@@ -99,18 +99,18 @@ public class StaticMapsProvider {
if (Settings.isStoreOfflineWpMaps() && CollectionUtils.isNotEmpty(cache.getWaypoints())) {
// remove all waypoint static map files due to origin cache waypoint id changed on saveCache
LocalStorage.deleteFilesWithPrefix(cache.getGeocode(), MAP_FILENAME_PREFIX + WAYPOINT_PREFIX);
- for (cgWaypoint waypoint : cache.getWaypoints()) {
+ for (Waypoint waypoint : cache.getWaypoints()) {
storeWaypointStaticMap(cache.getGeocode(), edge, waypoint, false);
}
}
}
- public static void storeWaypointStaticMap(cgCache cache, cgWaypoint waypoint, boolean waitForResult) {
+ public static void storeWaypointStaticMap(cgCache cache, Waypoint waypoint, boolean waitForResult) {
int edge = StaticMapsProvider.guessMaxDisplaySide();
storeWaypointStaticMap(cache.getGeocode(), edge, waypoint, waitForResult);
}
- private static void storeWaypointStaticMap(final String geocode, int edge, cgWaypoint waypoint, final boolean waitForResult) {
+ private static void storeWaypointStaticMap(final String geocode, int edge, Waypoint waypoint, final boolean waitForResult) {
if (geocode == null) {
Log.e("storeWaypointStaticMap - missing input parameter geocode");
return;
@@ -136,7 +136,7 @@ public class StaticMapsProvider {
private static void storeCacheStaticMap(final cgCache cache, final int edge, final boolean waitForResult) {
final String latlonMap = cache.getCoords().format(Format.LAT_LON_DECDEGREE_COMMA);
final Parameters waypoints = new Parameters();
- for (final cgWaypoint waypoint : cache.getWaypoints()) {
+ for (final Waypoint waypoint : cache.getWaypoints()) {
if (waypoint.getCoords() == null) {
continue;
}
@@ -205,7 +205,7 @@ public class StaticMapsProvider {
return url.toString();
}
- private static String getWpMarkerUrl(final cgWaypoint waypoint) {
+ private static String getWpMarkerUrl(final Waypoint waypoint) {
String type = waypoint.getWaypointType() != null ? waypoint.getWaypointType().id : null;
return MARKERS_URL + "marker_waypoint_" + type + ".png";
}
diff --git a/main/src/cgeo/geocaching/cgTrackable.java b/main/src/cgeo/geocaching/Trackable.java
index b03a783..f777351 100644
--- a/main/src/cgeo/geocaching/cgTrackable.java
+++ b/main/src/cgeo/geocaching/Trackable.java
@@ -11,7 +11,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-public class cgTrackable implements ILogable {
+public class Trackable implements ILogable {
static final public int SPOTTED_UNSET = 0;
static final public int SPOTTED_CACHE = 1;
static final public int SPOTTED_USER = 2;
@@ -44,7 +44,7 @@ public class cgTrackable implements ILogable {
int id = Integer.parseInt(hex, 16);
return "http://geokrety.org/konkret.php?id=" + id;
} catch (NumberFormatException e) {
- Log.e("cgTrackable.getUrl", e);
+ Log.e("Trackable.getUrl", e);
return null;
}
}
diff --git a/main/src/cgeo/geocaching/TrackableActivity.java b/main/src/cgeo/geocaching/TrackableActivity.java
index d5b4f9f..df3c6e4 100644
--- a/main/src/cgeo/geocaching/TrackableActivity.java
+++ b/main/src/cgeo/geocaching/TrackableActivity.java
@@ -58,7 +58,7 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
}
private static final int MENU_LOG_TOUCH = 1;
private static final int MENU_BROWSER_TRACKABLE = 2;
- private cgTrackable trackable = null;
+ private Trackable trackable = null;
private String geocode = null;
private String name = null;
private String guid = null;
@@ -486,7 +486,7 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
if (log.hasLogImages()) {
- final ArrayList<cgImage> logImages = new ArrayList<cgImage>(log.getLogImages());
+ final ArrayList<Image> logImages = new ArrayList<Image>(log.getLogImages());
final View.OnClickListener listener = new View.OnClickListener() {
@Override
@@ -545,18 +545,18 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
// trackable spotted
if (StringUtils.isNotBlank(trackable.getSpottedName()) ||
- trackable.getSpottedType() == cgTrackable.SPOTTED_UNKNOWN ||
- trackable.getSpottedType() == cgTrackable.SPOTTED_OWNER) {
+ trackable.getSpottedType() == Trackable.SPOTTED_UNKNOWN ||
+ trackable.getSpottedType() == Trackable.SPOTTED_OWNER) {
boolean showTimeSpan = true;
StringBuilder text;
- if (trackable.getSpottedType() == cgTrackable.SPOTTED_CACHE) {
+ if (trackable.getSpottedType() == Trackable.SPOTTED_CACHE) {
text = new StringBuilder(res.getString(R.string.trackable_spotted_in_cache) + ' ' + Html.fromHtml(trackable.getSpottedName()).toString());
- } else if (trackable.getSpottedType() == cgTrackable.SPOTTED_USER) {
+ } else if (trackable.getSpottedType() == Trackable.SPOTTED_USER) {
text = new StringBuilder(res.getString(R.string.trackable_spotted_at_user) + ' ' + Html.fromHtml(trackable.getSpottedName()).toString());
- } else if (trackable.getSpottedType() == cgTrackable.SPOTTED_UNKNOWN) {
+ } else if (trackable.getSpottedType() == Trackable.SPOTTED_UNKNOWN) {
text = new StringBuilder(res.getString(R.string.trackable_spotted_unknown_location));
- } else if (trackable.getSpottedType() == cgTrackable.SPOTTED_OWNER) {
+ } else if (trackable.getSpottedType() == Trackable.SPOTTED_OWNER) {
text = new StringBuilder(res.getString(R.string.trackable_spotted_owner));
} else {
text = new StringBuilder("N/A");
@@ -576,14 +576,14 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
final TextView spotted = details.add(R.string.trackable_spotted, text.toString());
spotted.setClickable(true);
- if (cgTrackable.SPOTTED_CACHE == trackable.getSpottedType()) {
+ if (Trackable.SPOTTED_CACHE == trackable.getSpottedType()) {
spotted.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
CacheDetailActivity.startActivityGuid(TrackableActivity.this, trackable.getSpottedGuid(), trackable.getSpottedName());
}
});
- } else if (cgTrackable.SPOTTED_USER == trackable.getSpottedType()) {
+ } else if (Trackable.SPOTTED_USER == trackable.getSpottedType()) {
spotted.setOnClickListener(new UserActionsListener());
}
}
diff --git a/main/src/cgeo/geocaching/cgWaypoint.java b/main/src/cgeo/geocaching/Waypoint.java
index 4b7b95e..7a8b787 100644
--- a/main/src/cgeo/geocaching/cgWaypoint.java
+++ b/main/src/cgeo/geocaching/Waypoint.java
@@ -10,7 +10,7 @@ import android.widget.TextView;
import java.util.List;
-public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
+public class Waypoint implements IWaypoint, Comparable<Waypoint> {
public static final String PREFIX_OWN = "OWN";
private static final int ORDER_UNDEFINED = -2;
@@ -32,7 +32,7 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
* @param name
* @param type
*/
- public cgWaypoint(final String name, final WaypointType type, final boolean own) {
+ public Waypoint(final String name, final WaypointType type, final boolean own) {
this.name = name;
this.waypointType = type;
this.own = own;
@@ -43,7 +43,7 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
*
* @param other
*/
- public cgWaypoint(final cgWaypoint other) {
+ public Waypoint(final Waypoint other) {
merge(other);
this.waypointType = other.waypointType;
id = 0;
@@ -53,7 +53,7 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
nameView.setCompoundDrawablesWithIntrinsicBounds(res.getDrawable(waypointType.markerId), null, null, null);
}
- public void merge(final cgWaypoint old) {
+ public void merge(final Waypoint old) {
if (StringUtils.isBlank(prefix)) {
setPrefix(old.prefix);
}
@@ -79,15 +79,15 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
}
}
- public static void mergeWayPoints(List<cgWaypoint> newPoints,
- List<cgWaypoint> oldPoints, boolean forceMerge) {
+ public static void mergeWayPoints(List<Waypoint> newPoints,
+ List<Waypoint> oldPoints, boolean forceMerge) {
// copy user modified details of the waypoints
if (newPoints != null && oldPoints != null) {
- for (cgWaypoint old : oldPoints) {
+ for (Waypoint old : oldPoints) {
if (old != null) {
boolean merged = false;
if (StringUtils.isNotEmpty(old.name)) {
- for (cgWaypoint waypoint : newPoints) {
+ for (Waypoint waypoint : newPoints) {
if (waypoint != null && waypoint.name != null) {
if (old.name.equalsIgnoreCase(waypoint.name)) {
waypoint.merge(old);
@@ -142,7 +142,7 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
}
@Override
- public int compareTo(cgWaypoint other) {
+ public int compareTo(Waypoint other) {
return order() - other.order();
}
diff --git a/main/src/cgeo/geocaching/WaypointPopup.java b/main/src/cgeo/geocaching/WaypointPopup.java
index eb0bc17..cc99abd 100644
--- a/main/src/cgeo/geocaching/WaypointPopup.java
+++ b/main/src/cgeo/geocaching/WaypointPopup.java
@@ -19,7 +19,7 @@ import android.widget.TextView;
public class WaypointPopup extends AbstractPopupActivity {
private static final String EXTRA_WAYPOINT_ID = "waypoint_id";
private int waypointId = 0;
- private cgWaypoint waypoint = null;
+ private Waypoint waypoint = null;
public WaypointPopup() {
super("c:geo-waypoint-info", R.layout.waypoint_popup);
diff --git a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
index 8f61e72..ad421f6 100644
--- a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
+++ b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
@@ -2,7 +2,7 @@ package cgeo.geocaching.apps;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
@@ -68,8 +68,8 @@ public abstract class AbstractLocusApp extends AbstractApp {
// get icon and Point
if (o instanceof cgCache) {
p = getCachePoint((cgCache) o, withCacheWaypoints, withCacheDetails);
- } else if (o instanceof cgWaypoint) {
- p = getWaypointPoint((cgWaypoint) o);
+ } else if (o instanceof Waypoint) {
+ p = getWaypointPoint((Waypoint) o);
}
if (p != null) {
pd.addPoint(p);
@@ -146,7 +146,7 @@ public abstract class AbstractLocusApp extends AbstractApp {
if (withWaypoints && cache.hasWaypoints()) {
pg.waypoints = new ArrayList<PointGeocachingDataWaypoint>();
- for (cgWaypoint waypoint : cache.getWaypoints()) {
+ for (Waypoint waypoint : cache.getWaypoints()) {
if (waypoint == null || waypoint.getCoords() == null) {
continue;
}
@@ -182,7 +182,7 @@ public abstract class AbstractLocusApp extends AbstractApp {
* @param waypoint
* @return null, when the <code>Point</code> could not be constructed
*/
- private static Point getWaypointPoint(cgWaypoint waypoint) {
+ private static Point getWaypointPoint(Waypoint waypoint) {
if (waypoint == null || waypoint.getCoords() == null) {
return null;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
index ca8c7db..67aa849 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
@@ -1,7 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.apps.AbstractApp;
import android.app.Activity;
@@ -25,7 +25,7 @@ abstract class AbstractPointNavigationApp extends AbstractApp implements CacheNa
}
@Override
- public void navigate(Activity activity, cgWaypoint waypoint) {
+ public void navigate(Activity activity, Waypoint waypoint) {
navigate(activity, waypoint.getCoords());
}
@@ -35,7 +35,7 @@ abstract class AbstractPointNavigationApp extends AbstractApp implements CacheNa
}
@Override
- public boolean isEnabled(cgWaypoint waypoint) {
+ public boolean isEnabled(Waypoint waypoint) {
return waypoint.getCoords() != null;
}
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
index 85a4b93..e6bf9f4 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
@@ -4,9 +4,9 @@ import cgeo.geocaching.ILogable;
import cgeo.geocaching.R;
import cgeo.geocaching.StaticMapsActivity;
import cgeo.geocaching.StaticMapsProvider;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
-import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.apps.AbstractApp;
@@ -29,7 +29,7 @@ abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigat
return false;
}
- protected static boolean hasStaticMap(cgWaypoint waypoint) {
+ protected static boolean hasStaticMap(Waypoint waypoint) {
if (waypoint==null) {
return false;
}
@@ -41,7 +41,7 @@ abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigat
return false;
}
- protected static boolean invokeStaticMaps(final Activity activity, final cgCache cache, final cgWaypoint waypoint, final boolean download) {
+ protected static boolean invokeStaticMaps(final Activity activity, final cgCache cache, final Waypoint waypoint, final boolean download) {
final ILogable logable = cache != null && cache.getListId() != 0 ? cache : waypoint;
// If the cache is not stored for offline, cache seems to be null and waypoint may be null too
if (logable==null || logable.getGeocode()==null ) {
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java
index 5275d53..330c338 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java
@@ -1,8 +1,8 @@
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeonavigate;
import cgeo.geocaching.apps.AbstractApp;
import cgeo.geocaching.geopoint.Geopoint;
@@ -27,13 +27,13 @@ class CompassApp extends AbstractApp implements CacheNavigationApp, WaypointNavi
}
@Override
- public void navigate(Activity activity, cgWaypoint waypoint) {
+ public void navigate(Activity activity, Waypoint waypoint) {
cgeonavigate.startActivity(activity, waypoint.getPrefix() + "/" + waypoint.getLookup(), waypoint.getName(), waypoint.getCoords(), null,
waypoint.getWaypointType().getL10n());
}
@Override
- public boolean isEnabled(cgWaypoint waypoint) {
+ public boolean isEnabled(Waypoint waypoint) {
return waypoint.getCoords() != null;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java
index faf3c36..846b9bc 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java
@@ -2,7 +2,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.Waypoint;
import android.app.Activity;
@@ -18,7 +18,7 @@ class DownloadStaticMapsApp extends AbstractStaticMapsApp {
}
@Override
- public boolean isEnabled(cgWaypoint waypoint) {
+ public boolean isEnabled(Waypoint waypoint) {
return !hasStaticMap(waypoint);
}
@@ -28,7 +28,7 @@ class DownloadStaticMapsApp extends AbstractStaticMapsApp {
}
@Override
- public void navigate(Activity activity, cgWaypoint waypoint) {
+ public void navigate(Activity activity, Waypoint waypoint) {
invokeStaticMaps(activity, null, waypoint, true);
}
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
index 8185f40..db842ad 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
@@ -1,8 +1,8 @@
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractApp;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.Geopoint;
@@ -27,12 +27,12 @@ class InternalMap extends AbstractApp implements CacheNavigationApp, WaypointNav
}
@Override
- public void navigate(Activity activity, cgWaypoint waypoint) {
+ public void navigate(Activity activity, Waypoint waypoint) {
CGeoMap.startActivityCoords(activity, waypoint.getCoords(), waypoint.getWaypointType(), waypoint.getName());
}
@Override
- public boolean isEnabled(cgWaypoint waypoint) {
+ public boolean isEnabled(Waypoint waypoint) {
return waypoint.getCoords() != null;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
index a20f2ce..b326105 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
@@ -1,7 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.apps.AbstractLocusApp;
import android.app.Activity;
@@ -11,7 +11,7 @@ import java.util.Collections;
class LocusApp extends AbstractLocusApp implements CacheNavigationApp, WaypointNavigationApp {
@Override
- public boolean isEnabled(cgWaypoint waypoint) {
+ public boolean isEnabled(Waypoint waypoint) {
return waypoint.getCoords() != null;
}
@@ -21,7 +21,7 @@ class LocusApp extends AbstractLocusApp implements CacheNavigationApp, WaypointN
*
*/
@Override
- public void navigate(Activity activity, cgWaypoint waypoint) {
+ public void navigate(Activity activity, Waypoint waypoint) {
showInLocus(Collections.singletonList(waypoint), true, false, activity);
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
index 2f8ce16..8effc05 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -2,8 +2,8 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.Settings;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.apps.AbstractAppFactory;
@@ -96,7 +96,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
* Default way to handle selection of navigation tool.<br />
* A dialog is created for tool selection and the selected tool is started afterwards.
* <p />
- * Delegates to {@link #showNavigationMenu(Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} with
+ * Delegates to {@link #showNavigationMenu(Activity, cgCache, cgeo.geocaching.Waypoint, Geopoint, boolean, boolean)} with
* <code>showInternalMap = true</code> and <code>showDefaultNavigation = false</code>
*
* @param activity
@@ -105,7 +105,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
* @param destination
*/
public static void showNavigationMenu(final Activity activity,
- final cgCache cache, final cgWaypoint waypoint, final Geopoint destination) {
+ final cgCache cache, final Waypoint waypoint, final Geopoint destination) {
showNavigationMenu(activity, cache, waypoint, destination, true, false);
}
@@ -125,10 +125,10 @@ public final class NavigationAppFactory extends AbstractAppFactory {
* @param showDefaultNavigation
* should be <code>false</code> by default
*
- * @see #showNavigationMenu(Activity, cgCache, cgWaypoint, Geopoint)
+ * @see #showNavigationMenu(Activity, cgCache, cgeo.geocaching.Waypoint, Geopoint)
*/
public static void showNavigationMenu(final Activity activity,
- final cgCache cache, final cgWaypoint waypoint, final Geopoint destination,
+ final cgCache cache, final Waypoint waypoint, final Geopoint destination,
final boolean showInternalMap, final boolean showDefaultNavigation) {
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.cache_menu_navigate);
@@ -219,7 +219,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
* Use {@link #onMenuItemSelected(MenuItem, Activity, cgCache)} on
* selection event to start the selected navigation tool.
*
- * <b>Only use this way if {@link #showNavigationMenu(Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} is
+ * <b>Only use this way if {@link #showNavigationMenu(Activity, cgCache, cgeo.geocaching.Waypoint, Geopoint, boolean, boolean)} is
* not suitable for the given usecase.</b>
*
* @param menu
@@ -235,7 +235,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
}
}
- public static void addMenuItems(final Menu menu, final cgWaypoint waypoint) {
+ public static void addMenuItems(final Menu menu, final Waypoint waypoint) {
for (NavigationAppsEnum navApp : getInstalledNavigationApps()) {
if (navApp.app instanceof WaypointNavigationApp) {
WaypointNavigationApp waypointApp = (WaypointNavigationApp) navApp.app;
@@ -267,13 +267,13 @@ public final class NavigationAppFactory extends AbstractAppFactory {
}
}
- public static boolean onMenuItemSelected(final MenuItem item, Activity activity, cgWaypoint waypoint) {
+ public static boolean onMenuItemSelected(final MenuItem item, Activity activity, Waypoint waypoint) {
final App menuItem = getAppFromMenuItem(item);
navigateWaypoint(activity, waypoint, menuItem);
return menuItem != null;
}
- private static void navigateWaypoint(Activity activity, cgWaypoint waypoint, App app) {
+ private static void navigateWaypoint(Activity activity, Waypoint waypoint, App app) {
if (app instanceof WaypointNavigationApp) {
WaypointNavigationApp waypointApp = (WaypointNavigationApp) app;
waypointApp.navigate(activity, waypoint);
@@ -327,7 +327,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
* @param activity
* @param waypoint
*/
- public static void startDefaultNavigationApplication(int defaultNavigation, Activity activity, cgWaypoint waypoint) {
+ public static void startDefaultNavigationApplication(int defaultNavigation, Activity activity, Waypoint waypoint) {
if (waypoint == null || waypoint.getCoords() == null) {
ActivityMixin.showToast(activity, cgeoapplication.getInstance().getString(R.string.err_location_unknown));
return;
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
index a481813..c94c4f4 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
@@ -1,8 +1,8 @@
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractApp;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.GeopointFormatter.Format;
@@ -21,7 +21,7 @@ class RMapsApp extends AbstractApp implements CacheNavigationApp, WaypointNaviga
}
@Override
- public void navigate(Activity activity, cgWaypoint waypoint) {
+ public void navigate(Activity activity, Waypoint waypoint) {
navigate(activity, waypoint.getCoords(), waypoint.getLookup(), waypoint.getName());
}
@@ -34,7 +34,7 @@ class RMapsApp extends AbstractApp implements CacheNavigationApp, WaypointNaviga
}
@Override
- public boolean isEnabled(cgWaypoint waypoint) {
+ public boolean isEnabled(Waypoint waypoint) {
return waypoint.getCoords() != null;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
index eb01f23..4c3b87e 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
@@ -1,8 +1,8 @@
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
import android.app.Activity;
@@ -18,7 +18,7 @@ class StaticMapApp extends AbstractStaticMapsApp {
}
@Override
- public boolean isEnabled(cgWaypoint waypoint) {
+ public boolean isEnabled(Waypoint waypoint) {
return hasStaticMap(waypoint);
}
@@ -28,7 +28,7 @@ class StaticMapApp extends AbstractStaticMapsApp {
}
@Override
- public void navigate(Activity activity, cgWaypoint waypoint) {
+ public void navigate(Activity activity, Waypoint waypoint) {
invokeStaticMaps(activity, null, waypoint, false);
}
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java
index 7d3a706..c26ec3e 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java
@@ -1,6 +1,6 @@
package cgeo.geocaching.apps.cache.navi;
-import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.Waypoint;
import android.app.Activity;
@@ -9,7 +9,7 @@ import android.app.Activity;
*
*/
public interface WaypointNavigationApp {
- void navigate(final Activity activity, final cgWaypoint waypoint);
+ void navigate(final Activity activity, final Waypoint waypoint);
- boolean isEnabled(final cgWaypoint waypoint);
+ boolean isEnabled(final Waypoint waypoint);
}
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index 19df7e3..6ef6d06 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -101,20 +101,20 @@ public class cgCache implements ICache, IWaypoint {
return cgData.loadAttributes(geocode);
}
};
- private LazyInitializedList<cgWaypoint> waypoints = new LazyInitializedList<cgWaypoint>() {
+ private LazyInitializedList<Waypoint> waypoints = new LazyInitializedList<Waypoint>() {
@Override
- protected List<cgWaypoint> loadFromDatabase() {
+ protected List<Waypoint> loadFromDatabase() {
return cgData.loadWaypoints(geocode);
}
};
- private List<cgImage> spoilers = null;
+ private List<Image> spoilers = null;
private LazyInitializedList<LogEntry> logs = new LazyInitializedList<LogEntry>() {
@Override
protected List<LogEntry> loadFromDatabase() {
return cgData.loadLogs(geocode);
}
};
- private List<cgTrackable> inventory = null;
+ private List<Trackable> inventory = null;
private Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>();
private boolean logOffline = false;
private boolean userModifiedCoords = false;
@@ -146,7 +146,7 @@ public class cgCache implements ICache, IWaypoint {
public cgCache(GPXParser gpxParser) {
setReliableLatLon(true);
setAttributes(Collections.<String> emptyList());
- setWaypoints(Collections.<cgWaypoint> emptyList(), false);
+ setWaypoints(Collections.<Waypoint> emptyList(), false);
setLogs(Collections.<LogEntry> emptyList());
}
@@ -295,8 +295,8 @@ public class cgCache implements ICache, IWaypoint {
this.setWaypoints(other.waypoints.asList(), false);
}
else {
- ArrayList<cgWaypoint> newPoints = new ArrayList<cgWaypoint>(waypoints.asList());
- cgWaypoint.mergeWayPoints(newPoints, other.waypoints.asList(), false);
+ ArrayList<Waypoint> newPoints = new ArrayList<Waypoint>(waypoints.asList());
+ Waypoint.mergeWayPoints(newPoints, other.waypoints.asList(), false);
this.setWaypoints(newPoints, false);
}
if (spoilers == null) {
@@ -320,7 +320,7 @@ public class cgCache implements ICache, IWaypoint {
// if cache has ORIGINAL type waypoint ... it is considered that it has modified coordinates, otherwise not
userModifiedCoords = false;
if (waypoints != null) {
- for (cgWaypoint wpt : waypoints) {
+ for (Waypoint wpt : waypoints) {
if (wpt.getWaypointType() == WaypointType.ORIGINAL) {
userModifiedCoords = true;
break;
@@ -724,19 +724,19 @@ public class cgCache implements ICache, IWaypoint {
}
@Override
- public List<cgTrackable> getInventory() {
+ public List<Trackable> getInventory() {
return inventory;
}
- public void addSpoiler(final cgImage spoiler) {
+ public void addSpoiler(final Image spoiler) {
if (spoilers == null) {
- spoilers = new ArrayList<cgImage>();
+ spoilers = new ArrayList<Image>();
}
spoilers.add(spoiler);
}
@Override
- public List<cgImage> getSpoilers() {
+ public List<Image> getSpoilers() {
if (spoilers == null) {
return Collections.emptyList();
}
@@ -934,7 +934,7 @@ public class cgCache implements ICache, IWaypoint {
*
* @return always non <code>null</code>
*/
- public List<cgWaypoint> getWaypoints() {
+ public List<Waypoint> getWaypoints() {
return waypoints.asList();
}
@@ -946,11 +946,11 @@ public class cgCache implements ICache, IWaypoint {
* called while loading or building a cache
* @return <code>true</code> if waypoints successfully added to waypoint database
*/
- public boolean setWaypoints(List<cgWaypoint> waypoints, boolean saveToDatabase) {
+ public boolean setWaypoints(List<Waypoint> waypoints, boolean saveToDatabase) {
this.waypoints.set(waypoints);
finalDefined = false;
if (waypoints != null) {
- for (cgWaypoint waypoint : waypoints) {
+ for (Waypoint waypoint : waypoints) {
waypoint.setGeocode(geocode);
if (waypoint.isFinalWithCoords()) {
finalDefined = true;
@@ -1085,11 +1085,11 @@ public class cgCache implements ICache, IWaypoint {
this.attributes.set(attributes);
}
- public void setSpoilers(List<cgImage> spoilers) {
+ public void setSpoilers(List<Image> spoilers) {
this.spoilers = spoilers;
}
- public void setInventory(List<cgTrackable> inventory) {
+ public void setInventory(List<Trackable> inventory) {
this.inventory = inventory;
}
@@ -1147,7 +1147,7 @@ public class cgCache implements ICache, IWaypoint {
* called while loading or building a cache
* @return <code>true</code> if waypoint successfully added to waypoint database
*/
- public boolean addOrChangeWaypoint(final cgWaypoint waypoint, boolean saveToDatabase) {
+ public boolean addOrChangeWaypoint(final Waypoint waypoint, boolean saveToDatabase) {
waypoint.setGeocode(geocode);
if (waypoint.getId() <= 0) { // this is a new waypoint
@@ -1185,7 +1185,7 @@ public class cgCache implements ICache, IWaypoint {
*/
private void resetFinalDefined() {
finalDefined = false;
- for (cgWaypoint wp : waypoints) {
+ for (Waypoint wp : waypoints) {
if (wp.isFinalWithCoords()) {
finalDefined = true;
break;
@@ -1208,12 +1208,12 @@ public class cgCache implements ICache, IWaypoint {
* the waypoint to duplicate
* @return <code>true</code> if the waypoint was duplicated, <code>false</code> otherwise (invalid index)
*/
- public boolean duplicateWaypoint(final cgWaypoint original) {
+ public boolean duplicateWaypoint(final Waypoint original) {
if (original == null) {
return false;
}
final int index = getWaypointIndex(original);
- final cgWaypoint copy = new cgWaypoint(original);
+ final Waypoint copy = new Waypoint(original);
copy.setUserDefined();
copy.setName(cgeoapplication.getInstance().getString(R.string.waypoint_copy_of) + " " + copy.getName());
waypoints.add(index + 1, copy);
@@ -1227,7 +1227,7 @@ public class cgCache implements ICache, IWaypoint {
* to be removed from cache
* @return <code>true</code>, if the waypoint was deleted
*/
- public boolean deleteWaypoint(final cgWaypoint waypoint) {
+ public boolean deleteWaypoint(final Waypoint waypoint) {
if (waypoint == null) {
return false;
}
@@ -1254,7 +1254,7 @@ public class cgCache implements ICache, IWaypoint {
* @param waypoint
*/
- public void deleteWaypointForce(cgWaypoint waypoint) {
+ public void deleteWaypointForce(Waypoint waypoint) {
final int index = getWaypointIndex(waypoint);
waypoints.remove(index);
cgData.deleteWaypoint(waypoint.getId());
@@ -1269,7 +1269,7 @@ public class cgCache implements ICache, IWaypoint {
* to find index for
* @return index in <code>waypoints</code> if found, -1 otherwise
*/
- private int getWaypointIndex(final cgWaypoint waypoint) {
+ private int getWaypointIndex(final Waypoint waypoint) {
final int id = waypoint.getId();
for (int index = 0; index < waypoints.size(); index++) {
if (waypoints.get(index).getId() == id) {
@@ -1286,7 +1286,7 @@ public class cgCache implements ICache, IWaypoint {
* the index of the waypoint
* @return waypoint or <code>null</code> if index is out of range
*/
- public cgWaypoint getWaypoint(final int index) {
+ public Waypoint getWaypoint(final int index) {
return index >= 0 && index < waypoints.size() ? waypoints.get(index) : null;
}
@@ -1297,8 +1297,8 @@ public class cgCache implements ICache, IWaypoint {
* the id of the waypoint to look for
* @return waypoint or <code>null</code>
*/
- public cgWaypoint getWaypointById(final int id) {
- for (final cgWaypoint waypoint : waypoints) {
+ public Waypoint getWaypointById(final int id) {
+ for (final Waypoint waypoint : waypoints) {
if (waypoint.getId() == id) {
return waypoint;
}
@@ -1321,7 +1321,7 @@ public class cgCache implements ICache, IWaypoint {
// coords must have non zero latitude and longitude and at least one part shall have fractional degrees
if (point.getLatitudeE6() != 0 && point.getLongitudeE6() != 0 && ((point.getLatitudeE6() % 1000) != 0 || (point.getLongitudeE6() % 1000) != 0)) {
final String name = cgeoapplication.getInstance().getString(R.string.cache_personal_note) + " " + count;
- final cgWaypoint waypoint = new cgWaypoint(name, WaypointType.WAYPOINT, false);
+ final Waypoint waypoint = new Waypoint(name, WaypointType.WAYPOINT, false);
waypoint.setCoords(point);
addOrChangeWaypoint(waypoint, false);
count++;
@@ -1492,7 +1492,7 @@ public class cgCache implements ICache, IWaypoint {
// store spoilers
if (CollectionUtils.isNotEmpty(cache.getSpoilers())) {
- for (cgImage oneSpoiler : cache.getSpoilers()) {
+ for (Image oneSpoiler : cache.getSpoilers()) {
imgGetter.getDrawable(oneSpoiler.getUrl());
}
}
@@ -1505,7 +1505,7 @@ public class cgCache implements ICache, IWaypoint {
if (Settings.isStoreLogImages()) {
for (LogEntry log : cache.getLogs()) {
if (log.hasLogImages()) {
- for (cgImage oneLogImg : log.getLogImages()) {
+ for (Image oneLogImg : log.getLogImages()) {
imgGetter.getDrawable(oneLogImg.getUrl());
}
}
@@ -1624,12 +1624,19 @@ public class cgCache implements ICache, IWaypoint {
return StaticMapsProvider.hasStaticMap(this);
}
- public List<cgImage> getImages() {
- List<cgImage> result = new ArrayList<cgImage>();
+ public List<Image> getImages() {
+ List<Image> result = new ArrayList<Image>();
result.addAll(getSpoilers());
for (LogEntry log : getLogs()) {
result.addAll(log.getLogImages());
}
return result;
}
+
+ public void setDetailedUpdatedNow() {
+ final long now = System.currentTimeMillis();
+ setUpdated(now);
+ setDetailedUpdate(now);
+ setDetailed(true);
+ }
}
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index e8865c7..b9adafe 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -775,12 +775,9 @@ public class cgData {
public static String[] getRecentGeocodesForSearch() {
init();
- Cursor cursor = null;
- List<String> list = new ArrayList<String>();
-
try {
long timestamp = System.currentTimeMillis() - DAYS_AFTER_CACHE_IS_DELETED;
- cursor = database.query(
+ final Cursor cursor = database.query(
dbTableCaches,
new String[]{"geocode"},
"(detailed = 1 and detailedupdate > ?) or reason > 0",
@@ -790,42 +787,23 @@ public class cgData {
"detailedupdate desc",
"100");
- if (cursor != null) {
-
- if (cursor.getCount() > 0) {
- cursor.moveToFirst();
- int index = cursor.getColumnIndex("geocode");
-
- do {
- list.add(cursor.getString(index));
- } while (cursor.moveToNext());
- } else {
- cursor.close();
- return null;
- }
- }
- } catch (Exception e) {
+ return getFirstColumn(cursor);
+ } catch (final Exception e) {
Log.e("cgData.allDetailedThere", e);
+ return new String[0];
}
-
- if (cursor != null) {
- cursor.close();
- }
-
- return list.toArray(new String[list.size()]);
}
public static boolean isThere(String geocode, String guid, boolean detailed, boolean checkTime) {
init();
- Cursor cursor = null;
-
- int cnt = 0;
long dataUpdated = 0;
long dataDetailedUpdate = 0;
int dataDetailed = 0;
try {
+ Cursor cursor;
+
if (StringUtils.isNotBlank(geocode)) {
cursor = database.query(
dbTableCaches,
@@ -850,50 +828,34 @@ public class cgData {
return false;
}
- if (cursor != null) {
- cnt = cursor.getCount();
-
- if (cnt > 0) {
- cursor.moveToFirst();
-
- int index = cursor.getColumnIndex("updated");
- dataUpdated = cursor.getLong(index);
- index = cursor.getColumnIndex("detailedupdate");
- dataDetailedUpdate = cursor.getLong(index);
- index = cursor.getColumnIndex("detailed");
- dataDetailed = cursor.getInt(index);
- }
+ if (cursor.moveToFirst()) {
+ dataDetailed = cursor.getInt(0);
+ dataDetailedUpdate = cursor.getLong(1);
+ dataUpdated = cursor.getLong(2);
}
- } catch (Exception e) {
- Log.e("cgData.isThere", e);
- }
- if (cursor != null) {
cursor.close();
+ } catch (final Exception e) {
+ Log.e("cgData.isThere", e);
}
- if (cnt > 0) {
- if (detailed && dataDetailed == 0) {
- // we want details, but these are not stored
- return false;
- }
-
- if (checkTime && detailed && dataDetailedUpdate < (System.currentTimeMillis() - DAYS_AFTER_CACHE_IS_DELETED)) {
- // we want to check time for detailed cache, but data are older than 3 hours
- return false;
- }
+ if (detailed && dataDetailed == 0) {
+ // we want details, but these are not stored
+ return false;
+ }
- if (checkTime && !detailed && dataUpdated < (System.currentTimeMillis() - DAYS_AFTER_CACHE_IS_DELETED)) {
- // we want to check time for short cache, but data are older than 3 hours
- return false;
- }
+ if (checkTime && detailed && dataDetailedUpdate < (System.currentTimeMillis() - DAYS_AFTER_CACHE_IS_DELETED)) {
+ // we want to check time for detailed cache, but data are older than 3 hours
+ return false;
+ }
- // we have some cache
- return true;
+ if (checkTime && !detailed && dataUpdated < (System.currentTimeMillis() - DAYS_AFTER_CACHE_IS_DELETED)) {
+ // we want to check time for short cache, but data are older than 3 hours
+ return false;
}
- // we have no such cache stored in cache
- return false;
+ // we have some cache
+ return true;
}
/** is cache stored in one of the lists (not only temporary) */
@@ -1150,11 +1112,11 @@ public class cgData {
String geocode = cache.getGeocode();
database.delete(dbTableWaypoints, "geocode = ? and type <> ? and own = 0", new String[]{geocode, "own"});
- List<cgWaypoint> waypoints = cache.getWaypoints();
+ List<Waypoint> waypoints = cache.getWaypoints();
if (CollectionUtils.isNotEmpty(waypoints)) {
ContentValues values = new ContentValues();
long timeStamp = System.currentTimeMillis();
- for (cgWaypoint oneWaypoint : waypoints) {
+ for (Waypoint oneWaypoint : waypoints) {
if (oneWaypoint.isUserDefined()) {
continue;
}
@@ -1209,7 +1171,7 @@ public class cgData {
return new Geopoint(cursor.getDouble(indexLat), cursor.getDouble(indexLon));
}
- private static boolean saveWaypointInternal(int id, String geocode, cgWaypoint waypoint) {
+ private static boolean saveWaypointInternal(int id, String geocode, Waypoint waypoint) {
if ((StringUtils.isBlank(geocode) && id <= 0) || waypoint == null) {
return false;
}
@@ -1261,11 +1223,11 @@ public class cgData {
String geocode = cache.getGeocode();
database.delete(dbTableSpoilers, "geocode = ?", new String[]{geocode});
- List<cgImage> spoilers = cache.getSpoilers();
+ List<Image> spoilers = cache.getSpoilers();
if (CollectionUtils.isNotEmpty(spoilers)) {
SQLiteStatement insertSpoiler = PreparedStatements.getInsertSpoiler();
final long timestamp = System.currentTimeMillis();
- for (cgImage spoiler : spoilers) {
+ for (Image spoiler : spoilers) {
insertSpoiler.bindString(1, geocode);
insertSpoiler.bindLong(2, timestamp);
insertSpoiler.bindString(3, spoiler.getUrl());
@@ -1304,7 +1266,7 @@ public class cgData {
long logId = insertLog.executeInsert();
if (log.hasLogImages()) {
SQLiteStatement insertImage = PreparedStatements.getInsertLogImage();
- for (cgImage img : log.getLogImages()) {
+ for (Image img : log.getLogImages()) {
insertImage.bindLong(1, logId);
insertImage.bindString(2, img.getTitle());
insertImage.bindString(3, img.getUrl());
@@ -1334,7 +1296,7 @@ public class cgData {
}
}
- public static boolean saveTrackable(final cgTrackable trackable) {
+ public static boolean saveTrackable(final Trackable trackable) {
init();
database.beginTransaction();
@@ -1348,7 +1310,7 @@ public class cgData {
return true;
}
- private static void saveInventoryWithoutTransaction(final String geocode, final List<cgTrackable> trackables) {
+ private static void saveInventoryWithoutTransaction(final String geocode, final List<Trackable> trackables) {
if (geocode != null) {
database.delete(dbTableTrackables, "geocode = ?", new String[]{geocode});
}
@@ -1356,7 +1318,7 @@ public class cgData {
if (CollectionUtils.isNotEmpty(trackables)) {
ContentValues values = new ContentValues();
long timeStamp = System.currentTimeMillis();
- for (cgTrackable trackable : trackables) {
+ for (Trackable trackable : trackables) {
final String tbCode = trackable.getGeocode();
if (StringUtils.isNotBlank(tbCode)) {
database.delete(dbTableTrackables, "tbcode = ?", new String[] { tbCode });
@@ -1500,13 +1462,10 @@ public class cgData {
Cursor cursor = database.rawQuery(query.toString(), null);
try {
- if (!cursor.moveToFirst()) {
- return Collections.emptySet();
- }
-
final Set<cgCache> caches = new HashSet<cgCache>();
int logIndex = -1;
- do {
+
+ while (cursor.moveToNext()) {
cgCache cache = cgData.createCacheFromDatabaseContent(cursor);
if (loadFlags.contains(LoadFlag.LOAD_ATTRIBUTES)) {
@@ -1514,14 +1473,14 @@ public class cgData {
}
if (loadFlags.contains(LoadFlag.LOAD_WAYPOINTS)) {
- final List<cgWaypoint> waypoints = loadWaypoints(cache.getGeocode());
+ final List<Waypoint> waypoints = loadWaypoints(cache.getGeocode());
if (CollectionUtils.isNotEmpty(waypoints)) {
cache.setWaypoints(waypoints, false);
}
}
if (loadFlags.contains(LoadFlag.LOAD_SPOILERS)) {
- final List<cgImage> spoilers = loadSpoilers(cache.getGeocode());
+ final List<Image> spoilers = loadSpoilers(cache.getGeocode());
cache.setSpoilers(spoilers);
}
@@ -1535,10 +1494,10 @@ public class cgData {
}
if (loadFlags.contains(LoadFlag.LOAD_INVENTORY)) {
- final List<cgTrackable> inventory = loadInventory(cache.getGeocode());
+ final List<Trackable> inventory = loadInventory(cache.getGeocode());
if (CollectionUtils.isNotEmpty(inventory)) {
if (cache.getInventory() == null) {
- cache.setInventory(new ArrayList<cgTrackable>());
+ cache.setInventory(new ArrayList<Trackable>());
} else {
cache.getInventory().clear();
}
@@ -1703,9 +1662,9 @@ public class cgData {
init();
- ArrayList<String> attributes = new ArrayList<String>();
+ final ArrayList<String> attributes = new ArrayList<String>();
- Cursor cursor = database.query(
+ final Cursor cursor = database.query(
dbTableAttributes,
new String[]{"attribute"},
"geocode = ?",
@@ -1715,30 +1674,23 @@ public class cgData {
null,
"100");
- if (cursor != null && cursor.getCount() > 0) {
- cursor.moveToFirst();
- int index = cursor.getColumnIndex("attribute");
-
- do {
- attributes.add(cursor.getString(index));
- } while (cursor.moveToNext());
+ while (cursor.moveToNext()) {
+ attributes.add(cursor.getString(0));
}
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return attributes;
}
- public static cgWaypoint loadWaypoint(int id) {
+ public static Waypoint loadWaypoint(int id) {
if (id == 0) {
return null;
}
init();
- Cursor cursor = database.query(
+ final Cursor cursor = database.query(
dbTableWaypoints,
WAYPOINT_COLUMNS,
"_id = ?",
@@ -1750,30 +1702,23 @@ public class cgData {
Log.d("cgData.loadWaypoint(" + id + ")");
- cgWaypoint waypoint = null;
- if (cursor != null && cursor.getCount() > 0) {
- cursor.moveToFirst();
+ final Waypoint waypoint = cursor.moveToFirst() ? createWaypointFromDatabaseContent(cursor) : null;
- waypoint = createWaypointFromDatabaseContent(cursor);
- }
-
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return waypoint;
}
- public static List<cgWaypoint> loadWaypoints(final String geocode) {
+ public static List<Waypoint> loadWaypoints(final String geocode) {
if (StringUtils.isBlank(geocode)) {
return null;
}
init();
- List<cgWaypoint> waypoints = new ArrayList<cgWaypoint>();
+ final List<Waypoint> waypoints = new ArrayList<Waypoint>();
- Cursor cursor = database.query(
+ final Cursor cursor = database.query(
dbTableWaypoints,
WAYPOINT_COLUMNS,
"geocode = ?",
@@ -1783,29 +1728,20 @@ public class cgData {
"_id",
"100");
- if (cursor != null && cursor.getCount() > 0) {
- cursor.moveToFirst();
-
- do {
-
- cgWaypoint waypoint = createWaypointFromDatabaseContent(cursor);
-
- waypoints.add(waypoint);
- } while (cursor.moveToNext());
+ while (cursor.moveToNext()) {
+ waypoints.add(createWaypointFromDatabaseContent(cursor));
}
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return waypoints;
}
- private static cgWaypoint createWaypointFromDatabaseContent(Cursor cursor) {
- String name = cursor.getString(cursor.getColumnIndex("name"));
- WaypointType type = WaypointType.findById(cursor.getString(cursor.getColumnIndex("type")));
- boolean own = cursor.getInt(cursor.getColumnIndex("own")) != 0;
- cgWaypoint waypoint = new cgWaypoint(name, type, own);
+ private static Waypoint createWaypointFromDatabaseContent(final Cursor cursor) {
+ final String name = cursor.getString(cursor.getColumnIndex("name"));
+ final WaypointType type = WaypointType.findById(cursor.getString(cursor.getColumnIndex("type")));
+ final boolean own = cursor.getInt(cursor.getColumnIndex("own")) != 0;
+ final Waypoint waypoint = new Waypoint(name, type, own);
waypoint.setId(cursor.getInt(cursor.getColumnIndex("_id")));
waypoint.setGeocode(cursor.getString(cursor.getColumnIndex("geocode")));
@@ -1818,16 +1754,16 @@ public class cgData {
return waypoint;
}
- private static List<cgImage> loadSpoilers(String geocode) {
+ private static List<Image> loadSpoilers(final String geocode) {
if (StringUtils.isBlank(geocode)) {
return null;
}
init();
- List<cgImage> spoilers = new ArrayList<cgImage>();
+ final List<Image> spoilers = new ArrayList<Image>();
- Cursor cursor = database.query(
+ final Cursor cursor = database.query(
dbTableSpoilers,
new String[]{"url", "title", "description"},
"geocode = ?",
@@ -1837,22 +1773,11 @@ public class cgData {
null,
"100");
- if (cursor != null && cursor.getCount() > 0) {
- cursor.moveToFirst();
- int indexUrl = cursor.getColumnIndex("url");
- int indexTitle = cursor.getColumnIndex("title");
- int indexDescription = cursor.getColumnIndex("description");
-
- do {
- cgImage spoiler = new cgImage(cursor.getString(indexUrl), cursor.getString(indexTitle), cursor.getString(indexDescription));
-
- spoilers.add(spoiler);
- } while (cursor.moveToNext());
+ while (cursor.moveToNext()) {
+ spoilers.add(new Image(cursor.getString(0), cursor.getString(1), cursor.getString(2)));
}
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return spoilers;
}
@@ -1866,7 +1791,7 @@ public class cgData {
public static List<Destination> loadHistoryOfSearchedLocations() {
init();
- Cursor cursor = database.query(dbTableSearchDestionationHistory,
+ final Cursor cursor = database.query(dbTableSearchDestionationHistory,
new String[]{"_id", "date", "latitude", "longitude"},
null,
null,
@@ -1877,27 +1802,16 @@ public class cgData {
final List<Destination> destinations = new LinkedList<Destination>();
- if (cursor != null && cursor.getCount() > 0) {
- cursor.moveToFirst();
- int indexId = cursor.getColumnIndex("_id");
- int indexDate = cursor.getColumnIndex("date");
- int indexLatitude = cursor.getColumnIndex("latitude");
- int indexLongitude = cursor.getColumnIndex("longitude");
-
- do {
- final Destination dest = new Destination(cursor.getLong(indexId), cursor.getLong(indexDate), getCoords(cursor, indexLatitude, indexLongitude));
+ while (cursor.moveToNext()) {
+ final Destination dest = new Destination(cursor.getLong(0), cursor.getLong(1), getCoords(cursor, 2, 3));
- // If coordinates are non-existent or invalid, do not consider
- // this point.
- if (dest.getCoords() != null) {
- destinations.add(dest);
- }
- } while (cursor.moveToNext());
+ // If coordinates are non-existent or invalid, do not consider this point.
+ if (dest.getCoords() != null) {
+ destinations.add(dest);
+ }
}
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return destinations;
}
@@ -1929,46 +1843,31 @@ public class cgData {
init();
- Cursor cursor = database.rawQuery(
- "SELECT cg_logs._id as cg_logs_id, type, author, log, date, found, friend, " + dbTableLogImages + "._id as cg_logImages_id, log_id, title, url FROM "
- + dbTableLogs + " LEFT OUTER JOIN " + dbTableLogImages
+ final Cursor cursor = database.rawQuery(
+ /* 0 1 2 3 4 5 6 7 8 9 10 */
+ "SELECT cg_logs._id as cg_logs_id, type, author, log, date, found, friend, " + dbTableLogImages + "._id as cg_logImages_id, log_id, title, url"
+ + " FROM " + dbTableLogs + " LEFT OUTER JOIN " + dbTableLogImages
+ " ON ( cg_logs._id = log_id ) WHERE geocode = ? ORDER BY date desc, cg_logs._id asc", new String[]{geocode});
- if (cursor != null && cursor.getCount() > 0) {
- LogEntry log = null;
- int indexLogsId = cursor.getColumnIndex("cg_logs_id");
- int indexType = cursor.getColumnIndex("type");
- int indexAuthor = cursor.getColumnIndex("author");
- int indexLog = cursor.getColumnIndex("log");
- int indexDate = cursor.getColumnIndex("date");
- int indexFound = cursor.getColumnIndex("found");
- int indexFriend = cursor.getColumnIndex("friend");
- int indexLogImagesId = cursor.getColumnIndex("cg_logImages_id");
- int indexTitle = cursor.getColumnIndex("title");
- int indexUrl = cursor.getColumnIndex("url");
- while (cursor.moveToNext() && logs.size() < 100) {
- if (log == null || log.id != cursor.getInt(indexLogsId)) {
- log = new LogEntry(
- cursor.getString(indexAuthor),
- cursor.getLong(indexDate),
- LogType.getById(cursor.getInt(indexType)),
- cursor.getString(indexLog));
- log.id = cursor.getInt(indexLogsId);
- log.found = cursor.getInt(indexFound);
- log.friend = cursor.getInt(indexFriend) == 1;
- logs.add(log);
- }
- if (!cursor.isNull(indexLogImagesId)) {
- String title = cursor.getString(indexTitle);
- String url = cursor.getString(indexUrl);
- log.addLogImage(new cgImage(url, title));
- }
+ LogEntry log = null;
+ while (cursor.moveToNext() && logs.size() < 100) {
+ if (log == null || log.id != cursor.getInt(0)) {
+ log = new LogEntry(
+ cursor.getString(2),
+ cursor.getLong(4),
+ LogType.getById(cursor.getInt(1)),
+ cursor.getString(3));
+ log.id = cursor.getInt(0);
+ log.found = cursor.getInt(5);
+ log.friend = cursor.getInt(6) == 1;
+ logs.add(log);
+ }
+ if (!cursor.isNull(7)) {
+ log.addLogImage(new Image(cursor.getString(10), cursor.getString(9)));
}
}
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return logs;
}
@@ -1980,9 +1879,9 @@ public class cgData {
init();
- Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>();
+ final Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>();
- Cursor cursor = database.query(
+ final Cursor cursor = database.query(
dbTableLogCount,
new String[]{"type", "count"},
"geocode = ?",
@@ -1992,36 +1891,25 @@ public class cgData {
null,
"100");
- if (cursor != null && cursor.getCount() > 0) {
- cursor.moveToFirst();
- int indexType = cursor.getColumnIndex("type");
- int indexCount = cursor.getColumnIndex("count");
-
- do {
- LogType type = LogType.getById(cursor.getInt(indexType));
- Integer count = cursor.getInt(indexCount);
-
- logCounts.put(type, count);
- } while (cursor.moveToNext());
+ while (cursor.moveToNext()) {
+ logCounts.put(LogType.getById(cursor.getInt(0)), cursor.getInt(1));
}
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return logCounts;
}
- private static List<cgTrackable> loadInventory(String geocode) {
+ private static List<Trackable> loadInventory(String geocode) {
if (StringUtils.isBlank(geocode)) {
return null;
}
init();
- List<cgTrackable> trackables = new ArrayList<cgTrackable>();
+ final List<Trackable> trackables = new ArrayList<Trackable>();
- Cursor cursor = database.query(
+ final Cursor cursor = database.query(
dbTableTrackables,
new String[]{"_id", "updated", "tbcode", "guid", "title", "owner", "released", "goal", "description"},
"geocode = ?",
@@ -2031,33 +1919,23 @@ public class cgData {
"title COLLATE NOCASE ASC",
"100");
- if (cursor != null && cursor.getCount() > 0) {
- cursor.moveToFirst();
-
- do {
- cgTrackable trackable = createTrackableFromDatabaseContent(cursor);
-
- trackables.add(trackable);
- } while (cursor.moveToNext());
+ while (cursor.moveToNext()) {
+ trackables.add(createTrackableFromDatabaseContent(cursor));
}
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return trackables;
}
- public static cgTrackable loadTrackable(String geocode) {
+ public static Trackable loadTrackable(final String geocode) {
if (StringUtils.isBlank(geocode)) {
return null;
}
init();
- cgTrackable trackable = new cgTrackable();
-
- Cursor cursor = database.query(
+ final Cursor cursor = database.query(
dbTableTrackables,
new String[]{"updated", "tbcode", "guid", "title", "owner", "released", "goal", "description"},
"tbcode = ?",
@@ -2067,30 +1945,25 @@ public class cgData {
null,
"1");
- if (cursor != null && cursor.getCount() > 0) {
- cursor.moveToFirst();
- trackable = createTrackableFromDatabaseContent(cursor);
- }
+ final Trackable trackable = cursor.moveToFirst() ? createTrackableFromDatabaseContent(cursor) : null;
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return trackable;
}
- private static cgTrackable createTrackableFromDatabaseContent(Cursor cursor) {
- cgTrackable trackable = new cgTrackable();
+ private static Trackable createTrackableFromDatabaseContent(final Cursor cursor) {
+ final Trackable trackable = new Trackable();
trackable.setGeocode(cursor.getString(cursor.getColumnIndex("tbcode")));
trackable.setGuid(cursor.getString(cursor.getColumnIndex("guid")));
trackable.setName(cursor.getString(cursor.getColumnIndex("title")));
trackable.setOwner(cursor.getString(cursor.getColumnIndex("owner")));
- String released = cursor.getString(cursor.getColumnIndex("released"));
+ final String released = cursor.getString(cursor.getColumnIndex("released"));
if (released != null) {
try {
long releaseMilliSeconds = Long.parseLong(released);
trackable.setReleased(new Date(releaseMilliSeconds));
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
Log.e("createTrackableFromDatabaseContent", e);
}
}
@@ -2220,17 +2093,12 @@ public class cgData {
"geocode");
}
- if (cursor.moveToFirst()) {
- final int index = cursor.getColumnIndex("geocode");
-
- do {
- geocodes.add(cursor.getString(index));
- } while (cursor.moveToNext());
+ while (cursor.moveToNext()) {
+ geocodes.add(cursor.getString(0));
}
cursor.close();
-
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.e("cgData.loadBatchOfStoredGeocodes", e);
}
@@ -2332,15 +2200,12 @@ public class cgData {
null,
"500");
- if (cursor.moveToFirst()) {
- final int index = cursor.getColumnIndex("geocode");
-
- do {
- geocodes.add(cursor.getString(index));
- } while (cursor.moveToNext());
+ while (cursor.moveToNext()) {
+ geocodes.add(cursor.getString(0));
}
+
cursor.close();
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.e("cgData.loadInViewport", e);
}
@@ -2358,7 +2223,7 @@ public class cgData {
* @param more
* true = all caches false = caches stored 3 days or more before
*/
- public static void clean(boolean more) {
+ public static void clean(final boolean more) {
if (databaseCleaned) {
return;
}
@@ -2367,8 +2232,6 @@ public class cgData {
Log.d("Database clean: started");
- Set<String> geocodes = new HashSet<String>();
-
try {
Cursor cursor;
if (more) {
@@ -2395,27 +2258,18 @@ public class cgData {
null);
}
- if (cursor != null) {
- if (cursor.getCount() > 0) {
- cursor.moveToFirst();
- final int index = cursor.getColumnIndex("geocode");
-
- do {
- geocodes.add(cursor.getString(index));
- } while (cursor.moveToNext());
- }
-
- cursor.close();
+ Set<String> geocodes = new HashSet<String>();
+ while (cursor.moveToNext()) {
+ geocodes.add(cursor.getString(0));
}
- final int size = geocodes.size();
- if (size > 0) {
- Log.d("Database clean: removing " + size + " geocaches from listId=0");
+ cursor.close();
+ if (!geocodes.isEmpty()) {
+ Log.d("Database clean: removing " + geocodes.size() + " geocaches from listId=0");
removeCaches(geocodes, LoadFlags.REMOVE_ALL);
}
-
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.w("cgData.clean", e);
}
@@ -2519,9 +2373,8 @@ public class cgData {
init();
- LogEntry log = null;
- Cursor cursor = database.query(
+ final Cursor cursor = database.query(
dbTableLogsOffline,
new String[]{"_id", "type", "log", "date"},
"geocode = ?",
@@ -2531,19 +2384,15 @@ public class cgData {
"_id desc",
"1");
- if (cursor != null && cursor.getCount() > 0) {
- cursor.moveToFirst();
-
- log = new LogEntry(
- cursor.getLong(cursor.getColumnIndex("date")),
- LogType.getById(cursor.getInt(cursor.getColumnIndex("type"))),
- cursor.getString(cursor.getColumnIndex("log")));
- log.id = cursor.getInt(cursor.getColumnIndex("_id"));
+ LogEntry log = null;
+ if (cursor.moveToFirst()) {
+ log = new LogEntry(cursor.getLong(3),
+ LogType.getById(cursor.getInt(1)),
+ cursor.getString(2));
+ log.id = cursor.getInt(0);
}
- if (cursor != null) {
- cursor.close();
- }
+ cursor.close();
return log;
}
@@ -2602,8 +2451,8 @@ public class cgData {
public static List<StoredList> getLists() {
init();
- Resources res = cgeoapplication.getInstance().getResources();
- List<StoredList> lists = new ArrayList<StoredList>();
+ final Resources res = cgeoapplication.getInstance().getResources();
+ final List<StoredList> lists = new ArrayList<StoredList>();
lists.add(new StoredList(StoredList.STANDARD_LIST_ID, res.getString(R.string.list_inbox), (int) PreparedStatements.getCountCachesOnStandardList().simpleQueryForLong()));
try {
@@ -2613,36 +2462,27 @@ public class cgData {
" GROUP BY l._id" +
" ORDER BY l.title COLLATE NOCASE ASC";
- Cursor cursor = database.rawQuery(query, null);
+ final Cursor cursor = database.rawQuery(query, null);
ArrayList<StoredList> storedLists = getListsFromCursor(cursor);
lists.addAll(storedLists);
-
- } catch (Exception e) {
+ cursor.close();
+ } catch (final Exception e) {
Log.e("cgData.readLists", e);
}
return lists;
}
- private static ArrayList<StoredList> getListsFromCursor(Cursor cursor) {
- ArrayList<StoredList> result = new ArrayList<StoredList>();
- if (cursor != null) {
- if (cursor.getCount() > 0) {
- cursor.moveToFirst();
- int indexId = cursor.getColumnIndex("_id");
- int indexTitle = cursor.getColumnIndex("title");
- int indexCount = cursor.getColumnIndex("count");
- do {
- int count = 0;
- if (indexCount >= 0) {
- count = cursor.getInt(indexCount);
- }
- StoredList list = new StoredList(cursor.getInt(indexId) + customListIdOffset, cursor.getString(indexTitle), count);
- result.add(list);
- } while (cursor.moveToNext());
- }
-
- cursor.close();
+ private static ArrayList<StoredList> getListsFromCursor(final Cursor cursor) {
+ final int indexId = cursor.getColumnIndex("_id");
+ final int indexTitle = cursor.getColumnIndex("title");
+ final int indexCount = cursor.getColumnIndex("count");
+ final ArrayList<StoredList> result = new ArrayList<StoredList>();
+ while (cursor.moveToNext()) {
+ final int count = indexCount != -1 ? cursor.getInt(indexCount) : 0;
+ final StoredList list = new StoredList(cursor.getInt(indexId) + customListIdOffset, cursor.getString(indexTitle), count);
+ result.add(list);
}
+ cursor.close();
return result;
}
@@ -2889,7 +2729,7 @@ public class cgData {
* @return
*/
- public static Set<cgWaypoint> loadWaypoints(final Viewport viewport, boolean excludeMine, boolean excludeDisabled, CacheType type) {
+ public static Set<Waypoint> loadWaypoints(final Viewport viewport, boolean excludeMine, boolean excludeDisabled, CacheType type) {
final StringBuilder where = new StringBuilder(buildCoordinateWhere(dbTableWaypoints, viewport));
if (excludeMine) {
where.append(" and ").append(dbTableCaches).append(".own == 0 and ").append(dbTableCaches).append(".found == 0");
@@ -2908,20 +2748,13 @@ public class cgData {
}
query.append(" FROM ").append(dbTableWaypoints).append(", ").append(dbTableCaches).append(" WHERE ").append(dbTableWaypoints).append(".geocode == ").append(dbTableCaches).append(".geocode and ").append(where);
+ final Set<Waypoint> waypoints = new HashSet<Waypoint>();
final Cursor cursor = database.rawQuery(query.toString(), null);
- try {
- if (!cursor.moveToFirst()) {
- return Collections.emptySet();
- }
-
- final Set<cgWaypoint> waypoints = new HashSet<cgWaypoint>();
- do {
- waypoints.add(createWaypointFromDatabaseContent(cursor));
- } while (cursor.moveToNext());
- return waypoints;
- } finally {
- cursor.close();
+ while (cursor.moveToNext()) {
+ waypoints.add(createWaypointFromDatabaseContent(cursor));
}
+ cursor.close();
+ return waypoints;
}
public static String[] getTrackableCodes() {
@@ -2936,21 +2769,22 @@ public class cgData {
null,
"updated DESC",
"100");
+ return getFirstColumn(cursor);
+ }
- final ArrayList<String> list = new ArrayList<String>();
- if (cursor != null) {
- if (cursor.getCount() > 0) {
- cursor.moveToFirst();
-
- final int index = cursor.getColumnIndex("tbcode");
- do {
- list.add(cursor.getString(index));
- } while (cursor.moveToNext());
- }
- cursor.close();
+ /**
+ * Extract the first column of the cursor rows and close the cursor.
+ *
+ * @param cursor a database cursor
+ * @return the first column of each row
+ */
+ private static String[] getFirstColumn(final Cursor cursor) {
+ final String[] result = new String[cursor.getCount()];
+ for (int i = 0; cursor.moveToNext(); i++) {
+ result[i] = cursor.getString(0);
}
-
- return list.toArray(new String[list.size()]);
+ cursor.close();
+ return result;
}
public static boolean saveChangedCache(cgCache cache) {
@@ -3091,7 +2925,7 @@ public class cgData {
return new SearchResult(geocodes, cgData.getAllHistoryCachesCount());
}
- public static boolean saveWaypoint(int id, String geocode, cgWaypoint waypoint) {
+ public static boolean saveWaypoint(int id, String geocode, Waypoint waypoint) {
if (cgData.saveWaypointInternal(id, geocode, waypoint)) {
cgData.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE));
return true;
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index 452bacb..aa4c89e 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -280,7 +280,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
};
/**
- * Loads the caches and fills the cachelist according to {@link #search} content.
+ * Loads the caches and fills the {@link #cacheList} according to {@link #search} content.
*
* If {@link #search} is <code>null</code>, this does nothing.
*/
@@ -292,7 +292,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
@Override
public void run() {
cacheList.clear();
- cacheList.addAll((Set<cgCache>) cachesFromSearchResult);
+ cacheList.addAll(cachesFromSearchResult);
adapter.reFilter();
updateTitle();
showFooterMoreCaches();
@@ -303,7 +303,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
protected void updateTitle() {
ArrayList<Integer> numbers = new ArrayList<Integer>();
- if (adapter != null && adapter.isFiltered()) {
+ if (adapter.isFiltered()) {
numbers.add(adapter.getCount());
}
if (search != null) {
@@ -667,13 +667,6 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
}
@Override
- public void onDestroy() {
- adapter = null;
-
- super.onDestroy();
- }
-
- @Override
public void onPause() {
removeGeoAndDir();
@@ -798,7 +791,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
}
item = menu.findItem(MENU_MOVE_TO_LIST);
if (item != null) {
- item.setVisible(multipleLists && !isEmpty);
+ item.setVisible(!isEmpty);
}
setMenuItemLabel(menu, MENU_REMOVE_FROM_HISTORY, R.string.cache_remove_from_history, R.string.cache_clear_history);
@@ -974,10 +967,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
}
if (cache.isOffline()) {
menu.add(0, MENU_DROP_CACHE, 0, res.getString(R.string.cache_offline_drop));
- final List<StoredList> cacheLists = cgData.getLists();
- if (cacheLists.size() > 1) {
- menu.add(0, MENU_MOVE_TO_LIST, 0, res.getString(R.string.cache_menu_move_list));
- }
+ menu.add(0, MENU_MOVE_TO_LIST, 0, res.getString(R.string.cache_menu_move_list));
menu.add(0, MENU_EXPORT, 0, res.getString(R.string.export));
}
else {
diff --git a/main/src/cgeo/geocaching/connector/ConnectorFactory.java b/main/src/cgeo/geocaching/connector/ConnectorFactory.java
index 4802c3e..6c8b7d9 100644
--- a/main/src/cgeo/geocaching/connector/ConnectorFactory.java
+++ b/main/src/cgeo/geocaching/connector/ConnectorFactory.java
@@ -2,7 +2,7 @@ package cgeo.geocaching.connector;
import cgeo.geocaching.ICache;
import cgeo.geocaching.SearchResult;
-import cgeo.geocaching.cgTrackable;
+import cgeo.geocaching.Trackable;
import cgeo.geocaching.connector.capability.ISearchByCenter;
import cgeo.geocaching.connector.capability.ISearchByViewPort;
import cgeo.geocaching.connector.gc.GCConnector;
@@ -84,7 +84,7 @@ public final class ConnectorFactory {
return getConnector(cache.getGeocode());
}
- public static IConnector getConnector(cgTrackable trackable) {
+ public static IConnector getConnector(Trackable trackable) {
return getConnector(trackable.getGeocode());
}
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 91b0ddd..0417409 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -4,12 +4,12 @@ import cgeo.geocaching.LogEntry;
import cgeo.geocaching.R;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
+import cgeo.geocaching.Trackable;
import cgeo.geocaching.TrackableLog;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
-import cgeo.geocaching.cgImage;
-import cgeo.geocaching.cgTrackable;
-import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.Image;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
@@ -306,9 +306,7 @@ public abstract class GCParser {
if (searchResult != null && !searchResult.getGeocodes().isEmpty()) {
final cgCache cache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
getExtraOnlineInfo(cache, page, handler);
- cache.setUpdated(System.currentTimeMillis());
- cache.setDetailedUpdate(cache.getUpdated());
- cache.setDetailed(true);
+ cache.setDetailedUpdatedNow();
if (CancellableHandler.isCancelled(handler)) {
return null;
}
@@ -549,7 +547,7 @@ public abstract class GCParser {
if (matcherSpoilersInside.group(4) != null) {
description = matcherSpoilersInside.group(4);
}
- cache.addSpoiler(new cgImage(url, title, description));
+ cache.addSpoiler(new Image(url, title, description));
}
} catch (Exception e) {
// failed to parse cache spoilers
@@ -563,7 +561,7 @@ public abstract class GCParser {
final MatcherWrapper matcherInventory = new MatcherWrapper(GCConstants.PATTERN_INVENTORY, page);
if (matcherInventory.find()) {
if (cache.getInventory() == null) {
- cache.setInventory(new ArrayList<cgTrackable>());
+ cache.setInventory(new ArrayList<Trackable>());
}
if (matcherInventory.groupCount() > 1) {
@@ -574,7 +572,7 @@ public abstract class GCParser {
while (matcherInventoryInside.find()) {
if (matcherInventoryInside.groupCount() > 0) {
- final cgTrackable inventoryItem = new cgTrackable();
+ final Trackable inventoryItem = new Trackable();
inventoryItem.setGuid(matcherInventoryInside.group(1));
inventoryItem.setName(matcherInventoryInside.group(2));
@@ -613,14 +611,14 @@ public abstract class GCParser {
}
// waypoints - reset collection
- cache.setWaypoints(Collections.<cgWaypoint> emptyList(), false);
+ cache.setWaypoints(Collections.<Waypoint> emptyList(), false);
// add waypoint for original coordinates in case of user-modified listing-coordinates
try {
final String originalCoords = BaseUtils.getMatch(page, GCConstants.PATTERN_LATLON_ORIG, false, null);
if (null != originalCoords) {
- final cgWaypoint waypoint = new cgWaypoint(cgeoapplication.getInstance().getString(R.string.cache_coordinates_original), WaypointType.ORIGINAL, false);
+ final Waypoint waypoint = new Waypoint(cgeoapplication.getInstance().getString(R.string.cache_coordinates_original), WaypointType.ORIGINAL, false);
waypoint.setCoords(new Geopoint(originalCoords));
cache.addOrChangeWaypoint(waypoint, false);
cache.setUserModifiedCoords(true);
@@ -664,7 +662,7 @@ public abstract class GCParser {
// waypoint type
final String resulttype = BaseUtils.getMatch(wp[3], GCConstants.PATTERN_WPTYPE, null);
- final cgWaypoint waypoint = new cgWaypoint(name, WaypointType.findById(resulttype), false);
+ final Waypoint waypoint = new Waypoint(name, WaypointType.findById(resulttype), false);
// waypoint prefix
waypoint.setPrefix(BaseUtils.getMatch(wp[4], GCConstants.PATTERN_WPPREFIXORLOOKUPORLATLON, true, 2, waypoint.getPrefix(), false));
@@ -886,13 +884,13 @@ public abstract class GCParser {
return null;
}
- public static cgTrackable searchTrackable(final String geocode, final String guid, final String id) {
+ public static Trackable searchTrackable(final String geocode, final String guid, final String id) {
if (StringUtils.isBlank(geocode) && StringUtils.isBlank(guid) && StringUtils.isBlank(id)) {
Log.w("GCParser.searchTrackable: No geocode nor guid nor id given");
return null;
}
- cgTrackable trackable = new cgTrackable();
+ Trackable trackable = new Trackable();
final Parameters params = new Parameters();
if (StringUtils.isNotBlank(geocode)) {
@@ -1246,13 +1244,13 @@ public abstract class GCParser {
}
/**
- * Parse a trackable HTML description into a cgTrackable object
+ * Parse a trackable HTML description into a Trackable object
*
* @param page
* the HTML page to parse, already processed through {@link BaseUtils#replaceWhitespace}
* @return the parsed trackable, or null if none could be parsed
*/
- static cgTrackable parseTrackable(final String page, final String possibleTrackingcode) {
+ static Trackable parseTrackable(final String page, final String possibleTrackingcode) {
if (StringUtils.isBlank(page)) {
Log.e("GCParser.parseTrackable: No page given");
return null;
@@ -1262,7 +1260,7 @@ public abstract class GCParser {
return null;
}
- final cgTrackable trackable = new cgTrackable();
+ final Trackable trackable = new Trackable();
// trackable geocode
trackable.setGeocode(BaseUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_GEOCODE, true, trackable.getGeocode()));
@@ -1302,22 +1300,22 @@ public abstract class GCParser {
if (matcherSpottedCache.find() && matcherSpottedCache.groupCount() > 0) {
trackable.setSpottedGuid(matcherSpottedCache.group(1));
trackable.setSpottedName(matcherSpottedCache.group(2).trim());
- trackable.setSpottedType(cgTrackable.SPOTTED_CACHE);
+ trackable.setSpottedType(Trackable.SPOTTED_CACHE);
}
final MatcherWrapper matcherSpottedUser = new MatcherWrapper(GCConstants.PATTERN_TRACKABLE_SPOTTEDUSER, page);
if (matcherSpottedUser.find() && matcherSpottedUser.groupCount() > 0) {
trackable.setSpottedGuid(matcherSpottedUser.group(1));
trackable.setSpottedName(matcherSpottedUser.group(2).trim());
- trackable.setSpottedType(cgTrackable.SPOTTED_USER);
+ trackable.setSpottedType(Trackable.SPOTTED_USER);
}
if (BaseUtils.matches(page, GCConstants.PATTERN_TRACKABLE_SPOTTEDUNKNOWN)) {
- trackable.setSpottedType(cgTrackable.SPOTTED_UNKNOWN);
+ trackable.setSpottedType(Trackable.SPOTTED_UNKNOWN);
}
if (BaseUtils.matches(page, GCConstants.PATTERN_TRACKABLE_SPOTTEDOWNER)) {
- trackable.setSpottedType(cgTrackable.SPOTTED_OWNER);
+ trackable.setSpottedType(Trackable.SPOTTED_OWNER);
}
} catch (Exception e) {
// failed to parse trackable last known place
@@ -1403,7 +1401,7 @@ public abstract class GCParser {
* 2. Image title
*/
while (matcherLogImages.find()) {
- final cgImage logImage = new cgImage(matcherLogImages.group(1), matcherLogImages.group(2));
+ final Image logImage = new Image(matcherLogImages.group(1), matcherLogImages.group(2));
logDone.addLogImage(logImage);
}
@@ -1525,7 +1523,7 @@ public abstract class GCParser {
final JSONObject image = images.getJSONObject(i);
String url = "http://img.geocaching.com/cache/log/" + image.getString("FileName");
String title = image.getString("Name");
- final cgImage logImage = new cgImage(url, title);
+ final Image logImage = new Image(url, title);
logDone.addLogImage(logImage);
}
diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java
index d0c0e16..b80da6b 100644
--- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java
+++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java
@@ -79,51 +79,59 @@ public class OC11XMLParser {
}
private static CacheSize getCacheSize(final String sizeId) {
- int size = Integer.parseInt(sizeId);
-
- switch (size) {
- case 1:
- return CacheSize.OTHER;
- case 2:
- return CacheSize.MICRO;
- case 3:
- return CacheSize.SMALL;
- case 4:
- return CacheSize.REGULAR;
- case 5:
- case 6:
- return CacheSize.LARGE;
- case 8:
- return CacheSize.VIRTUAL;
- default:
- break;
+ try {
+ int size = Integer.parseInt(sizeId);
+
+ switch (size) {
+ case 1:
+ return CacheSize.OTHER;
+ case 2:
+ return CacheSize.MICRO;
+ case 3:
+ return CacheSize.SMALL;
+ case 4:
+ return CacheSize.REGULAR;
+ case 5:
+ case 6:
+ return CacheSize.LARGE;
+ case 8:
+ return CacheSize.VIRTUAL;
+ default:
+ break;
+ }
+ } catch (NumberFormatException e) {
+ Log.e("OC11XMLParser.getCacheSize", e);
}
return CacheSize.NOT_CHOSEN;
}
private static CacheType getCacheType(final String typeId) {
- int type = Integer.parseInt(typeId);
- switch (type) {
- case 1: // Other/unbekannter Cachetyp
- return CacheType.UNKNOWN;
- case 2: // Trad./normaler Cache
- return CacheType.TRADITIONAL;
- case 3: // Multi/Multicache
- return CacheType.MULTI;
- case 4: // Virt./virtueller Cache
- return CacheType.VIRTUAL;
- case 5: // ICam./Webcam-Cache
- return CacheType.WEBCAM;
- case 6: // Event/Event-Cache
- return CacheType.EVENT;
- case 7: // Quiz/Rätselcache
- return CacheType.MYSTERY;
- case 8: // Math/Mathe-/Physikcache
- return CacheType.MYSTERY;
- case 9: // Moving/beweglicher Cache
- return CacheType.UNKNOWN;
- case 10: // Driv./Drive-In
- return CacheType.TRADITIONAL;
+ try {
+ int type = Integer.parseInt(typeId);
+ switch (type) {
+ case 1: // Other/unbekannter Cachetyp
+ return CacheType.UNKNOWN;
+ case 2: // Trad./normaler Cache
+ return CacheType.TRADITIONAL;
+ case 3: // Multi/Multicache
+ return CacheType.MULTI;
+ case 4: // Virt./virtueller Cache
+ return CacheType.VIRTUAL;
+ case 5: // ICam./Webcam-Cache
+ return CacheType.WEBCAM;
+ case 6: // Event/Event-Cache
+ return CacheType.EVENT;
+ case 7: // Quiz/Rätselcache
+ return CacheType.MYSTERY;
+ case 8: // Math/Mathe-/Physikcache
+ return CacheType.MYSTERY;
+ case 9: // Moving/beweglicher Cache
+ return CacheType.VIRTUAL;
+ case 10: // Driv./Drive-In
+ return CacheType.TRADITIONAL;
+ }
+ } catch (NumberFormatException e) {
+ Log.e("OC11XMLParser.getCacheType", e);
}
return CacheType.UNKNOWN;
}
@@ -140,8 +148,9 @@ public class OC11XMLParser {
return LogType.ATTENDED;
case 8:
return LogType.WILL_ATTEND;
+ default:
+ return LogType.UNKNOWN;
}
- return LogType.UNKNOWN;
}
private static void setCacheStatus(final int statusId, final cgCache cache) {
@@ -216,6 +225,7 @@ public class OC11XMLParser {
&& !cache.isArchived()
&& caches.size() < CACHE_PARSE_LIMIT) {
cache.setCoords(coords);
+ cache.setDetailedUpdatedNow();
caches.put(cache.getCacheId(), cache);
}
}
@@ -327,7 +337,11 @@ public class OC11XMLParser {
@Override
public void end(String body) {
final String content = body.trim();
- cacheHolder.cache.setDifficulty(Float.valueOf(content));
+ try {
+ cacheHolder.cache.setDifficulty(Float.valueOf(content));
+ } catch (NumberFormatException e) {
+ Log.e("OC11XMLParser: unknown difficulty " + content, e);
+ }
}
});
@@ -337,7 +351,11 @@ public class OC11XMLParser {
@Override
public void end(String body) {
final String content = body.trim();
- cacheHolder.cache.setTerrain(Float.valueOf(content));
+ try {
+ cacheHolder.cache.setTerrain(Float.valueOf(content));
+ } catch (NumberFormatException e) {
+ Log.e("OC11XMLParser: unknown terrain " + content, e);
+ }
}
});
@@ -443,7 +461,7 @@ public class OC11XMLParser {
if (cache != null && logHolder.logEntry.type != LogType.UNKNOWN) {
cache.getLogs().prepend(logHolder.logEntry);
if (logHolder.logEntry.type == LogType.FOUND_IT
- && StringUtils.equals(logHolder.logEntry.author, Settings.getOCConnectorUserName())) {
+ && StringUtils.equalsIgnoreCase(logHolder.logEntry.author, Settings.getOCConnectorUserName())) {
cache.setFound(true);
cache.setVisitedDate(logHolder.logEntry.date);
}
@@ -467,8 +485,8 @@ public class OC11XMLParser {
public void end(String body) {
try {
logHolder.logEntry.date = parseDayDate(body).getTime();
- } catch (Exception e) {
- Log.w("Failed to parse log date: " + e.toString());
+ } catch (NullPointerException e) {
+ Log.w("Failed to parse log date", e);
}
}
});
@@ -479,8 +497,13 @@ public class OC11XMLParser {
@Override
public void start(Attributes attrs) {
if (attrs.getIndex("id") > -1) {
- final int typeId = Integer.parseInt(attrs.getValue("id"));
- logHolder.logEntry.type = getLogType(typeId);
+ final String id = attrs.getValue("id");
+ try {
+ final int typeId = Integer.parseInt(id);
+ logHolder.logEntry.type = getLogType(typeId);
+ } catch (NumberFormatException e) {
+ Log.e("OC11XMLParser, unknown logtype " + id, e);
+ }
}
}
});
@@ -511,4 +534,4 @@ public class OC11XMLParser {
return null;
}
}
-}
+} \ No newline at end of file
diff --git a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java
index 26b42e3..88ba5a1 100644
--- a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java
+++ b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java
@@ -13,12 +13,12 @@ import cgeo.geocaching.utils.Log;
import ch.boye.httpclientandroidlib.HttpResponse;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
+import java.util.Collections;
import java.util.Locale;
import java.util.zip.GZIPInputStream;
@@ -42,18 +42,16 @@ public class OCXMLClient {
Collection<cgCache> caches = OC11XMLParser.parseCaches(new GZIPInputStream(data));
if (caches.iterator().hasNext()) {
cgCache cache = caches.iterator().next();
- cache.setDetailed(true);
cgData.saveCache(cache, LoadFlags.SAVE_ALL);
return cache;
}
return null;
} catch (IOException e) {
- Log.e("Error parsing cache '" + geoCode + "': " + e.toString());
+ Log.e("Error parsing cache '" + geoCode + "'", e);
return null;
}
}
- @SuppressWarnings("unchecked")
public static Collection<cgCache> getCachesAround(final Geopoint center, final double distance) {
try {
final Parameters params = getOCXmlQueryParameters(false, false);
@@ -63,13 +61,13 @@ public class OCXMLClient {
final InputStream data = request(ConnectorFactory.getConnector("OCXXX"), SERVICE_CACHE, params);
if (data == null) {
- return CollectionUtils.EMPTY_COLLECTION;
+ return Collections.emptyList();
}
return OC11XMLParser.parseCaches(new GZIPInputStream(data));
} catch (IOException e) {
- Log.e("Error parsing nearby search result: " + e.toString());
- return CollectionUtils.EMPTY_COLLECTION;
+ Log.e("Error parsing nearby search result", e);
+ return Collections.emptyList();
}
}
diff --git a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
index 1121cc5..508d0b5 100644
--- a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
+++ b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
@@ -1,9 +1,9 @@
package cgeo.geocaching.connector.oc;
+import cgeo.geocaching.Image;
import cgeo.geocaching.LogEntry;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
-import cgeo.geocaching.cgImage;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.IConnector;
import cgeo.geocaching.enumerations.CacheSize;
@@ -158,7 +158,7 @@ final public class OkapiClient {
if (imageResponse.getBoolean(CACHE_IMAGE_IS_SPOILER)) {
final String title = imageResponse.getString(CACHE_IMAGE_CAPTION);
final String url = absoluteUrl(imageResponse.getString(CACHE_IMAGE_URL), cache.getGeocode());
- cache.addSpoiler(new cgImage(url, title));
+ cache.addSpoiler(new Image(url, title));
}
}
}
@@ -167,9 +167,7 @@ final public class OkapiClient {
cache.setLogs(parseLogs(response.getJSONArray(CACHE_LATEST_LOGS)));
cache.setHidden(parseDate(response.getString(CACHE_HIDDEN)));
- cache.setUpdated(System.currentTimeMillis());
- cache.setDetailedUpdate(cache.getUpdated());
- cache.setDetailed(true);
+ cache.setDetailedUpdatedNow();
// save full detailed caches
cgData.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
} catch (JSONException e) {
diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java
index 3aec114..9f6642f 100644
--- a/main/src/cgeo/geocaching/export/GpxExport.java
+++ b/main/src/cgeo/geocaching/export/GpxExport.java
@@ -3,9 +3,9 @@ package cgeo.geocaching.export;
import cgeo.geocaching.LogEntry;
import cgeo.geocaching.R;
import cgeo.geocaching.Settings;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
-import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.activity.Progress;
import cgeo.geocaching.enumerations.CacheAttribute;
@@ -282,10 +282,10 @@ class GpxExport extends AbstractExport {
}
private void writeWaypoints(final cgCache cache) throws IOException {
- List<cgWaypoint> waypoints = cache.getWaypoints();
- List<cgWaypoint> ownWaypoints = new ArrayList<cgWaypoint>(waypoints.size());
- List<cgWaypoint> originWaypoints = new ArrayList<cgWaypoint>(waypoints.size());
- for (cgWaypoint wp : cache.getWaypoints()) {
+ List<Waypoint> waypoints = cache.getWaypoints();
+ List<Waypoint> ownWaypoints = new ArrayList<Waypoint>(waypoints.size());
+ List<Waypoint> originWaypoints = new ArrayList<Waypoint>(waypoints.size());
+ for (Waypoint wp : cache.getWaypoints()) {
if (wp.isUserDefined()) {
ownWaypoints.add(wp);
} else {
@@ -293,7 +293,7 @@ class GpxExport extends AbstractExport {
}
}
int maxPrefix = 0;
- for (cgWaypoint wp : originWaypoints) {
+ for (Waypoint wp : originWaypoints) {
String prefix = wp.getPrefix();
try {
maxPrefix = Math.max(Integer.parseInt(prefix), maxPrefix);
@@ -302,7 +302,7 @@ class GpxExport extends AbstractExport {
}
writeCacheWaypoint(wp, prefix);
}
- for (cgWaypoint wp : ownWaypoints) {
+ for (Waypoint wp : ownWaypoints) {
maxPrefix++;
String prefix = StringUtils.leftPad(String.valueOf(maxPrefix), 2, '0');
writeCacheWaypoint(wp, prefix);
@@ -318,7 +318,7 @@ class GpxExport extends AbstractExport {
* @param prefix
* @throws IOException
*/
- private void writeCacheWaypoint(final cgWaypoint wp, final String prefix) throws IOException {
+ private void writeCacheWaypoint(final Waypoint wp, final String prefix) throws IOException {
gpx.write("<wpt lat=\"");
final Geopoint coords = wp.getCoords();
gpx.write(coords != null ? Double.toString(coords.getLatitude()) : ""); // TODO: check whether is the best way to handle unknown waypoint coordinates
diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java
index e2d7205..8207455 100644
--- a/main/src/cgeo/geocaching/files/GPXParser.java
+++ b/main/src/cgeo/geocaching/files/GPXParser.java
@@ -3,10 +3,10 @@ package cgeo.geocaching.files;
import cgeo.geocaching.LogEntry;
import cgeo.geocaching.R;
import cgeo.geocaching.StoredList;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
-import cgeo.geocaching.cgTrackable;
-import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.Trackable;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.enumerations.CacheSize;
@@ -81,7 +81,7 @@ public abstract class GPXParser extends FileParser {
final private String version;
private cgCache cache;
- private cgTrackable trackable = new cgTrackable();
+ private Trackable trackable = new Trackable();
private LogEntry log = null;
private String type = null;
@@ -331,7 +331,7 @@ public abstract class GPXParser extends FileParser {
// lookup cache for waypoint in already parsed caches
final cgCache cacheForWaypoint = cgData.loadCache(cacheGeocodeForWaypoint, LoadFlags.LOAD_CACHE_OR_DB);
if (cacheForWaypoint != null) {
- final cgWaypoint waypoint = new cgWaypoint(cache.getShortdesc(), convertWaypointSym2Type(sym), false);
+ final Waypoint waypoint = new Waypoint(cache.getShortdesc(), convertWaypointSym2Type(sym), false);
waypoint.setId(-1);
waypoint.setGeocode(cacheGeocodeForWaypoint);
waypoint.setPrefix(cache.getName().substring(0, 2));
@@ -340,12 +340,12 @@ public abstract class GPXParser extends FileParser {
waypoint.setCoords(cache.getCoords());
waypoint.setNote(cache.getDescription());
- final ArrayList<cgWaypoint> mergedWayPoints = new ArrayList<cgWaypoint>();
+ final ArrayList<Waypoint> mergedWayPoints = new ArrayList<Waypoint>();
mergedWayPoints.addAll(cacheForWaypoint.getWaypoints());
- final ArrayList<cgWaypoint> newPoints = new ArrayList<cgWaypoint>();
+ final ArrayList<Waypoint> newPoints = new ArrayList<Waypoint>();
newPoints.add(waypoint);
- cgWaypoint.mergeWayPoints(newPoints, mergedWayPoints, true);
+ Waypoint.mergeWayPoints(newPoints, mergedWayPoints, true);
cacheForWaypoint.setWaypoints(newPoints, false);
cgData.saveCache(cacheForWaypoint, EnumSet.of(SaveFlag.SAVE_DB));
showProgressMessage(progressHandler, progressStream.getProgress());
@@ -661,7 +661,7 @@ public abstract class GPXParser extends FileParser {
@Override
public void start(Attributes attrs) {
- trackable = new cgTrackable();
+ trackable = new Trackable();
try {
if (attrs.getIndex("ref") > -1) {
@@ -679,7 +679,7 @@ public abstract class GPXParser extends FileParser {
public void end() {
if (StringUtils.isNotBlank(trackable.getGeocode()) && StringUtils.isNotBlank(trackable.getName())) {
if (cache.getInventory() == null) {
- cache.setInventory(new ArrayList<cgTrackable>());
+ cache.setInventory(new ArrayList<Trackable>());
}
cache.getInventory().add(trackable);
}
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 356f763..a470672 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -8,9 +8,9 @@ import cgeo.geocaching.R;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
import cgeo.geocaching.StoredList;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
-import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.cgeocaches;
import cgeo.geocaching.activity.ActivityMixin;
@@ -180,7 +180,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
/** List of caches in the viewport */
private LeastRecentlyUsedSet<cgCache> caches = null;
/** List of waypoints in the viewport */
- private final LeastRecentlyUsedSet<cgWaypoint> waypoints = new LeastRecentlyUsedSet<cgWaypoint>(MAX_CACHES);
+ private final LeastRecentlyUsedSet<Waypoint> waypoints = new LeastRecentlyUsedSet<Waypoint>(MAX_CACHES);
// storing for offline
private ProgressDialog waitDialog = null;
private int detailTotal = 0;
@@ -1156,7 +1156,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
if (isLiveEnabled || mapMode == MapMode.COORDS) {
//All visible waypoints
CacheType type = Settings.getCacheType();
- Set<cgWaypoint> waypointsInViewport = cgData.loadWaypoints(viewport, Settings.isExcludeMyCaches(), Settings.isExcludeDisabledCaches(), type);
+ Set<Waypoint> waypointsInViewport = cgData.loadWaypoints(viewport, Settings.isExcludeMyCaches(), Settings.isExcludeDisabledCaches(), type);
waypoints.addAll(waypointsInViewport);
}
else
@@ -1261,14 +1261,14 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
// display caches
final List<cgCache> cachesToDisplay = caches.getAsList();
- final List<cgWaypoint> waypointsToDisplay = new ArrayList<cgWaypoint>(waypoints);
+ final List<Waypoint> waypointsToDisplay = new ArrayList<Waypoint>(waypoints);
final List<CachesOverlayItemImpl> itemsToDisplay = new ArrayList<CachesOverlayItemImpl>();
if (!cachesToDisplay.isEmpty()) {
// Only show waypoints for single view or setting
// when less than showWaypointsthreshold Caches shown
if (mapMode == MapMode.SINGLE || (cachesCnt < Settings.getWayPointsThreshold())) {
- for (cgWaypoint waypoint : waypointsToDisplay) {
+ for (Waypoint waypoint : waypointsToDisplay) {
if (waypoint == null || waypoint.getCoords() == null) {
continue;
@@ -1316,7 +1316,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
if (coordsIntent != null) {
- final cgWaypoint waypoint = new cgWaypoint("some place", waypointTypeIntent != null ? waypointTypeIntent : WaypointType.WAYPOINT, false);
+ final Waypoint waypoint = new Waypoint("some place", waypointTypeIntent != null ? waypointTypeIntent : WaypointType.WAYPOINT, false);
waypoint.setCoords(coordsIntent);
final CachesOverlayItemImpl item = getItem(waypoint, null, waypoint);
@@ -1626,7 +1626,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
* Waypoint. Mutally exclusive with cache
* @return
*/
- private CachesOverlayItemImpl getItem(final IWaypoint coord, final cgCache cache, final cgWaypoint waypoint) {
+ private CachesOverlayItemImpl getItem(final IWaypoint coord, final cgCache cache, final Waypoint waypoint) {
if (cache != null) {
final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(coord, cache.getType());
diff --git a/main/src/cgeo/geocaching/twitter/Twitter.java b/main/src/cgeo/geocaching/twitter/Twitter.java
index c86c633..399f852 100644
--- a/main/src/cgeo/geocaching/twitter/Twitter.java
+++ b/main/src/cgeo/geocaching/twitter/Twitter.java
@@ -1,9 +1,9 @@
package cgeo.geocaching.twitter;
import cgeo.geocaching.Settings;
+import cgeo.geocaching.Trackable;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
-import cgeo.geocaching.cgTrackable;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.enumerations.LoadFlags;
import cgeo.geocaching.geopoint.Geopoint;
@@ -77,7 +77,7 @@ public final class Twitter {
}
public static void postTweetTrackable(String geocode) {
- final cgTrackable trackable = cgData.loadTrackable(geocode);
+ final Trackable trackable = cgData.loadTrackable(geocode);
String name = trackable.getName();
if (name.length() > 82) {
name = name.substring(0, 81) + '…';
diff --git a/main/src/cgeo/geocaching/ui/Formatter.java b/main/src/cgeo/geocaching/ui/Formatter.java
index 60fb3e6..4d23952 100644
--- a/main/src/cgeo/geocaching/ui/Formatter.java
+++ b/main/src/cgeo/geocaching/ui/Formatter.java
@@ -2,7 +2,7 @@ package cgeo.geocaching.ui;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgWaypoint;
+import cgeo.geocaching.Waypoint;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.enumerations.CacheListType;
import cgeo.geocaching.enumerations.CacheSize;
@@ -152,13 +152,13 @@ public abstract class Formatter {
return StringUtils.join(infos, Formatter.SEPARATOR);
}
- public static String formatWaypointInfo(cgWaypoint waypoint) {
+ public static String formatWaypointInfo(Waypoint waypoint) {
final List<String> infos = new ArrayList<String>(3);
WaypointType waypointType = waypoint.getWaypointType();
if (waypointType != WaypointType.OWN && waypointType != null) {
infos.add(waypointType.getL10n());
}
- if (cgWaypoint.PREFIX_OWN.equalsIgnoreCase(waypoint.getPrefix())) {
+ if (Waypoint.PREFIX_OWN.equalsIgnoreCase(waypoint.getPrefix())) {
infos.add(cgeoapplication.getInstance().getString(R.string.waypoint_custom));
} else {
if (StringUtils.isNotBlank(waypoint.getPrefix())) {
diff --git a/main/src/cgeo/geocaching/ui/ImagesList.java b/main/src/cgeo/geocaching/ui/ImagesList.java
index 8313f2f..e3332a0 100644
--- a/main/src/cgeo/geocaching/ui/ImagesList.java
+++ b/main/src/cgeo/geocaching/ui/ImagesList.java
@@ -1,8 +1,8 @@
package cgeo.geocaching.ui;
+import cgeo.geocaching.Image;
import cgeo.geocaching.R;
import cgeo.geocaching.StoredList;
-import cgeo.geocaching.cgImage;
import cgeo.geocaching.files.LocalStorage;
import cgeo.geocaching.network.HtmlImage;
import cgeo.geocaching.utils.Log;
@@ -43,7 +43,7 @@ public class ImagesList {
private static final int MENU_BROWSER = 202;
private BitmapDrawable currentDrawable;
- private cgImage currentImage;
+ private Image currentImage;
public enum ImageType {
LogImages(R.string.cache_log_images_title, R.string.cache_log_images_loading),
@@ -73,7 +73,7 @@ public class ImagesList {
/**
* map image view id to image
*/
- private final SparseArray<cgImage> images = new SparseArray<cgImage>();
+ private final SparseArray<Image> images = new SparseArray<Image>();
private final String geocode;
private LinearLayout imagesView;
@@ -83,7 +83,7 @@ public class ImagesList {
inflater = activity.getLayoutInflater();
}
- public void loadImages(final View parentView, final List<cgImage> images, ImageType imageType, final boolean offline) {
+ public void loadImages(final View parentView, final List<Image> images, ImageType imageType, final boolean offline) {
imagesView = (LinearLayout) parentView.findViewById(R.id.spoiler_list);
@@ -95,7 +95,7 @@ public class ImagesList {
progressDialog.setMax(count);
progressDialog.show();
- for (final cgImage img : images) {
+ for (final Image img : images) {
LinearLayout rowView = (LinearLayout) inflater.inflate(R.layout.cache_image_item, null);
if (StringUtils.isNotBlank(img.getTitle())) {
@@ -117,10 +117,10 @@ public class ImagesList {
private class AsyncImgLoader extends AsyncTask<Void, Void, BitmapDrawable> {
final private LinearLayout view;
- final private cgImage img;
+ final private Image img;
final boolean offline;
- public AsyncImgLoader(final LinearLayout view, final cgImage img, final boolean offline) {
+ public AsyncImgLoader(final LinearLayout view, final Image img, final boolean offline) {
this.view = view;
this.img = img;
this.offline = offline;
diff --git a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java
index 7cacd9d..7171fde 100644
--- a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java
+++ b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java
@@ -2,8 +2,8 @@ package cgeo.geocaching.utils;
import cgeo.geocaching.R;
import cgeo.geocaching.Settings;
+import cgeo.geocaching.Trackable;
import cgeo.geocaching.cgCache;
-import cgeo.geocaching.cgTrackable;
import cgeo.geocaching.connector.gc.GCConstants;
import cgeo.geocaching.connector.gc.Login;
import cgeo.geocaching.network.Network;
@@ -29,14 +29,14 @@ public class LogTemplateProvider {
*/
public static class LogContext {
private cgCache cache;
- private cgTrackable trackable;
+ private Trackable trackable;
private boolean offline = false;
public LogContext(final cgCache cache) {
this(cache, false);
}
- public LogContext(final cgTrackable trackable) {
+ public LogContext(final Trackable trackable) {
this.trackable = trackable;
}
@@ -53,7 +53,7 @@ public class LogTemplateProvider {
return cache;
}
- public cgTrackable getTrackable() {
+ public Trackable getTrackable() {
return trackable;
}
@@ -148,7 +148,7 @@ public class LogTemplateProvider {
@Override
public String getValue(final LogContext context) {
- cgTrackable trackable = context.getTrackable();
+ Trackable trackable = context.getTrackable();
if (trackable != null) {
return trackable.getOwner();
}