diff options
author | blafoo <github@blafoo.de> | 2012-02-11 19:54:08 +0100 |
---|---|---|
committer | blafoo <github@blafoo.de> | 2012-02-11 19:54:08 +0100 |
commit | 14ba46c805858046029941e36be6a7277e49bff2 (patch) | |
tree | 88ec2c1b99dd50c49a87038d4d75b57d6c9d0255 /main/src/cgeo | |
parent | 2e29346049143679dcd8ab7bd69a51bd5789f8ae (diff) | |
download | cgeo-14ba46c805858046029941e36be6a7277e49bff2.zip cgeo-14ba46c805858046029941e36be6a7277e49bff2.tar.gz cgeo-14ba46c805858046029941e36be6a7277e49bff2.tar.bz2 |
Relocated constants to new class Constants
Diffstat (limited to 'main/src/cgeo')
-rw-r--r-- | main/src/cgeo/geocaching/Constants.java | 20 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/GCConstants.java | 3 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 8 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeo.java | 5 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/connector/GCConnector.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/ui/CacheListAdapter.java | 6 |
7 files changed, 32 insertions, 16 deletions
diff --git a/main/src/cgeo/geocaching/Constants.java b/main/src/cgeo/geocaching/Constants.java new file mode 100644 index 0000000..b996b20 --- /dev/null +++ b/main/src/cgeo/geocaching/Constants.java @@ -0,0 +1,20 @@ +package cgeo.geocaching; + +/** + * Various constant values used all over in c:geo + * + * @author blafoo + */ + +public final class Constants { + + /** Number of days (as ms) after temporarily saved caches are deleted */ + public static long DAYS_AFTER_CACHE_IS_DELETED = 3 * 24 * 60 * 60 * 1000; + + /** Number of logs to retrieve from GC.com */ + public final static int NUMBER_OF_LOGS = 35; + + /** Text separator used for formatting texts */ + public static final String SEPARATOR = " · "; + +} diff --git a/main/src/cgeo/geocaching/GCConstants.java b/main/src/cgeo/geocaching/GCConstants.java index a37b264..6127a7f 100644 --- a/main/src/cgeo/geocaching/GCConstants.java +++ b/main/src/cgeo/geocaching/GCConstants.java @@ -13,9 +13,6 @@ import java.util.regex.Pattern; */ public final class GCConstants { - /** Number of logs to retrieve from GC.com */ - public final static int NUMBER_OF_LOGS = 35; - /** * Patterns for parsing the result of a (detailed) search */ diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index 7caa480..a7131f5 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -1278,7 +1278,7 @@ public class cgBase { final Parameters params = new Parameters( "tkn", userToken, "idx", "1", - "num", String.valueOf(GCConstants.NUMBER_OF_LOGS), + "num", String.valueOf(Constants.NUMBER_OF_LOGS), "decrypt", "true", // "sp", Boolean.toString(personal), // personal logs "sf", Boolean.toString(friends)); diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index f23b794..17ed58e 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -999,7 +999,7 @@ public class cgData { List<String> list = new ArrayList<String>(); try { - long timestamp = System.currentTimeMillis() - (3 * 24 * 60 * 60 * 1000); + long timestamp = System.currentTimeMillis() - Constants.DAYS_AFTER_CACHE_IS_DELETED; cursor = databaseRO.query( dbTableCaches, new String[] { "geocode" }, @@ -1100,12 +1100,12 @@ public class cgData { return false; } - if (checkTime && detailed && dataDetailedUpdate < (System.currentTimeMillis() - (3 * 24 * 60 * 60 * 1000))) { + if (checkTime && detailed && dataDetailedUpdate < (System.currentTimeMillis() - Constants.DAYS_AFTER_CACHE_IS_DELETED)) { // we want to check time for detailed cache, but data are older than 3 hours return false; } - if (checkTime && !detailed && dataUpdated < (System.currentTimeMillis() - (3 * 24 * 60 * 60 * 1000))) { + if (checkTime && !detailed && dataUpdated < (System.currentTimeMillis() - Constants.DAYS_AFTER_CACHE_IS_DELETED)) { // we want to check time for short cache, but data are older than 3 hours return false; } @@ -2914,7 +2914,7 @@ public class cgData { null, null); } else { - long timestamp = System.currentTimeMillis() - (3 * 24 * 60 * 60 * 1000); + long timestamp = System.currentTimeMillis() - Constants.DAYS_AFTER_CACHE_IS_DELETED; String timestampString = Long.toString(timestamp); cursor = databaseRO.query( dbTableCaches, diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java index 4de8e50..6f2c758 100644 --- a/main/src/cgeo/geocaching/cgeo.java +++ b/main/src/cgeo/geocaching/cgeo.java @@ -9,7 +9,6 @@ import cgeo.geocaching.enumerations.StatusCode; import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.maps.CGeoMap; -import cgeo.geocaching.ui.CacheListAdapter; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -70,13 +69,13 @@ public class cgeo extends AbstractActivity { TextView userInfoView = (TextView) findViewById(R.id.user_info); - String userInfo = "geocaching.com" + CacheListAdapter.SEPARATOR; + String userInfo = "geocaching.com" + Constants.SEPARATOR; if (cgBase.isActualLoginStatus()) { userInfo += cgBase.getActualUserName(); if (cgBase.getActualCachesFound() >= 0) { userInfo += " (" + String.valueOf(cgBase.getActualCachesFound()) + ")"; } - userInfo += CacheListAdapter.SEPARATOR; + userInfo += Constants.SEPARATOR; } userInfo += cgBase.getActualStatus(); diff --git a/main/src/cgeo/geocaching/connector/GCConnector.java b/main/src/cgeo/geocaching/connector/GCConnector.java index 2c198ae..5d685df 100644 --- a/main/src/cgeo/geocaching/connector/GCConnector.java +++ b/main/src/cgeo/geocaching/connector/GCConnector.java @@ -1,6 +1,6 @@ package cgeo.geocaching.connector; -import cgeo.geocaching.GCConstants; +import cgeo.geocaching.Constants; import cgeo.geocaching.R; import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; @@ -95,7 +95,7 @@ public class GCConnector extends AbstractConnector { params.put("guid", guid); } params.put("log", "y"); - params.put("numlogs", String.valueOf(GCConstants.NUMBER_OF_LOGS)); + params.put("numlogs", String.valueOf(Constants.NUMBER_OF_LOGS)); cgBase.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_loadpage); diff --git a/main/src/cgeo/geocaching/ui/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java index cab72ae..77544fb 100644 --- a/main/src/cgeo/geocaching/ui/CacheListAdapter.java +++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java @@ -1,6 +1,7 @@ package cgeo.geocaching.ui; import cgeo.geocaching.CacheDetailActivity; +import cgeo.geocaching.Constants; import cgeo.geocaching.R; import cgeo.geocaching.Settings; import cgeo.geocaching.cgBase; @@ -81,7 +82,6 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> { * time in milliseconds after which the list may be resorted due to position updates */ private static final int PAUSE_BETWEEN_LIST_SORT = 1000; - public static final String SEPARATOR = " · "; private IFilter currentFilter = null; private List<cgCache> originalList = null; private final CacheListType cacheListType; @@ -598,7 +598,7 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> { infos.add(StringUtils.upperCase(cache.getGeocode())); infos.add(cgBase.formatDate(cache.getVisitedDate())); infos.add(cgBase.formatTime(cache.getVisitedDate())); - holder.info.setText(StringUtils.join(infos, SEPARATOR)); + holder.info.setText(StringUtils.join(infos, Constants.SEPARATOR)); } else { ArrayList<String> infos = new ArrayList<String>(); if (StringUtils.isNotBlank(cache.getGeocode())) { @@ -624,7 +624,7 @@ public class CacheListAdapter extends ArrayAdapter<cgCache> { if (cacheListType != CacheListType.OFFLINE && cacheListType != CacheListType.HISTORY && cache.getListId() > 0) { infos.add(res.getString(R.string.cache_offline)); } - holder.info.setText(StringUtils.join(infos, SEPARATOR)); + holder.info.setText(StringUtils.join(infos, Constants.SEPARATOR)); } return v; |