aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2012-12-26 12:59:14 +0100
committerBananeweizen <Bananeweizen@gmx.de>2012-12-26 12:59:14 +0100
commite29b64e963af24f9c85c12ea110bf5255ef6fbec (patch)
treee7e4ffbebed28023d3c1f6a42f6a1910fb1f6646
parentc29c80e9b8cccc552e6747dbcaf0c5738fadd92a (diff)
downloadcgeo-e29b64e963af24f9c85c12ea110bf5255ef6fbec.zip
cgeo-e29b64e963af24f9c85c12ea110bf5255ef6fbec.tar.gz
cgeo-e29b64e963af24f9c85c12ea110bf5255ef6fbec.tar.bz2
code cleanup: remove debug code
* fixed some more issues of Findbugs and CodePro
-rw-r--r--cgeo-calendar/src/cgeo/calendar/AddEntry.java2
-rw-r--r--cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java2
-rw-r--r--cgeo-calendar/src/cgeo/calendar/CalendarEntry.java6
-rw-r--r--main/src/cgeo/geocaching/AbstractLoggingActivity.java2
-rw-r--r--main/src/cgeo/geocaching/AbstractPopupActivity.java10
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java21
-rw-r--r--main/src/cgeo/geocaching/EditWaypointActivity.java4
-rw-r--r--main/src/cgeo/geocaching/SearchResult.java2
-rw-r--r--main/src/cgeo/geocaching/StaticMapsActivity.java6
-rw-r--r--main/src/cgeo/geocaching/TrackableActivity.java3
-rw-r--r--main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java4
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java2
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java2
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java4
-rw-r--r--main/src/cgeo/geocaching/cgeocoords.java2
-rw-r--r--main/src/cgeo/geocaching/cgeopoint.java2
-rw-r--r--main/src/cgeo/geocaching/connector/gc/AbstractSearchThread.java2
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCConnector.java13
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java4
-rw-r--r--main/src/cgeo/geocaching/export/FieldnoteExport.java41
-rw-r--r--main/src/cgeo/geocaching/export/GpxExport.java2
-rw-r--r--main/src/cgeo/geocaching/files/GPXImporter.java6
-rw-r--r--main/src/cgeo/geocaching/filter/AbstractFilter.java2
-rw-r--r--main/src/cgeo/geocaching/filter/AbstractRangeFilter.java2
-rw-r--r--main/src/cgeo/geocaching/geopoint/Geopoint.java30
-rw-r--r--main/src/cgeo/geocaching/geopoint/GeopointFormatter.java5
-rw-r--r--main/src/cgeo/geocaching/maps/AbstractMapSource.java2
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java2
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleMapProvider.java12
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleOverlay.java3
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java10
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java3
-rw-r--r--main/src/cgeo/geocaching/network/Network.java6
-rw-r--r--main/src/cgeo/geocaching/network/Parameters.java4
-rw-r--r--main/src/cgeo/geocaching/ui/LoggingUI.java1
-rw-r--r--main/src/cgeo/geocaching/utils/PeriodicHandler.java2
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java18
-rw-r--r--tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java1
-rw-r--r--tests/src/cgeo/geocaching/sorting/NameComparatorTest.java8
-rw-r--r--tests/src/cgeo/geocaching/test/RegExPerformanceTest.java2
-rw-r--r--tests/src/cgeo/geocaching/test/mock/MockedCache.java2
41 files changed, 119 insertions, 138 deletions
diff --git a/cgeo-calendar/src/cgeo/calendar/AddEntry.java b/cgeo-calendar/src/cgeo/calendar/AddEntry.java
index 39092cb..b1f97b9 100644
--- a/cgeo-calendar/src/cgeo/calendar/AddEntry.java
+++ b/cgeo-calendar/src/cgeo/calendar/AddEntry.java
@@ -32,7 +32,7 @@ class AddEntry extends AbstractAddEntry {
final ContentValues event = new ContentValues();
event.put("calendar_id", calendarId);
if (entry.getStartTimeMinutes() >= 0) {
- event.put("dtstart", eventDate.getTime() + entry.getStartTimeMinutes() * 60000);
+ event.put("dtstart", eventDate.getTime() + entry.getStartTimeMinutes() * 60000L);
}
else {
event.put("dtstart", eventDate.getTime() + 43200000); // noon
diff --git a/cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java b/cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java
index 787be73..44453dd 100644
--- a/cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java
+++ b/cgeo-calendar/src/cgeo/calendar/AddEntryLevel14.java
@@ -35,7 +35,7 @@ class AddEntryLevel14 extends AbstractAddEntry {
.putExtra("eventTimezone", "UTC")
.putExtra("eventLocation", eventLocation);
if (entry.getStartTimeMinutes() >= 0) {
- intent.putExtra("beginTime", eventDate.getTime() + entry.getStartTimeMinutes() * 60000);
+ intent.putExtra("beginTime", eventDate.getTime() + entry.getStartTimeMinutes() * 60000L);
}
else {
intent.putExtra("beginTime", eventDate.getTime() + 43200000);
diff --git a/cgeo-calendar/src/cgeo/calendar/CalendarEntry.java b/cgeo-calendar/src/cgeo/calendar/CalendarEntry.java
index 3e4de73..e31e054 100644
--- a/cgeo-calendar/src/cgeo/calendar/CalendarEntry.java
+++ b/cgeo-calendar/src/cgeo/calendar/CalendarEntry.java
@@ -2,6 +2,8 @@ package cgeo.calendar;
import cgeo.geocaching.utils.Log;
+import org.apache.commons.lang3.CharEncoding;
+
import android.net.Uri;
import android.text.Html;
import android.text.Spanned;
@@ -48,7 +50,7 @@ class CalendarEntry {
if (param == null) {
return "";
}
- return URLDecoder.decode(param, "UTF-8").trim();
+ return URLDecoder.decode(param, CharEncoding.UTF_8).trim();
} catch (UnsupportedEncodingException e) {
Log.e("CalendarEntry.getParameter", e);
}
@@ -56,7 +58,7 @@ class CalendarEntry {
}
public boolean isValid() {
- return (getName().length() > 0 && getHiddenDate().length() > 0);
+ return getName().length() > 0 && getHiddenDate().length() > 0;
}
public String getHiddenDate() {
diff --git a/main/src/cgeo/geocaching/AbstractLoggingActivity.java b/main/src/cgeo/geocaching/AbstractLoggingActivity.java
index 62cb5cb..4816dee 100644
--- a/main/src/cgeo/geocaching/AbstractLoggingActivity.java
+++ b/main/src/cgeo/geocaching/AbstractLoggingActivity.java
@@ -20,7 +20,7 @@ public abstract class AbstractLoggingActivity extends AbstractActivity {
private static final int MENU_SIGNATURE = 1;
private static final int MENU_SMILEY = 2;
- public AbstractLoggingActivity(String helpTopic) {
+ protected AbstractLoggingActivity(String helpTopic) {
super(helpTopic);
}
diff --git a/main/src/cgeo/geocaching/AbstractPopupActivity.java b/main/src/cgeo/geocaching/AbstractPopupActivity.java
index e3f7aeb..db9a04c 100644
--- a/main/src/cgeo/geocaching/AbstractPopupActivity.java
+++ b/main/src/cgeo/geocaching/AbstractPopupActivity.java
@@ -73,7 +73,7 @@ public abstract class AbstractPopupActivity extends AbstractActivity {
}
};
- public AbstractPopupActivity(String helpTopic, int layout) {
+ protected AbstractPopupActivity(String helpTopic, int layout) {
super(helpTopic);
this.layout = layout;
}
@@ -186,10 +186,10 @@ public abstract class AbstractPopupActivity extends AbstractActivity {
case MENU_SHOW_IN_BROWSER:
showInBrowser();
return true;
- }
-
- if (LoggingUI.onMenuItemSelected(item, this, cache)) {
- return true;
+ default:
+ if (LoggingUI.onMenuItemSelected(item, this, cache)) {
+ return true;
+ }
}
return true;
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 0d4482f..188f939 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -566,16 +566,17 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
return true;
}
return false;
- }
- if (NavigationAppFactory.onMenuItemSelected(item, this, cache)) {
- return true;
- }
- if (GeneralAppsFactory.onMenuItemSelected(item, this, cache)) {
- return true;
- }
- if (LoggingUI.onMenuItemSelected(item, this, cache)) {
- refreshOnResume = true;
- return true;
+ default:
+ if (NavigationAppFactory.onMenuItemSelected(item, this, cache)) {
+ return true;
+ }
+ if (GeneralAppsFactory.onMenuItemSelected(item, this, cache)) {
+ return true;
+ }
+ if (LoggingUI.onMenuItemSelected(item, this, cache)) {
+ refreshOnResume = true;
+ return true;
+ }
}
return true;
diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java
index 4d93bb4..001d73f 100644
--- a/main/src/cgeo/geocaching/EditWaypointActivity.java
+++ b/main/src/cgeo/geocaching/EditWaypointActivity.java
@@ -304,7 +304,7 @@ public class EditWaypointActivity extends AbstractActivity {
}
}
- private class changeWaypointType implements OnItemSelectedListener {
+ private static class changeWaypointType implements OnItemSelectedListener {
private changeWaypointType(EditWaypointActivity wpView) {
this.wpView = wpView;
@@ -328,7 +328,7 @@ public class EditWaypointActivity extends AbstractActivity {
}
}
- private class changeDistanceUnit implements OnItemSelectedListener {
+ private static class changeDistanceUnit implements OnItemSelectedListener {
private changeDistanceUnit(EditWaypointActivity unitView) {
this.unitView = unitView;
diff --git a/main/src/cgeo/geocaching/SearchResult.java b/main/src/cgeo/geocaching/SearchResult.java
index d39066d..d1b1df6 100644
--- a/main/src/cgeo/geocaching/SearchResult.java
+++ b/main/src/cgeo/geocaching/SearchResult.java
@@ -169,7 +169,7 @@ public class SearchResult implements Parcelable {
return;
}
- this.viewstates = viewstates;
+ System.arraycopy(viewstates, 0, this.viewstates, 0, viewstates.length);
}
public int getTotal() {
diff --git a/main/src/cgeo/geocaching/StaticMapsActivity.java b/main/src/cgeo/geocaching/StaticMapsActivity.java
index 82fa46d..c0a7f47 100644
--- a/main/src/cgeo/geocaching/StaticMapsActivity.java
+++ b/main/src/cgeo/geocaching/StaticMapsActivity.java
@@ -10,7 +10,6 @@ import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -36,7 +35,6 @@ public class StaticMapsActivity extends AbstractActivity {
private LayoutInflater inflater = null;
private ProgressDialog waitDialog = null;
private LinearLayout smapsView = null;
- private BitmapFactory factory = null;
private final Handler loadMapsHandler = new Handler() {
@Override
@@ -131,10 +129,6 @@ public class StaticMapsActivity extends AbstractActivity {
@Override
public void run() {
try {
- if (factory == null) {
- factory = new BitmapFactory();
- }
-
// try downloading 2 times
for (int trials = 0; trials < 2; trials++) {
for (int level = 1; level <= 5; level++) {
diff --git a/main/src/cgeo/geocaching/TrackableActivity.java b/main/src/cgeo/geocaching/TrackableActivity.java
index e4bc02f..b01942f 100644
--- a/main/src/cgeo/geocaching/TrackableActivity.java
+++ b/main/src/cgeo/geocaching/TrackableActivity.java
@@ -250,8 +250,9 @@ public class TrackableActivity extends AbstractViewPagerActivity<TrackableActivi
case MENU_BROWSER_TRACKABLE:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(trackable.getUrl())));
return true;
+ default:
+ return false;
}
- return false;
}
@Override
diff --git a/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java b/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java
index 4d1344d..56431d4 100644
--- a/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java
+++ b/main/src/cgeo/geocaching/activity/AbstractViewPagerActivity.java
@@ -29,7 +29,7 @@ import java.util.Map;
*/
public abstract class AbstractViewPagerActivity<Page extends Enum<Page>> extends AbstractActivity {
- public AbstractViewPagerActivity(String helpTopic) {
+ protected AbstractViewPagerActivity(String helpTopic) {
super(helpTopic);
}
@@ -173,7 +173,7 @@ public abstract class AbstractViewPagerActivity<Page extends Enum<Page>> extends
/**
* Create the view pager. Call this from the {@link Activity#onCreate} implementation.
- *
+ *
* @param startPageIndex
* index of the page shown first
* @param pageSelectedListener
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
index f8521ad..85a4b93 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java
@@ -15,7 +15,7 @@ import org.apache.commons.lang3.StringUtils;
import android.app.Activity;
abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigationApp, WaypointNavigationApp {
- public AbstractStaticMapsApp(String name) {
+ protected AbstractStaticMapsApp(String name) {
super(name, null);
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
index e74eb89..f1616ad 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
@@ -12,7 +12,7 @@ abstract class GoogleNavigationApp extends AbstractPointNavigationApp {
private final String mode;
- GoogleNavigationApp(final int nameResourceId, final String mode) {
+ protected GoogleNavigationApp(final int nameResourceId, final String mode) {
super(getString(nameResourceId), null);
this.mode = mode;
}
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index a4c1ea9..ce43faa 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -905,9 +905,9 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity
moveCachesToOtherList();
invalidateOptionsMenuCompatible();
return true;
+ default:
+ return CacheListAppFactory.onMenuItemSelected(item, cacheList, this, search);
}
-
- return CacheListAppFactory.onMenuItemSelected(item, cacheList, this, search);
}
/**
diff --git a/main/src/cgeo/geocaching/cgeocoords.java b/main/src/cgeo/geocaching/cgeocoords.java
index 1cf9630..0c2ffbf 100644
--- a/main/src/cgeo/geocaching/cgeocoords.java
+++ b/main/src/cgeo/geocaching/cgeocoords.java
@@ -378,6 +378,8 @@ public class cgeocoords extends Dialog {
break;
case Plain:
// This case has been handled above
+ default:
+ throw new IllegalArgumentException();
}
return true;
diff --git a/main/src/cgeo/geocaching/cgeopoint.java b/main/src/cgeo/geocaching/cgeopoint.java
index d89d324..e399a97 100644
--- a/main/src/cgeo/geocaching/cgeopoint.java
+++ b/main/src/cgeo/geocaching/cgeopoint.java
@@ -304,7 +304,7 @@ public class cgeopoint extends AbstractActivity {
}
}
- private class changeDistanceUnit implements OnItemSelectedListener {
+ private static class changeDistanceUnit implements OnItemSelectedListener {
private changeDistanceUnit(cgeopoint unitView) {
this.unitView = unitView;
diff --git a/main/src/cgeo/geocaching/connector/gc/AbstractSearchThread.java b/main/src/cgeo/geocaching/connector/gc/AbstractSearchThread.java
index d0e45f6..f19064d 100644
--- a/main/src/cgeo/geocaching/connector/gc/AbstractSearchThread.java
+++ b/main/src/cgeo/geocaching/connector/gc/AbstractSearchThread.java
@@ -12,7 +12,7 @@ abstract public class AbstractSearchThread extends Thread {
private final Handler handler;
private static AbstractSearchThread currentInstance;
- public AbstractSearchThread(final Handler handler) {
+ protected AbstractSearchThread(final Handler handler) {
this.handler = handler;
}
diff --git a/main/src/cgeo/geocaching/connector/gc/GCConnector.java b/main/src/cgeo/geocaching/connector/gc/GCConnector.java
index 8eed4bf..5de170b 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCConnector.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCConnector.java
@@ -21,18 +21,21 @@ import java.util.regex.Pattern;
public class GCConnector extends AbstractConnector implements ISearchByGeocode, ISearchByCenter {
private static final String HTTP_COORD_INFO = "http://coord.info/";
- private static GCConnector instance;
private static final Pattern gpxZipFilePattern = Pattern.compile("\\d{7,}(_.+)?\\.zip", Pattern.CASE_INSENSITIVE);
private GCConnector() {
// singleton
}
+ /**
+ * initialization on demand holder pattern
+ */
+ private static class Holder {
+ private static final GCConnector INSTANCE = new GCConnector();
+ }
+
public static GCConnector getInstance() {
- if (instance == null) {
- instance = new GCConnector();
- }
- return instance;
+ return Holder.INSTANCE;
}
@Override
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 60e6688..c40d470 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -1396,7 +1396,6 @@ public abstract class GCParser {
// Apply the pattern for images in a trackable log entry against each full log (group(0))
final String logEntry = matcherLogs.group(0);
- System.out.println(logEntry);
final Matcher matcherLogImages = GCConstants.PATTERN_TRACKABLE_LOG_IMAGES.matcher(logEntry);
/*
* 1. Image URL
@@ -1713,8 +1712,7 @@ public abstract class GCParser {
}
} catch (JSONException e) {
- Log.e("Unknown exception with json wrap code");
- e.printStackTrace();
+ Log.e("Unknown exception with json wrap code", e);
}
Log.e("GCParser.deleteModifiedCoordinates - cannot delete modified coords");
return false;
diff --git a/main/src/cgeo/geocaching/export/FieldnoteExport.java b/main/src/cgeo/geocaching/export/FieldnoteExport.java
index 6d0364e..65dc291 100644
--- a/main/src/cgeo/geocaching/export/FieldnoteExport.java
+++ b/main/src/cgeo/geocaching/export/FieldnoteExport.java
@@ -12,7 +12,9 @@ import cgeo.geocaching.network.Network;
import cgeo.geocaching.network.Parameters;
import cgeo.geocaching.utils.Log;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
+import org.mapsforge.core.IOUtils;
import android.app.Activity;
import android.app.AlertDialog;
@@ -154,32 +156,25 @@ class FieldnoteExport extends AbstractExport {
fieldNoteBuffer.append('\n');
- if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
- exportLocation.mkdirs();
+ if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+ return false;
+ }
- SimpleDateFormat fileNameDateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
- exportFile = new File(exportLocation.toString() + '/' + fileNameDateFormat.format(new Date()) + ".txt");
+ exportLocation.mkdirs();
- Writer fw = null;
- try {
- OutputStream os = new FileOutputStream(exportFile);
- fw = new OutputStreamWriter(os, "UTF-16");
- fw.write(fieldNoteBuffer.toString());
- } catch (IOException e) {
- Log.e("FieldnoteExport.ExportTask export", e);
- return false;
- } finally {
- if (fw != null) {
- try {
- fw.close();
- } catch (IOException e) {
- Log.e("FieldnoteExport.ExportTask export", e);
- return false;
- }
- }
- }
- } else {
+ SimpleDateFormat fileNameDateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
+ exportFile = new File(exportLocation.toString() + '/' + fileNameDateFormat.format(new Date()) + ".txt");
+
+ Writer fw = null;
+ try {
+ OutputStream os = new FileOutputStream(exportFile);
+ fw = new OutputStreamWriter(os, CharEncoding.UTF_16);
+ fw.write(fieldNoteBuffer.toString());
+ } catch (IOException e) {
+ Log.e("FieldnoteExport.ExportTask export", e);
return false;
+ } finally {
+ IOUtils.closeQuietly(fw);
}
if (upload) {
diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java
index b1834b9..3aec114 100644
--- a/main/src/cgeo/geocaching/export/GpxExport.java
+++ b/main/src/cgeo/geocaching/export/GpxExport.java
@@ -51,7 +51,7 @@ class GpxExport extends AbstractExport {
if (null == activity) {
// No activity given, so no user interaction possible.
// Start export with default parameters.
- new ExportTask(caches, activity).execute((Void) null);
+ new ExportTask(caches, null).execute((Void) null);
} else {
// Show configuration dialog
diff --git a/main/src/cgeo/geocaching/files/GPXImporter.java b/main/src/cgeo/geocaching/files/GPXImporter.java
index 1c6f1af..750d5e0 100644
--- a/main/src/cgeo/geocaching/files/GPXImporter.java
+++ b/main/src/cgeo/geocaching/files/GPXImporter.java
@@ -124,7 +124,7 @@ public class GPXImporter {
final Handler importStepHandler;
final CancellableHandler progressHandler;
- public ImportThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
+ protected ImportThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
this.listId = listId;
this.importStepHandler = importStepHandler;
this.progressHandler = progressHandler;
@@ -204,7 +204,7 @@ public class GPXImporter {
static abstract class ImportGpxThread extends ImportThread {
- public ImportGpxThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
+ protected ImportGpxThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
super(listId, importStepHandler, progressHandler);
}
@@ -274,7 +274,7 @@ public class GPXImporter {
static abstract class ImportGpxZipThread extends ImportGpxThread {
- public ImportGpxZipThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
+ protected ImportGpxZipThread(int listId, Handler importStepHandler, CancellableHandler progressHandler) {
super(listId, importStepHandler, progressHandler);
}
diff --git a/main/src/cgeo/geocaching/filter/AbstractFilter.java b/main/src/cgeo/geocaching/filter/AbstractFilter.java
index 44d6d3f..f78a218 100644
--- a/main/src/cgeo/geocaching/filter/AbstractFilter.java
+++ b/main/src/cgeo/geocaching/filter/AbstractFilter.java
@@ -8,7 +8,7 @@ import java.util.List;
abstract class AbstractFilter implements IFilter {
private final String name;
- public AbstractFilter(String name) {
+ protected AbstractFilter(String name) {
this.name = name;
}
diff --git a/main/src/cgeo/geocaching/filter/AbstractRangeFilter.java b/main/src/cgeo/geocaching/filter/AbstractRangeFilter.java
index 829a1d9..e84174a 100644
--- a/main/src/cgeo/geocaching/filter/AbstractRangeFilter.java
+++ b/main/src/cgeo/geocaching/filter/AbstractRangeFilter.java
@@ -8,7 +8,7 @@ abstract class AbstractRangeFilter extends AbstractFilter {
protected final float rangeMin;
protected final float rangeMax;
- public AbstractRangeFilter(int ressourceId, int range) {
+ protected AbstractRangeFilter(int ressourceId, int range) {
super(cgeoapplication.getInstance().getResources().getString(ressourceId) + ' ' + (range == 5 ? '5' : range + " + " + String.format("%.1f", range + 0.5)));
this.rangeMin = range;
rangeMax = rangeMin + 1f;
diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java
index fb21a0c..0dfdbcb 100644
--- a/main/src/cgeo/geocaching/geopoint/Geopoint.java
+++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java
@@ -102,7 +102,7 @@ public final class Geopoint implements ICoordinates, Parcelable {
* @param lonDegFrac
*/
public Geopoint(final String latDir, final String latDeg, final String latDegFrac,
- final String lonDir, final String lonDeg, final String lonDegFrac) {
+ final String lonDir, final String lonDeg, final String lonDegFrac) {
latitude = Double.parseDouble(latDeg + "." + addZeros(Integer.parseInt(latDegFrac), 5)) *
getLatSign(latDir);
longitude = Double.parseDouble(lonDeg + "." + addZeros(Integer.parseInt(lonDegFrac), 5)) *
@@ -122,7 +122,7 @@ public final class Geopoint implements ICoordinates, Parcelable {
* @param lonMinFrac
*/
public Geopoint(final String latDir, final String latDeg, final String latMin, final String latMinFrac,
- final String lonDir, final String lonDeg, final String lonMin, final String lonMinFrac) {
+ final String lonDir, final String lonDeg, final String lonMin, final String lonMinFrac) {
latitude = (Double.parseDouble(latDeg) + Double.parseDouble(latMin + "." + addZeros(Integer.parseInt(latMinFrac), 3)) / 60) *
(getLatSign(latDir));
longitude = (Double.parseDouble(lonDeg) + Double.parseDouble(lonMin + "." + addZeros(Integer.parseInt(lonMinFrac), 3)) / 60) *
@@ -144,7 +144,7 @@ public final class Geopoint implements ICoordinates, Parcelable {
* @param lonSecFrac
*/
public Geopoint(final String latDir, final String latDeg, final String latMin, final String latSec, final String latSecFrac,
- final String lonDir, final String lonDeg, final String lonMin, final String lonSec, final String lonSecFrac) {
+ final String lonDir, final String lonDeg, final String lonMin, final String lonSec, final String lonSecFrac) {
latitude = (Double.parseDouble(latDeg) + Double.parseDouble(latMin) / 60 + Double.parseDouble(latSec + "." + addZeros(Integer.parseInt(latSecFrac), 3)) / 3600) *
(getLatSign(latDir));
longitude = (Double.parseDouble(lonDeg) + Double.parseDouble(lonMin) / 60 + Double.parseDouble(lonSec + "." + addZeros(Integer.parseInt(lonSecFrac), 3)) / 3600) *
@@ -280,8 +280,7 @@ public final class Geopoint implements ICoordinates, Parcelable {
* tolerance in km
* @return true if similar, false otherwise
*/
- public boolean isEqualTo(Geopoint gp, double tolerance)
- {
+ public boolean isEqualTo(Geopoint gp, double tolerance) {
return null != gp && distanceTo(gp) <= tolerance;
}
@@ -293,42 +292,35 @@ public final class Geopoint implements ICoordinates, Parcelable {
* @see GeopointFormatter
* @return formatted coordinates
*/
- public String format(GeopointFormatter.Format format)
- {
+ public String format(GeopointFormatter.Format format) {
return GeopointFormatter.format(format, this);
}
/**
* Returns formatted coordinates with default format.
* Default format is decimalminutes, e.g. N 52° 36.123 E 010° 03.456
- *
+ *
* @return formatted coordinates
*/
@Override
- public String toString()
- {
+ public String toString() {
return format(GeopointFormatter.Format.LAT_LON_DECMINUTE);
}
- abstract public static class GeopointException
- extends RuntimeException
- {
+ abstract public static class GeopointException extends NumberFormatException {
private static final long serialVersionUID = 1L;
- public GeopointException(String msg)
+ protected GeopointException(String msg)
{
super(msg);
}
}
- public static class ParseException
- extends GeopointException
- {
+ public static class ParseException extends GeopointException {
private static final long serialVersionUID = 1L;
public final int resource;
- public ParseException(final String msg, final GeopointParser.LatLon faulty)
- {
+ public ParseException(final String msg, final GeopointParser.LatLon faulty) {
super(msg);
resource = faulty == GeopointParser.LatLon.LAT ? R.string.err_parse_lat : R.string.err_parse_lon;
}
diff --git a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java
index 356feae..0e676ce 100644
--- a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java
+++ b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java
@@ -96,10 +96,9 @@ public class GeopointFormatter
case LON_DECMINUTE_RAW:
return String.format(Locale.getDefault(), "%c %03d %06.3f", gp.getLonDir(), gp.getLonDeg(), gp.getLonMinRaw());
+ default:
+ throw new IllegalArgumentException();
}
-
- // Keep the compiler happy even though it cannot happen
- return null;
}
}
diff --git a/main/src/cgeo/geocaching/maps/AbstractMapSource.java b/main/src/cgeo/geocaching/maps/AbstractMapSource.java
index 90a61d2..1d219d3 100644
--- a/main/src/cgeo/geocaching/maps/AbstractMapSource.java
+++ b/main/src/cgeo/geocaching/maps/AbstractMapSource.java
@@ -9,7 +9,7 @@ public abstract class AbstractMapSource implements MapSource {
private final MapProvider mapProvider;
private final String id;
- public AbstractMapSource(final String id, final MapProvider mapProvider, final String name) {
+ protected AbstractMapSource(final String id, final MapProvider mapProvider, final String name) {
this.id = id;
this.mapProvider = mapProvider;
this.name = name;
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 92018ea..32814c4 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -1336,7 +1336,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
final protected Viewport viewport;
- public DoRunnable(final Viewport viewport) {
+ protected DoRunnable(final Viewport viewport) {
this.viewport = viewport;
}
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapProvider.java b/main/src/cgeo/geocaching/maps/google/GoogleMapProvider.java
index dbe41d6..1fa38ad 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleMapProvider.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleMapProvider.java
@@ -16,7 +16,6 @@ public final class GoogleMapProvider extends AbstractMapProvider {
public static final String GOOGLE_MAP_ID = "GOOGLE_MAP";
public static final String GOOGLE_SATELLITE_ID = "GOOGLE_SATELLITE";
- private static GoogleMapProvider instance;
private final MapItemFactory mapItemFactory;
@@ -29,11 +28,12 @@ public final class GoogleMapProvider extends AbstractMapProvider {
mapItemFactory = new GoogleMapItemFactory();
}
+ private static class Holder {
+ private static final GoogleMapProvider INSTANCE = new GoogleMapProvider();
+ }
+
public static GoogleMapProvider getInstance() {
- if (instance == null) {
- instance = new GoogleMapProvider();
- }
- return instance;
+ return Holder.INSTANCE;
}
public static boolean isSatelliteSource(final MapSource mapSource) {
@@ -67,7 +67,7 @@ public final class GoogleMapProvider extends AbstractMapProvider {
private static abstract class AbstractGoogleMapSource extends AbstractMapSource {
- public AbstractGoogleMapSource(final String id, final MapProvider mapProvider, final String name) {
+ protected AbstractGoogleMapSource(final String id, final MapProvider mapProvider, final String name) {
super(id, mapProvider, name);
}
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java
index d86eafe..773f9ff 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java
@@ -27,6 +27,9 @@ public class GoogleOverlay extends Overlay implements OverlayImpl {
break;
case ScaleOverlay:
overlayBase = new ScaleOverlay(activityIn, this);
+ break;
+ default:
+ throw new IllegalArgumentException();
}
}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java
index 8eef130..294eb79 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java
@@ -31,7 +31,6 @@ public final class MapsforgeMapProvider extends AbstractMapProvider {
public static final String MAPSFORGE_MAPNIK_ID = "MAPSFORGE_MAPNIK";
private boolean oldMap = false;
private MapItemFactory mapItemFactory = new MapsforgeMapItemFactory();
- private static MapsforgeMapProvider instance;
private MapsforgeMapProvider() {
final Resources resources = cgeoapplication.getInstance().getResources();
@@ -42,11 +41,12 @@ public final class MapsforgeMapProvider extends AbstractMapProvider {
updateOfflineMaps();
}
+ private static final class Holder {
+ private static final MapsforgeMapProvider INSTANCE = new MapsforgeMapProvider();
+ }
+
public static MapsforgeMapProvider getInstance() {
- if (instance == null) {
- instance = new MapsforgeMapProvider();
- }
- return instance;
+ return Holder.INSTANCE;
}
public static List<String> getOfflineMaps() {
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
index b6e31a2..dd7fb75 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
@@ -29,6 +29,9 @@ public class MapsforgeOverlay extends Overlay implements OverlayImpl {
break;
case ScaleOverlay:
overlayBase = new ScaleOverlay(activityIn, this);
+ break;
+ default:
+ throw new IllegalArgumentException();
}
}
diff --git a/main/src/cgeo/geocaching/network/Network.java b/main/src/cgeo/geocaching/network/Network.java
index 67964e3..c3265fe 100644
--- a/main/src/cgeo/geocaching/network/Network.java
+++ b/main/src/cgeo/geocaching/network/Network.java
@@ -62,7 +62,7 @@ public abstract class Network {
private final static HttpParams clientParams = new BasicHttpParams();
static {
- Network.clientParams.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
+ Network.clientParams.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, CharEncoding.UTF_8);
Network.clientParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 30000);
Network.clientParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, 30000);
Network.clientParams.setParameter(ClientPNames.HANDLE_REDIRECTS, true);
@@ -230,7 +230,7 @@ public abstract class Network {
request = new HttpPost(uri);
if (params != null) {
try {
- ((HttpPost) request).setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
+ ((HttpPost) request).setEntity(new UrlEncodedFormEntity(params, CharEncoding.UTF_8));
} catch (final UnsupportedEncodingException e) {
Log.e("request", e);
return null;
@@ -401,7 +401,7 @@ public abstract class Network {
private static String getResponseDataNoError(final HttpResponse response, boolean replaceWhitespace) {
try {
- String data = EntityUtils.toString(response.getEntity(), "UTF-8");
+ String data = EntityUtils.toString(response.getEntity(), CharEncoding.UTF_8);
return replaceWhitespace ? BaseUtils.replaceWhitespace(data) : data;
} catch (Exception e) {
Log.e("getResponseData", e);
diff --git a/main/src/cgeo/geocaching/network/Parameters.java b/main/src/cgeo/geocaching/network/Parameters.java
index 3957d38..74f5531 100644
--- a/main/src/cgeo/geocaching/network/Parameters.java
+++ b/main/src/cgeo/geocaching/network/Parameters.java
@@ -4,6 +4,8 @@ import ch.boye.httpclientandroidlib.NameValuePair;
import ch.boye.httpclientandroidlib.client.utils.URLEncodedUtils;
import ch.boye.httpclientandroidlib.message.BasicNameValuePair;
+import org.apache.commons.lang3.CharEncoding;
+
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Collections;
@@ -65,7 +67,7 @@ public class Parameters extends ArrayList<NameValuePair> {
@Override
public String toString() {
- return URLEncodedUtils.format(this, "UTF-8");
+ return URLEncodedUtils.format(this, CharEncoding.UTF_8);
}
/**
diff --git a/main/src/cgeo/geocaching/ui/LoggingUI.java b/main/src/cgeo/geocaching/ui/LoggingUI.java
index 746b50d..eaa25ef 100644
--- a/main/src/cgeo/geocaching/ui/LoggingUI.java
+++ b/main/src/cgeo/geocaching/ui/LoggingUI.java
@@ -124,6 +124,7 @@ public class LoggingUI extends AbstractUIFactory {
case CLEAR_LOG:
cgData.clearLogOffline(cache.getGeocode());
+ break;
}
} else {
cache.logOffline(activity, logTypeEntry.logType);
diff --git a/main/src/cgeo/geocaching/utils/PeriodicHandler.java b/main/src/cgeo/geocaching/utils/PeriodicHandler.java
index 3f6c345..ac6b22a 100644
--- a/main/src/cgeo/geocaching/utils/PeriodicHandler.java
+++ b/main/src/cgeo/geocaching/utils/PeriodicHandler.java
@@ -26,7 +26,7 @@ abstract public class PeriodicHandler extends Handler {
* @param period
* The period in milliseconds.
*/
- public PeriodicHandler(final long period) {
+ protected PeriodicHandler(final long period) {
this.period = period;
}
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index f6e6e66..bf09256 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -216,26 +216,16 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
return new ArrayList<cgCache>(cgData.loadCaches(result, LoadFlags.LOAD_ALL_DB_ONLY));
}
- public static void testParseDateWithFractionalSeconds() {
+ public static void testParseDateWithFractionalSeconds() throws ParseException {
// was experienced in GSAK file
final String dateString = "2011-08-13T02:52:18.103Z";
- try {
- GPXParser.parseDate(dateString);
- } catch (ParseException e) {
- fail();
- e.printStackTrace();
- }
+ GPXParser.parseDate(dateString);
}
- public static void testParseDateWithHugeFraction() {
+ public static void testParseDateWithHugeFraction() throws ParseException {
// see issue 821
String dateString = "2011-11-07T00:00:00.0000000-07:00";
- try {
- GPXParser.parseDate(dateString);
- } catch (ParseException e) {
- fail();
- e.printStackTrace();
- }
+ GPXParser.parseDate(dateString);
}
public void testSelfmadeGPXWithoutGeocodes() throws Exception {
diff --git a/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java b/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
index c905bc2..cbcd176 100644
--- a/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
+++ b/tests/src/cgeo/geocaching/files/SimpleDirChooserUITest.java
@@ -20,6 +20,7 @@ public class SimpleDirChooserUITest extends ActivityInstrumentationTestCase2<Sim
@Override
public void setUp() throws Exception {
+ super.setUp();
solo = new Solo(getInstrumentation(), getActivity());
}
diff --git a/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java b/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java
index fa3b16c..98c77fd 100644
--- a/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java
+++ b/tests/src/cgeo/geocaching/sorting/NameComparatorTest.java
@@ -13,13 +13,7 @@ public class NameComparatorTest extends AndroidTestCase {
}
}
- private NameComparator comp;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- comp = new NameComparator();
- }
+ private NameComparator comp = new NameComparator();
public void testLexical() {
assertSorted(new NamedCache("A"), new NamedCache("Z"));
diff --git a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java
index b9f8138..5e46445 100644
--- a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java
+++ b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java
@@ -124,7 +124,7 @@ public class RegExPerformanceTest extends TestCase {
for (int j = 0; j < iterations; j++) {
BaseUtils.getMatch(page, pattern, true, "");
}
- return (System.currentTimeMillis() - start);
+ return System.currentTimeMillis() - start;
}
diff --git a/tests/src/cgeo/geocaching/test/mock/MockedCache.java b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
index 352c34d..8517c81 100644
--- a/tests/src/cgeo/geocaching/test/mock/MockedCache.java
+++ b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
@@ -70,7 +70,7 @@ public abstract class MockedCache implements ICache {
return BaseUtils.replaceWhitespace(buffer.toString());
} catch (IOException e) {
- e.printStackTrace();
+ Assert.fail(e.getMessage());
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(br);