diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2013-02-24 10:25:43 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2013-02-24 10:25:43 +0100 |
commit | 684e8419fb4fa0f38fe9a1fd3b474a853a274484 (patch) | |
tree | ea2320aea9ca2392aec59b6a87b8db676b0f16bd | |
parent | c32d501ce28356c99b3b89d39bc2a3a345018efc (diff) | |
download | cgeo-684e8419fb4fa0f38fe9a1fd3b474a853a274484.zip cgeo-684e8419fb4fa0f38fe9a1fd3b474a853a274484.tar.gz cgeo-684e8419fb4fa0f38fe9a1fd3b474a853a274484.tar.bz2 |
code cleanup
* rename several lower case classes
* more strict visibility modifiers
* Lint warnings
* style warnings
62 files changed, 314 insertions, 320 deletions
diff --git a/main/AndroidManifest.xml b/main/AndroidManifest.xml index 35cac8a..96278a7 100644 --- a/main/AndroidManifest.xml +++ b/main/AndroidManifest.xml @@ -86,7 +86,7 @@ android:configChanges="keyboardHidden|orientation" > </activity> <activity - android:name=".cgeopoint" + android:name=".NavigateAnyPointActivity" android:label="@string/app_name" android:windowSoftInputMode="stateHidden" android:configChanges="keyboardHidden|orientation" > @@ -207,12 +207,12 @@ android:label="@string/app_name_compass"> </activity> <activity - android:name=".cgeogpxes" + android:name=".GpxFileListActivity" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation" > </activity> <activity - android:name=".cgSelectMapfile" + android:name=".SelectMapfileActivity" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation" > </activity> diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 0cf016d..5da9ca0 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -1883,7 +1883,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc } - private class HtmlImageCounter implements Html.ImageGetter { + private static class HtmlImageCounter implements Html.ImageGetter { private int imageCount = 0; @@ -2142,8 +2142,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc /** Loads the Log Images outside the ui thread. */ - private class LogImageLoader extends AsyncTask<String, Progress, Spanned> - { + private class LogImageLoader extends AsyncTask<String, Progress, Spanned> { private LogViewHolder holder; public LogImageLoader(LogViewHolder holder) { diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java index 3c8789f..bae0ead 100644 --- a/main/src/cgeo/geocaching/EditWaypointActivity.java +++ b/main/src/cgeo/geocaching/EditWaypointActivity.java @@ -133,12 +133,12 @@ public class EditWaypointActivity extends AbstractActivity { } Button buttonLat = (Button) findViewById(R.id.buttonLatitude); - buttonLat.setOnClickListener(new coordDialogListener()); + buttonLat.setOnClickListener(new CoordDialogListener()); Button buttonLon = (Button) findViewById(R.id.buttonLongitude); - buttonLon.setOnClickListener(new coordDialogListener()); + buttonLon.setOnClickListener(new CoordDialogListener()); Button addWaypoint = (Button) findViewById(R.id.add_waypoint); - addWaypoint.setOnClickListener(new coordsListener()); + addWaypoint.setOnClickListener(new CoordsListener()); List<String> wayPointNames = new ArrayList<String>(); for (WaypointType wpt : WaypointType.ALL_TYPES_EXCEPT_OWN_AND_ORIGINAL) { @@ -155,7 +155,7 @@ public class EditWaypointActivity extends AbstractActivity { waitDialog = ProgressDialog.show(this, null, res.getString(R.string.waypoint_loading), true); waitDialog.setCancelable(true); - (new loadWaypoint()).start(); + (new LoadWaypointThread()).start(); } else { initializeWaypointTypeSelector(); } @@ -192,7 +192,7 @@ public class EditWaypointActivity extends AbstractActivity { waitDialog = ProgressDialog.show(this, null, res.getString(R.string.waypoint_loading), true); waitDialog.setCancelable(true); - (new loadWaypoint()).start(); + (new LoadWaypointThread()).start(); } } } @@ -228,7 +228,7 @@ public class EditWaypointActivity extends AbstractActivity { } waypointTypeSelector.setSelection(typeIndex); - waypointTypeSelector.setOnItemSelectedListener(new changeWaypointType(this)); + waypointTypeSelector.setOnItemSelectedListener(new ChangeWaypointType(this)); waypointTypeSelector.setVisibility(View.VISIBLE); } @@ -247,7 +247,7 @@ public class EditWaypointActivity extends AbstractActivity { } } - distanceUnitSelector.setOnItemSelectedListener(new changeDistanceUnit(this)); + distanceUnitSelector.setOnItemSelectedListener(new ChangeDistanceUnit(this)); } final private GeoDirHandler geoDirHandler = new GeoDirHandler() { @@ -268,7 +268,7 @@ public class EditWaypointActivity extends AbstractActivity { } }; - private class loadWaypoint extends Thread { + private class LoadWaypointThread extends Thread { @Override public void run() { @@ -282,7 +282,7 @@ public class EditWaypointActivity extends AbstractActivity { } } - private class coordDialogListener implements View.OnClickListener { + private class CoordDialogListener implements View.OnClickListener { @Override public void onClick(View arg0) { @@ -311,9 +311,9 @@ public class EditWaypointActivity extends AbstractActivity { } } - private static class changeWaypointType implements OnItemSelectedListener { + private static class ChangeWaypointType implements OnItemSelectedListener { - private changeWaypointType(EditWaypointActivity wpView) { + private ChangeWaypointType(EditWaypointActivity wpView) { this.wpView = wpView; } @@ -335,9 +335,9 @@ public class EditWaypointActivity extends AbstractActivity { } } - private static class changeDistanceUnit implements OnItemSelectedListener { + private static class ChangeDistanceUnit implements OnItemSelectedListener { - private changeDistanceUnit(EditWaypointActivity unitView) { + private ChangeDistanceUnit(EditWaypointActivity unitView) { this.unitView = unitView; } @@ -361,7 +361,7 @@ public class EditWaypointActivity extends AbstractActivity { public static final int UPLOAD_SUCCESS = 4; public static final int SAVE_ERROR = 5; - private class coordsListener implements View.OnClickListener { + private class CoordsListener implements View.OnClickListener { @Override public void onClick(View arg0) { @@ -426,10 +426,13 @@ public class EditWaypointActivity extends AbstractActivity { @Override public void handleMessage(Message msg) { + // TODO: The order of showToast, progress.dismiss and finish is different in these cases. Why? switch (msg.what) { case UPLOAD_SUCCESS: showToast(getString(R.string.waypoint_coordinates_has_been_modified_on_website, coordsToSave)); - //$FALL-THROUGH$ + progress.dismiss(); + finish(); + break; case SUCCESS: progress.dismiss(); finish(); @@ -452,6 +455,8 @@ public class EditWaypointActivity extends AbstractActivity { finish(); //TODO: should we close activity here ? showToast(res.getString(R.string.err_waypoint_add_failed)); break; + default: + throw new UnsupportedOperationException(); } } }; diff --git a/main/src/cgeo/geocaching/cgeogpxes.java b/main/src/cgeo/geocaching/GpxFileListActivity.java index d512618..f12a30c 100644 --- a/main/src/cgeo/geocaching/cgeogpxes.java +++ b/main/src/cgeo/geocaching/GpxFileListActivity.java @@ -2,7 +2,7 @@ package cgeo.geocaching; import cgeo.geocaching.connector.ConnectorFactory;
import cgeo.geocaching.connector.IConnector;
-import cgeo.geocaching.files.FileList;
+import cgeo.geocaching.files.AbstractFileListActivity;
import cgeo.geocaching.files.GPXImporter;
import cgeo.geocaching.ui.GPXListAdapter;
@@ -15,9 +15,9 @@ import java.io.File; import java.util.Collections;
import java.util.List;
-public class cgeogpxes extends FileList<GPXListAdapter> {
+public class GpxFileListActivity extends AbstractFileListActivity<GPXListAdapter> {
- public cgeogpxes() {
+ public GpxFileListActivity() {
super(new String[] { "gpx", "loc", "zip" });
}
@@ -37,7 +37,7 @@ public class cgeogpxes extends FileList<GPXListAdapter> { }
public static void startSubActivity(Activity fromActivity, int listId) {
- final Intent intent = new Intent(fromActivity, cgeogpxes.class);
+ final Intent intent = new Intent(fromActivity, GpxFileListActivity.class);
intent.putExtra(Intents.EXTRA_LIST_ID, listId);
fromActivity.startActivityForResult(intent, 0);
}
diff --git a/main/src/cgeo/geocaching/ImageSelectActivity.java b/main/src/cgeo/geocaching/ImageSelectActivity.java index 9b29c38..08622a9 100644 --- a/main/src/cgeo/geocaching/ImageSelectActivity.java +++ b/main/src/cgeo/geocaching/ImageSelectActivity.java @@ -210,8 +210,7 @@ public class ImageSelectActivity extends AbstractActivity { loadImagePreview(); } - private void loadImagePreview() - { + private void loadImagePreview() { if (!new File(imageUri.getPath()).exists()) { Log.i("Image does not exist"); return; diff --git a/main/src/cgeo/geocaching/cgeopoint.java b/main/src/cgeo/geocaching/NavigateAnyPointActivity.java index 9fb1905..74f656b 100644 --- a/main/src/cgeo/geocaching/cgeopoint.java +++ b/main/src/cgeo/geocaching/NavigateAnyPointActivity.java @@ -36,7 +36,7 @@ import android.widget.TextView; import java.util.List; -public class cgeopoint extends AbstractActivity { +public class NavigateAnyPointActivity extends AbstractActivity { private static final int MENU_DEFAULT_NAVIGATION = 2; private static final int MENU_NAVIGATE = 0; private static final int MENU_CACHES_AROUND = 5; @@ -102,7 +102,7 @@ public class cgeopoint extends AbstractActivity { String distanceUnit = ""; - public cgeopoint() { + public NavigateAnyPointActivity() { super("c:geo-navigate-any"); } @@ -248,8 +248,8 @@ public class cgeopoint extends AbstractActivity { latButton = (Button) findViewById(R.id.buttonLatitude); lonButton = (Button) findViewById(R.id.buttonLongitude); - latButton.setOnClickListener(new coordDialogListener()); - lonButton.setOnClickListener(new coordDialogListener()); + latButton.setOnClickListener(new CoordDialogListener()); + lonButton.setOnClickListener(new CoordDialogListener()); final Geopoint coords = Settings.getAnyCoordinates(); if (coords != null) { @@ -258,7 +258,7 @@ public class cgeopoint extends AbstractActivity { } Button buttonCurrent = (Button) findViewById(R.id.current); - buttonCurrent.setOnClickListener(new currentListener()); + buttonCurrent.setOnClickListener(new CurrentListener()); getDestionationHistoryAdapter().notifyDataSetChanged(); disableSuggestions((EditText) findViewById(R.id.distance)); @@ -280,10 +280,10 @@ public class cgeopoint extends AbstractActivity { } } - distanceUnitSelector.setOnItemSelectedListener(new changeDistanceUnit(this)); + distanceUnitSelector.setOnItemSelectedListener(new ChangeDistanceUnit(this)); } - private class coordDialogListener implements View.OnClickListener { + private class CoordDialogListener implements View.OnClickListener { @Override public void onClick(View arg0) { @@ -291,7 +291,7 @@ public class cgeopoint extends AbstractActivity { if (latButton.getText().length() > 0 && lonButton.getText().length() > 0) { gp = new Geopoint(latButton.getText().toString() + " " + lonButton.getText().toString()); } - CoordinatesInputDialog coordsDialog = new CoordinatesInputDialog(cgeopoint.this, null, gp, app.currentGeo()); + CoordinatesInputDialog coordsDialog = new CoordinatesInputDialog(NavigateAnyPointActivity.this, null, gp, app.currentGeo()); coordsDialog.setCancelable(true); coordsDialog.setOnCoordinateUpdate(new CoordinatesInputDialog.CoordinateUpdate() { @Override @@ -305,13 +305,13 @@ public class cgeopoint extends AbstractActivity { } } - private static class changeDistanceUnit implements OnItemSelectedListener { + private static class ChangeDistanceUnit implements OnItemSelectedListener { - private changeDistanceUnit(cgeopoint unitView) { + private ChangeDistanceUnit(NavigateAnyPointActivity unitView) { this.unitView = unitView; } - private cgeopoint unitView; + private NavigateAnyPointActivity unitView; @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, @@ -470,7 +470,7 @@ public class cgeopoint extends AbstractActivity { } }; - private class currentListener implements View.OnClickListener { + private class CurrentListener implements View.OnClickListener { @Override public void onClick(View arg0) { diff --git a/main/src/cgeo/geocaching/SearchActivity.java b/main/src/cgeo/geocaching/SearchActivity.java index ddb9483..231555c 100644 --- a/main/src/cgeo/geocaching/SearchActivity.java +++ b/main/src/cgeo/geocaching/SearchActivity.java @@ -135,11 +135,11 @@ public class SearchActivity extends AbstractActivity { private void init() { Settings.getLogin(); - findViewById(R.id.buttonLatitude).setOnClickListener(new findByCoordsAction()); - findViewById(R.id.buttonLongitude).setOnClickListener(new findByCoordsAction()); + findViewById(R.id.buttonLatitude).setOnClickListener(new FindByCoordsAction()); + findViewById(R.id.buttonLongitude).setOnClickListener(new FindByCoordsAction()); final Button findByCoords = (Button) findViewById(R.id.search_coordinates); - findByCoords.setOnClickListener(new findByCoordsListener()); + findByCoords.setOnClickListener(new FindByCoordsListener()); EditUtils.setActionListener((EditText) findViewById(R.id.address), new Runnable() { @@ -150,7 +150,7 @@ public class SearchActivity extends AbstractActivity { }); final Button findByAddress = (Button) findViewById(R.id.search_address); - findByAddress.setOnClickListener(new findByAddressListener()); + findByAddress.setOnClickListener(new FindByAddressListener()); final AutoCompleteTextView geocodeEdit = (AutoCompleteTextView) findViewById(R.id.geocode); EditUtils.setActionListener(geocodeEdit, new Runnable() { @@ -163,7 +163,7 @@ public class SearchActivity extends AbstractActivity { addHistoryEntries(geocodeEdit, cgData.getRecentGeocodesForSearch()); final Button displayByGeocode = (Button) findViewById(R.id.display_geocode); - displayByGeocode.setOnClickListener(new findByGeocodeListener()); + displayByGeocode.setOnClickListener(new FindByGeocodeListener()); EditUtils.setActionListener((EditText) findViewById(R.id.keyword), new Runnable() { @@ -174,7 +174,7 @@ public class SearchActivity extends AbstractActivity { }); final Button findByKeyword = (Button) findViewById(R.id.search_keyword); - findByKeyword.setOnClickListener(new findByKeywordListener()); + findByKeyword.setOnClickListener(new FindByKeywordListener()); EditUtils.setActionListener((EditText) findViewById(R.id.username), new Runnable() { @@ -185,7 +185,7 @@ public class SearchActivity extends AbstractActivity { }); final Button findByUserName = (Button) findViewById(R.id.search_username); - findByUserName.setOnClickListener(new findByUsernameListener()); + findByUserName.setOnClickListener(new FindByUsernameListener()); EditUtils.setActionListener((EditText) findViewById(R.id.owner), new Runnable() { @@ -217,7 +217,7 @@ public class SearchActivity extends AbstractActivity { disableSuggestions(trackable); final Button displayTrackable = (Button) findViewById(R.id.display_trackable); - displayTrackable.setOnClickListener(new findTrackableListener()); + displayTrackable.setOnClickListener(new FindTrackableListener()); } private void addHistoryEntries(final AutoCompleteTextView textView, final String[] entries) { @@ -252,7 +252,7 @@ public class SearchActivity extends AbstractActivity { } }; - private class findByCoordsAction implements OnClickListener { + private class FindByCoordsAction implements OnClickListener { @Override public void onClick(View arg0) { @@ -269,7 +269,7 @@ public class SearchActivity extends AbstractActivity { } } - private class findByCoordsListener implements View.OnClickListener { + private class FindByCoordsListener implements View.OnClickListener { @Override public void onClick(View arg0) { @@ -298,7 +298,7 @@ public class SearchActivity extends AbstractActivity { } } - private class findByKeywordListener implements View.OnClickListener { + private class FindByKeywordListener implements View.OnClickListener { @Override public void onClick(View arg0) { @@ -318,7 +318,7 @@ public class SearchActivity extends AbstractActivity { cgeocaches.startActivityKeyword(this, keyText); } - private class findByAddressListener implements View.OnClickListener { + private class FindByAddressListener implements View.OnClickListener { @Override public void onClick(View arg0) { findByAddressFn(); @@ -338,7 +338,7 @@ public class SearchActivity extends AbstractActivity { startActivity(addressesIntent); } - private class findByUsernameListener implements View.OnClickListener { + private class FindByUsernameListener implements View.OnClickListener { @Override public void onClick(View arg0) { @@ -372,7 +372,7 @@ public class SearchActivity extends AbstractActivity { cgeocaches.startActivityOwner(this, usernameText); } - private class findByGeocodeListener implements View.OnClickListener { + private class FindByGeocodeListener implements View.OnClickListener { @Override public void onClick(View arg0) { @@ -391,7 +391,7 @@ public class SearchActivity extends AbstractActivity { CacheDetailActivity.startActivity(this, geocodeText); } - private class findTrackableListener implements View.OnClickListener { + private class FindTrackableListener implements View.OnClickListener { @Override public void onClick(View arg0) { diff --git a/main/src/cgeo/geocaching/cgSelectMapfile.java b/main/src/cgeo/geocaching/SelectMapfileActivity.java index ded81a7..9557f3e 100644 --- a/main/src/cgeo/geocaching/cgSelectMapfile.java +++ b/main/src/cgeo/geocaching/SelectMapfileActivity.java @@ -1,6 +1,6 @@ package cgeo.geocaching; -import cgeo.geocaching.files.FileList; +import cgeo.geocaching.files.AbstractFileListActivity; import cgeo.geocaching.files.IFileSelectionView; import cgeo.geocaching.files.LocalStorage; import cgeo.geocaching.ui.FileSelectionListAdapter; @@ -13,9 +13,9 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -public class cgSelectMapfile extends FileList<FileSelectionListAdapter> implements IFileSelectionView { +public class SelectMapfileActivity extends AbstractFileListActivity<FileSelectionListAdapter> implements IFileSelectionView { - public cgSelectMapfile() { + public SelectMapfileActivity() { super("map"); } diff --git a/main/src/cgeo/geocaching/SettingsActivity.java b/main/src/cgeo/geocaching/SettingsActivity.java index 3463204..0678617 100644 --- a/main/src/cgeo/geocaching/SettingsActivity.java +++ b/main/src/cgeo/geocaching/SettingsActivity.java @@ -230,7 +230,7 @@ public class SettingsActivity extends AbstractActivity { } Button logMeIn = (Button) findViewById(R.id.log_me_in); - logMeIn.setOnClickListener(new logIn()); + logMeIn.setOnClickListener(new LoginListener()); TextView legalNote = (TextView) findViewById(R.id.legal_note); legalNote.setClickable(true); @@ -570,7 +570,7 @@ public class SettingsActivity extends AbstractActivity { } Button webAuth = (Button) findViewById(R.id.sendToCgeo_register); - webAuth.setOnClickListener(new webAuth()); + webAuth.setOnClickListener(new WebAuthListener()); // Map source settings updateMapSourceMenu(); @@ -580,7 +580,7 @@ public class SettingsActivity extends AbstractActivity { @Override public void onClick(View v) { - Intent selectIntent = new Intent(SettingsActivity.this, cgSelectMapfile.class); + Intent selectIntent = new Intent(SettingsActivity.this, SelectMapfileActivity.class); startActivityForResult(selectIntent, SELECT_MAPFILE_REQUEST); } }); @@ -758,7 +758,7 @@ public class SettingsActivity extends AbstractActivity { mapSourceSelector.setAdapter(adapter); final int index = MapProviderFactory.getMapSources().indexOf(Settings.getMapSource()); mapSourceSelector.setSelection(index); - mapSourceSelector.setOnItemSelectedListener(new cgeoChangeMapSource()); + mapSourceSelector.setOnItemSelectedListener(new ChangeMapSourceListener()); initMapDirectoryEdittext(false); } @@ -882,7 +882,7 @@ public class SettingsActivity extends AbstractActivity { } } - private static class cgeoChangeMapSource implements OnItemSelectedListener { + private static class ChangeMapSourceListener implements OnItemSelectedListener { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int position, @@ -896,7 +896,7 @@ public class SettingsActivity extends AbstractActivity { } } - private class logIn implements View.OnClickListener { + private class LoginListener implements View.OnClickListener { @Override public void onClick(View arg0) { @@ -930,7 +930,7 @@ public class SettingsActivity extends AbstractActivity { } } - private class webAuth implements View.OnClickListener { + private class WebAuthListener implements View.OnClickListener { @Override public void onClick(View arg0) { diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java index 0091d7c..5680ff3 100644 --- a/main/src/cgeo/geocaching/cgeo.java +++ b/main/src/cgeo/geocaching/cgeo.java @@ -355,7 +355,7 @@ public class cgeo extends AbstractActivity { Settings.getLogin(); if (app.firstRun) { - (new firstLogin()).start(); + (new FirstLoginThread()).start(); } final View findOnMap = findViewById(R.id.map); @@ -431,7 +431,7 @@ public class cgeo extends AbstractActivity { setFilterTitle(); checkRestore(); - (new cleanDatabase()).start(); + (new CleanDatabaseThread()).start(); } protected void selectGlobalTypeFilter() { @@ -624,7 +624,7 @@ public class cgeo extends AbstractActivity { */ public void cgeoPoint(View v) { findViewById(R.id.any_button).setPressed(true); - startActivity(new Intent(this, cgeopoint.class)); + startActivity(new Intent(this, NavigateAnyPointActivity.class)); } /** @@ -694,7 +694,7 @@ public class cgeo extends AbstractActivity { } } - private class cleanDatabase extends Thread { + private class CleanDatabaseThread extends Thread { @Override public void run() { @@ -722,7 +722,7 @@ public class cgeo extends AbstractActivity { } } - private class firstLogin extends Thread { + private class FirstLoginThread extends Thread { @Override public void run() { diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index 7fbb112..171149d 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -1169,7 +1169,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity } private void importGpx() { - cgeogpxes.startSubActivity(this, listId); + GpxFileListActivity.startSubActivity(this, listId); } @Override @@ -1549,8 +1549,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity int times = 0; int ret = MSG_DONE; - while (!needToStop && times < 3 * 60 / 5) // maximum: 3 minutes, every 5 seconds - { + while (!needToStop && times < 3 * 60 / 5) { // maximum: 3 minutes, every 5 seconds //download new code String deviceCode = Settings.getWebDeviceCode(); if (deviceCode == null) { @@ -1590,8 +1589,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity try { yield(); - if (delay == 0) - { + if (delay == 0) { sleep(5000); //No caches 5s times++; } else { diff --git a/main/src/cgeo/geocaching/cgeonavigate.java b/main/src/cgeo/geocaching/cgeonavigate.java index 3c6bf73..17c2e20 100644 --- a/main/src/cgeo/geocaching/cgeonavigate.java +++ b/main/src/cgeo/geocaching/cgeonavigate.java @@ -74,7 +74,7 @@ public class cgeonavigate extends AbstractActivity { } } } else { - Intent pointIntent = new Intent(this, cgeopoint.class); + Intent pointIntent = new Intent(this, NavigateAnyPointActivity.class); startActivity(pointIntent); finish(); @@ -156,7 +156,7 @@ public class cgeonavigate extends AbstractActivity { geoDirHandler.startDir(); } } else if (id == 2) { - Intent pointIntent = new Intent(this, cgeopoint.class); + Intent pointIntent = new Intent(this, NavigateAnyPointActivity.class); startActivity(pointIntent); finish(); diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index 494e040..9707e06 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -1061,8 +1061,7 @@ public abstract class GCParser { * the URI for the image to be uploaded * @return status code to indicate success or failure */ - public static StatusCode uploadLogImage(final String logId, final String caption, final String description, final Uri imageUri) - { + public static StatusCode uploadLogImage(final String logId, final String caption, final String description, final Uri imageUri) { final String uri = new Uri.Builder().scheme("http").authority("www.geocaching.com").path("/seek/upload.aspx").encodedQuery("LID=" + logId).build().toString(); String page = Network.getResponseData(Network.getRequest(uri)); diff --git a/main/src/cgeo/geocaching/connector/gc/IconDecoder.java b/main/src/cgeo/geocaching/connector/gc/IconDecoder.java index 98bd28a..d3a2959 100644 --- a/main/src/cgeo/geocaching/connector/gc/IconDecoder.java +++ b/main/src/cgeo/geocaching/connector/gc/IconDecoder.java @@ -1,7 +1,7 @@ package cgeo.geocaching.connector.gc; -import cgeo.geocaching.Settings; import cgeo.geocaching.Geocache; +import cgeo.geocaching.Settings; import cgeo.geocaching.enumerations.CacheType; import android.graphics.Bitmap; @@ -77,8 +77,7 @@ public abstract class IconDecoder { int type = -1; int count = 0; - for (int x = 0; x < pngType.length; x++) - { + for (int x = 0; x < pngType.length; x++) { if (pngType[x] > count) { count = pngType[x]; type = x; diff --git a/main/src/cgeo/geocaching/connector/gc/Login.java b/main/src/cgeo/geocaching/connector/gc/Login.java index 85b5272..f3ef290 100644 --- a/main/src/cgeo/geocaching/connector/gc/Login.java +++ b/main/src/cgeo/geocaching/connector/gc/Login.java @@ -208,7 +208,13 @@ public abstract class Login { setActualLoginStatus(BaseUtils.matches(page, GCConstants.PATTERN_LOGIN_NAME)); if (isActualLoginStatus()) { setActualUserName(BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")); - setActualCachesFound(Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll("[,.]", ""))); + int cachesCount = 0; + try { + cachesCount = Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "0").replaceAll("[,.]", "")); + } catch (NumberFormatException e) { + Log.e("getLoginStatus: bad cache count", e); + } + setActualCachesFound(cachesCount); Settings.setMemberStatus(BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, null)); if ( page.contains(GCConstants.MEMBER_STATUS_RENEW) ) { Settings.setMemberStatus(GCConstants.MEMBER_STATUS_PM); diff --git a/main/src/cgeo/geocaching/connector/gc/SearchHandler.java b/main/src/cgeo/geocaching/connector/gc/SearchHandler.java index 201280a..2351554 100644 --- a/main/src/cgeo/geocaching/connector/gc/SearchHandler.java +++ b/main/src/cgeo/geocaching/connector/gc/SearchHandler.java @@ -57,7 +57,7 @@ public class SearchHandler extends Handler { imageView = (ImageView) view.findViewById(R.id.image); - (new getCaptcha(new URL("http://www.google.com/recaptcha/api/image?c=" + recaptchaThread.getChallenge()))).start(); + (new GetCaptchaThread(new URL("http://www.google.com/recaptcha/api/image?c=" + recaptchaThread.getChallenge()))).start(); dlg.setTitle(res.getString(R.string.caches_recaptcha_title)); dlg.setView(view); @@ -79,10 +79,10 @@ public class SearchHandler extends Handler { } } - private class getCaptcha extends Thread { + private class GetCaptchaThread extends Thread { private URL uri = null; - public getCaptcha(URL uriIn) { + public GetCaptchaThread(URL uriIn) { uri = uriIn; } diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java index 6231c68..9a76a96 100644 --- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java +++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java @@ -153,6 +153,8 @@ public class OC11XMLParser { return CacheType.VIRTUAL; case 10: // Driv./Drive-In return CacheType.TRADITIONAL; + default: + return CacheType.UNKNOWN; } } catch (NumberFormatException e) { Log.e("OC11XMLParser.getCacheType", e); @@ -214,7 +216,7 @@ public class OC11XMLParser { desc.hint = StringUtils.EMPTY; } - protected static int attributeId; + private static int attributeId; public static Collection<Geocache> parseCaches(final InputStream stream) throws IOException { // parse and return caches without filtering diff --git a/main/src/cgeo/geocaching/files/FileList.java b/main/src/cgeo/geocaching/files/AbstractFileListActivity.java index 31daeb4..5ff0d91 100644 --- a/main/src/cgeo/geocaching/files/FileList.java +++ b/main/src/cgeo/geocaching/files/AbstractFileListActivity.java @@ -28,7 +28,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; -public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractListActivity { +public abstract class AbstractFileListActivity<T extends ArrayAdapter<File>> extends AbstractListActivity { private static final int MSG_SEARCH_WHOLE_SD_CARD = 1; private final List<File> files = new ArrayList<File>(); @@ -184,7 +184,7 @@ public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractLis Log.w("No external media mounted."); } } catch (Exception e) { - Log.e("cgFileList.loadFiles.run", e); + Log.e("AbstractFileListActivity.loadFiles.run", e); } changeWaitDialogHandler.sendMessage(Message.obtain(changeWaitDialogHandler, 0, "loaded directories")); @@ -252,7 +252,7 @@ public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractLis } /** - * Check if a filename belongs to the FileList. This implementation checks for file extensions. + * Check if a filename belongs to the AbstractFileListActivity. This implementation checks for file extensions. * Subclasses may override this method to filter out specific files. * * @param filename @@ -267,11 +267,11 @@ public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractLis return false; } - protected FileList(final String extension) { + protected AbstractFileListActivity(final String extension) { setExtensions(new String[] { extension }); } - protected FileList(final String[] extensions) { + protected AbstractFileListActivity(final String[] extensions) { setExtensions(extensions); } diff --git a/main/src/cgeo/geocaching/geopoint/DistanceParser.java b/main/src/cgeo/geocaching/geopoint/DistanceParser.java index e1692f4..5a840a8 100644 --- a/main/src/cgeo/geocaching/geopoint/DistanceParser.java +++ b/main/src/cgeo/geocaching/geopoint/DistanceParser.java @@ -22,7 +22,7 @@ public final class DistanceParser { * @throws NumberFormatException * if the given number is invalid */ - public static float parseDistance(String distanceText, final boolean metricUnit) { + public static float parseDistance(String distanceText, final boolean metricUnit) throws NumberFormatException { final MatcherWrapper matcher = new MatcherWrapper(pattern, distanceText); if (!matcher.find()) { diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java index a4821b9..c03a2bc 100644 --- a/main/src/cgeo/geocaching/geopoint/Geopoint.java +++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java @@ -36,8 +36,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * @param lon * longitude */ - public Geopoint(final double lat, final double lon) - { + public Geopoint(final double lat, final double lon) { latitude = lat; longitude = lon; } @@ -152,8 +151,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * * @return latitude */ - public double getLatitude() - { + public double getLatitude() { return latitude; } @@ -162,8 +160,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * * @return latitude */ - public int getLatitudeE6() - { + public int getLatitudeE6() { return (int) Math.round(latitude * 1E6); } @@ -172,8 +169,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * * @return longitude */ - public double getLongitude() - { + public double getLongitude() { return longitude; } @@ -182,8 +178,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * * @return longitude */ - public int getLongitudeE6() - { + public int getLongitudeE6() { return (int) Math.round(longitude * 1E6); } @@ -209,8 +204,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * @throws GeopointException * if there is an error in distance calculation */ - public float distanceTo(final ICoordinates point) - { + public float distanceTo(final ICoordinates point) { return pathTo(point.getCoords())[0] / 1000; } @@ -221,8 +215,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * target * @return bearing in degree, in the [0,360[ range */ - public float bearingTo(final ICoordinates point) - { + public float bearingTo(final ICoordinates point) { // Android library returns a bearing in the [-180;180] range final float bearing = pathTo(point.getCoords())[1]; return bearing < 0 ? bearing + 360 : bearing; @@ -237,8 +230,7 @@ public final class Geopoint implements ICoordinates, Parcelable { * distance in km * @return the projected geopoint */ - public Geopoint project(final double bearing, final double distance) - { + public Geopoint project(final double bearing, final double distance) { final double rlat1 = latitude * deg2rad; final double rlon1 = longitude * deg2rad; final double rbearing = bearing * deg2rad; @@ -295,7 +287,7 @@ public final class Geopoint implements ICoordinates, Parcelable { /** * Returns formatted coordinates with default format. * Default format is decimalminutes, e.g. N 52° 36.123 E 010° 03.456 - * + * * @return formatted coordinates */ @Override @@ -306,8 +298,7 @@ public final class Geopoint implements ICoordinates, Parcelable { abstract public static class GeopointException extends NumberFormatException { private static final long serialVersionUID = 1L; - protected GeopointException(String msg) - { + protected GeopointException(String msg) { super(msg); } } diff --git a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java index 0e676ce..ba0a4d5 100644 --- a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java +++ b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java @@ -5,8 +5,7 @@ import java.util.Locale; /** * Formatting of Geopoint. */ -public class GeopointFormatter -{ +public class GeopointFormatter { /** * Predefined formats. */ @@ -54,8 +53,7 @@ public class GeopointFormatter * one of the predefined formats * @return the formatted coordinates */ - public static String format(final Format format, final Geopoint gp) - { + public static String format(final Format format, final Geopoint gp) { final double latSigned = gp.getLatitude(); final double lonSigned = gp.getLongitude(); diff --git a/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java b/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java index 196d92d..3d9f283 100644 --- a/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java +++ b/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java @@ -45,7 +45,7 @@ public class TwitterAuthorizationActivity extends AbstractActivity { requestTokenDialog.dismiss(); } - startButton.setOnClickListener(new startListener()); + startButton.setOnClickListener(new StartListener()); startButton.setEnabled(true); if (msg.what == 1) { @@ -53,7 +53,7 @@ public class TwitterAuthorizationActivity extends AbstractActivity { pinEntry.setVisibility(View.VISIBLE); pinEntryButton.setVisibility(View.VISIBLE); - pinEntryButton.setOnClickListener(new confirmPINListener()); + pinEntryButton.setOnClickListener(new ConfirmPINListener()); } else { showToast(res.getString(R.string.err_auth_initialize)); startButton.setText(res.getString(R.string.auth_start)); @@ -68,7 +68,7 @@ public class TwitterAuthorizationActivity extends AbstractActivity { changeTokensDialog.dismiss(); } - pinEntryButton.setOnClickListener(new confirmPINListener()); + pinEntryButton.setOnClickListener(new ConfirmPINListener()); pinEntryButton.setEnabled(true); if (msg.what == 1) { @@ -114,7 +114,7 @@ public class TwitterAuthorizationActivity extends AbstractActivity { OAtokenSecret = tempToken.right; startButton.setEnabled(true); - startButton.setOnClickListener(new startListener()); + startButton.setOnClickListener(new StartListener()); if (StringUtils.isBlank(OAtoken) && StringUtils.isBlank(OAtokenSecret)) { // start authorization process @@ -125,7 +125,7 @@ public class TwitterAuthorizationActivity extends AbstractActivity { pinEntry.setVisibility(View.VISIBLE); pinEntryButton.setVisibility(View.VISIBLE); - pinEntryButton.setOnClickListener(new confirmPINListener()); + pinEntryButton.setOnClickListener(new ConfirmPINListener()); } } @@ -213,7 +213,7 @@ public class TwitterAuthorizationActivity extends AbstractActivity { changeTokensHandler.sendEmptyMessage(status); } - private class startListener implements View.OnClickListener { + private class StartListener implements View.OnClickListener { @Override public void onClick(View arg0) { @@ -238,7 +238,7 @@ public class TwitterAuthorizationActivity extends AbstractActivity { } } - private class confirmPINListener implements View.OnClickListener { + private class ConfirmPINListener implements View.OnClickListener { @Override public void onClick(View arg0) { diff --git a/main/src/cgeo/geocaching/ui/FileSelectionListAdapter.java b/main/src/cgeo/geocaching/ui/FileSelectionListAdapter.java index 1b5d47f..1db3f21 100644 --- a/main/src/cgeo/geocaching/ui/FileSelectionListAdapter.java +++ b/main/src/cgeo/geocaching/ui/FileSelectionListAdapter.java @@ -61,7 +61,7 @@ public class FileSelectionListAdapter extends ArrayAdapter<File> { holder.filename.setTypeface(holder.filename.getTypeface(), Typeface.NORMAL); } - final touchListener touchLst = new touchListener(file); + final TouchListener touchLst = new TouchListener(file); v.setOnClickListener(touchLst); holder.filepath.setText(file.getParent()); @@ -70,10 +70,10 @@ public class FileSelectionListAdapter extends ArrayAdapter<File> { return v; } - private class touchListener implements View.OnClickListener { + private class TouchListener implements View.OnClickListener { private File file = null; - public touchListener(File fileIn) { + public TouchListener(File fileIn) { file = fileIn; } diff --git a/main/src/cgeo/geocaching/ui/GPXListAdapter.java b/main/src/cgeo/geocaching/ui/GPXListAdapter.java index 45e1f52..9f6c14c 100644 --- a/main/src/cgeo/geocaching/ui/GPXListAdapter.java +++ b/main/src/cgeo/geocaching/ui/GPXListAdapter.java @@ -1,7 +1,7 @@ package cgeo.geocaching.ui; import cgeo.geocaching.R; -import cgeo.geocaching.cgeogpxes; +import cgeo.geocaching.GpxFileListActivity; import cgeo.geocaching.files.GPXImporter; import cgeo.geocaching.utils.Log; @@ -18,7 +18,7 @@ import java.io.File; import java.util.List; public class GPXListAdapter extends ArrayAdapter<File> { - private cgeogpxes activity = null; + private GpxFileListActivity activity = null; private LayoutInflater inflater = null; private static class ViewHolder { @@ -26,7 +26,7 @@ public class GPXListAdapter extends ArrayAdapter<File> { TextView filename; } - public GPXListAdapter(cgeogpxes parentIn, List<File> listIn) { + public GPXListAdapter(GpxFileListActivity parentIn, List<File> listIn) { super(parentIn, 0, listIn); activity = parentIn; diff --git a/main/src/cgeo/geocaching/utils/IOUtils.java b/main/src/cgeo/geocaching/utils/IOUtils.java index 73db12f..df90da3 100644 --- a/main/src/cgeo/geocaching/utils/IOUtils.java +++ b/main/src/cgeo/geocaching/utils/IOUtils.java @@ -5,7 +5,9 @@ import java.io.IOException; final public class IOUtils { - private IOUtils() {} + private IOUtils() { + // utility class + } public static void closeQuietly(final Closeable closeable) { if (closeable != null) { diff --git a/main/src/cgeo/geocaching/utils/PeriodicHandler.java b/main/src/cgeo/geocaching/utils/PeriodicHandler.java index ac6b22a..2759580 100644 --- a/main/src/cgeo/geocaching/utils/PeriodicHandler.java +++ b/main/src/cgeo/geocaching/utils/PeriodicHandler.java @@ -48,6 +48,9 @@ abstract public class PeriodicHandler extends Handler { case ACT: sendEmptyMessageDelayed(ACT, period); act(); + break; + default: + throw new UnsupportedOperationException(); } } diff --git a/tests/src/cgeo/geocaching/CacheTest.java b/tests/src/cgeo/geocaching/CacheTest.java index c1279af..20c7d9e 100644 --- a/tests/src/cgeo/geocaching/CacheTest.java +++ b/tests/src/cgeo/geocaching/CacheTest.java @@ -43,7 +43,7 @@ public class CacheTest extends AndroidTestCase { } public static void testGeocodeUppercase() { - Geocache cache = new Geocache(); + final Geocache cache = new Geocache(); cache.setGeocode("gc1234"); assertEquals("GC1234", cache.getGeocode()); } diff --git a/tests/src/cgeo/geocaching/cgeogpxesTest.java b/tests/src/cgeo/geocaching/GpxFileListActivityTest.java index 8f9de4a..a7605d6 100644 --- a/tests/src/cgeo/geocaching/cgeogpxesTest.java +++ b/tests/src/cgeo/geocaching/GpxFileListActivityTest.java @@ -4,11 +4,11 @@ import android.annotation.TargetApi; import android.test.ActivityInstrumentationTestCase2; @TargetApi(8) -public class cgeogpxesTest extends ActivityInstrumentationTestCase2<cgeogpxes> { - private final cgeogpxes importGpxActivity = new cgeogpxes(); +public class GpxFileListActivityTest extends ActivityInstrumentationTestCase2<GpxFileListActivity> { + private final GpxFileListActivity importGpxActivity = new GpxFileListActivity(); - public cgeogpxesTest() { - super(cgeogpxes.class); + public GpxFileListActivityTest() { + super(GpxFileListActivity.class); } public void testFileNameMatches() { diff --git a/tests/src/cgeo/geocaching/SettingsTest.java b/tests/src/cgeo/geocaching/SettingsTest.java index cedf777..d6b4985 100644 --- a/tests/src/cgeo/geocaching/SettingsTest.java +++ b/tests/src/cgeo/geocaching/SettingsTest.java @@ -13,11 +13,6 @@ public class SettingsTest extends ActivityInstrumentationTestCase2<cgeo> { super(cgeo.class); } - @Override - protected void setUp() throws Exception { - super.setUp(); - } - /** * access settings. * this should work fine without an exception (once there was an exception because of the empty map file string) diff --git a/tests/src/cgeo/geocaching/StoredListTest.java b/tests/src/cgeo/geocaching/StoredListTest.java index 6d8fd64..dd8b6c7 100644 --- a/tests/src/cgeo/geocaching/StoredListTest.java +++ b/tests/src/cgeo/geocaching/StoredListTest.java @@ -5,13 +5,13 @@ import junit.framework.TestCase; public class StoredListTest extends TestCase { public static void testStandardListExists() { - StoredList list = cgData.getList(StoredList.STANDARD_LIST_ID); + final StoredList list = cgData.getList(StoredList.STANDARD_LIST_ID); assertNotNull(list); } public static void testEquals() { - StoredList list1 = cgData.getList(StoredList.STANDARD_LIST_ID); - StoredList list2 = cgData.getList(StoredList.STANDARD_LIST_ID); + final StoredList list1 = cgData.getList(StoredList.STANDARD_LIST_ID); + final StoredList list2 = cgData.getList(StoredList.STANDARD_LIST_ID); assertEquals(list1, list2); } diff --git a/tests/src/cgeo/geocaching/TrackableTest.java b/tests/src/cgeo/geocaching/TrackableTest.java index c18d1ea..2852a4d 100644 --- a/tests/src/cgeo/geocaching/TrackableTest.java +++ b/tests/src/cgeo/geocaching/TrackableTest.java @@ -5,13 +5,13 @@ import android.test.AndroidTestCase; public class TrackableTest extends AndroidTestCase { public static void testGetGeocode() { - Trackable trackable = new Trackable(); + final Trackable trackable = new Trackable(); trackable.setGeocode("tb1234"); assertEquals("TB1234", trackable.getGeocode()); } public static void testSetLogsNull() { - Trackable trackable = new Trackable(); + final Trackable trackable = new Trackable(); trackable.setLogs(null); assertNotNull("Trackable logs must not be null!", trackable.getLogs()); } diff --git a/tests/src/cgeo/geocaching/WaypointTest.java b/tests/src/cgeo/geocaching/WaypointTest.java index 273a3bf..974fca3 100644 --- a/tests/src/cgeo/geocaching/WaypointTest.java +++ b/tests/src/cgeo/geocaching/WaypointTest.java @@ -34,7 +34,7 @@ public class WaypointTest extends AndroidTestCase { } public static void testGeocode() { - Waypoint waypoint = new Waypoint("Test waypoint", WaypointType.PARKING, false); + final Waypoint waypoint = new Waypoint("Test waypoint", WaypointType.PARKING, false); waypoint.setGeocode("p1"); assertEquals("P1", waypoint.getGeocode()); } diff --git a/tests/src/cgeo/geocaching/cgDataTest.java b/tests/src/cgeo/geocaching/cgDataTest.java index 2d3775d..a6fb846 100644 --- a/tests/src/cgeo/geocaching/cgDataTest.java +++ b/tests/src/cgeo/geocaching/cgDataTest.java @@ -51,7 +51,7 @@ public class cgDataTest extends CGeoTestCase { assertEquals(1, cgData.renameList(listId1, "cgData Test (renamed)")); // get list - StoredList list1 = cgData.getList(listId1); + final StoredList list1 = cgData.getList(listId1); assertEquals("cgData Test (renamed)", list1.title); // move to list (cache1=listId2, cache2=listId2) @@ -74,7 +74,7 @@ public class cgDataTest extends CGeoTestCase { } finally { // remove caches - Set<String> geocodes = new HashSet<String>(); + final Set<String> geocodes = new HashSet<String>(); geocodes.add(cache1.getGeocode()); geocodes.add(cache2.getGeocode()); cgData.removeCaches(geocodes, LoadFlags.REMOVE_ALL); @@ -126,7 +126,7 @@ public class cgDataTest extends CGeoTestCase { // Loading logs for an empty geocode should return an empty list, not null! public static void testLoadLogsFromEmptyGeocode() { - List<LogEntry> logs = cgData.loadLogs(""); + final List<LogEntry> logs = cgData.loadLogs(""); assertNotNull("Logs must not be null", logs); assertEquals("Logs from empty geocode must be empty", 0, logs.size()); diff --git a/tests/src/cgeo/geocaching/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/cgeoApplicationTest.java index 8556abf..c1b01e7 100644 --- a/tests/src/cgeo/geocaching/cgeoApplicationTest.java +++ b/tests/src/cgeo/geocaching/cgeoApplicationTest.java @@ -56,7 +56,7 @@ public class cgeoApplicationTest extends CGeoTestCase { */ @MediumTest public static void testSearchTrackableNotExisting() { - Trackable tb = GCParser.searchTrackable("123456", null, null); + final Trackable tb = GCParser.searchTrackable("123456", null, null); assertNull(tb); } @@ -130,8 +130,8 @@ public class cgeoApplicationTest extends CGeoTestCase { */ @MediumTest public static void testSearchByGeocodeNotLoggedIn() { - ImmutablePair<String, String> login = Settings.getLogin(); - String memberStatus = Settings.getMemberStatus(); + final ImmutablePair<String, String> login = Settings.getLogin(); + final String memberStatus = Settings.getMemberStatus(); try { // non premium cache @@ -143,7 +143,7 @@ public class cgeoApplicationTest extends CGeoTestCase { assertNotNull(search); assertEquals(1, search.getGeocodes().size()); assertTrue(search.getGeocodes().contains(cache.getGeocode())); - Geocache searchedCache = search.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); + final Geocache searchedCache = search.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); // coords must be null if the user is not logged in assertNull(searchedCache.getCoords()); @@ -169,16 +169,16 @@ public class cgeoApplicationTest extends CGeoTestCase { */ @MediumTest public static void testSearchErrorOccured() { - ImmutablePair<String, String> login = Settings.getLogin(); - String memberStatus = Settings.getMemberStatus(); + final ImmutablePair<String, String> login = Settings.getLogin(); + final String memberStatus = Settings.getMemberStatus(); try { // non premium cache - MockedCache cache = new GC1ZXX2(); + final MockedCache cache = new GC1ZXX2(); deleteCacheFromDBAndLogout(cache.getGeocode()); - SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null); + final SearchResult search = Geocache.searchByGeocode(cache.getGeocode(), null, StoredList.TEMPORARY_LIST_ID, true, null); assertNotNull(search); assertEquals(0, search.getGeocodes().size()); @@ -325,10 +325,10 @@ public class cgeoApplicationTest extends CGeoTestCase { @MediumTest public static void testSearchByViewportNotLoggedIn() { - ImmutablePair<String, String> login = Settings.getLogin(); - String memberStatus = Settings.getMemberStatus(); - Strategy strategy = Settings.getLiveMapStrategy(); - Strategy testStrategy = Strategy.FAST; // FASTEST, FAST or DETAILED for tests + final ImmutablePair<String, String> login = Settings.getLogin(); + final String memberStatus = Settings.getMemberStatus(); + final Strategy strategy = Settings.getLiveMapStrategy(); + final Strategy testStrategy = Strategy.FAST; // FASTEST, FAST or DETAILED for tests Settings.setLiveMapStrategy(testStrategy); final CacheType cacheType = Settings.getCacheType(); @@ -348,7 +348,7 @@ public class cgeoApplicationTest extends CGeoTestCase { assertNotNull(search); assertTrue(search.getGeocodes().contains(cache.getGeocode())); // coords differ - Geocache cacheFromViewport = cgData.loadCache(cache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB); + final Geocache cacheFromViewport = cgData.loadCache(cache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB); Log.d("cgeoApplicationTest.testSearchByViewportNotLoggedIn: Coords expected = " + cache.getCoords()); Log.d("cgeoApplicationTest.testSearchByViewportNotLoggedIn: Coords actual = " + cacheFromViewport.getCoords()); assertFalse(cache.getCoords().isEqualTo(cacheFromViewport.getCoords(), 1e-3)); @@ -398,10 +398,10 @@ public class cgeoApplicationTest extends CGeoTestCase { * Caches that are good test cases */ public static void testSearchByGeocodeSpecialties() { - Geocache GCV2R9 = cgeoApplicationTest.testSearchByGeocode("GCV2R9"); + final Geocache GCV2R9 = cgeoApplicationTest.testSearchByGeocode("GCV2R9"); Assert.assertEquals("California, United States", GCV2R9.getLocation()); - Geocache GC1ZXEZ = cgeoApplicationTest.testSearchByGeocode("GC1ZXEZ"); + final Geocache GC1ZXEZ = cgeoApplicationTest.testSearchByGeocode("GC1ZXEZ"); Assert.assertEquals("Ms.Marple/Mr.Stringer", GC1ZXEZ.getOwnerUserId()); } diff --git a/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java b/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java index e8abb91..ca396e1 100644 --- a/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java +++ b/tests/src/cgeo/geocaching/connector/ConnectorFactoryTest.java @@ -31,7 +31,7 @@ public class ConnectorFactoryTest extends AbstractResourceInstrumentationTestCas assertTrue(ConnectorFactory.getConnector("OP12345") instanceof OCConnector); // opencaching PL } - public static void testGeocodeInvalidFormat() throws Exception { + public static void testGeocodeInvalidFormat() { // all codes are invalid assertTrue(ConnectorFactory.getConnector("GC") instanceof UnknownConnector); assertTrue(ConnectorFactory.getConnector("OC") instanceof UnknownConnector); diff --git a/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java b/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java index fb49949..708e328 100644 --- a/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/AutoZoomTest.java @@ -10,8 +10,8 @@ import junit.framework.TestCase; public class AutoZoomTest extends TestCase { public static void testZoom1() { - Geopoint bottomLeft = new Geopoint(49.3, 8.3); - Geopoint topRight = new Geopoint(49.4, 8.4); + final Geopoint bottomLeft = new Geopoint(49.3, 8.3); + final Geopoint topRight = new Geopoint(49.4, 8.4); int zoom = Tile.calcZoomLat(bottomLeft, topRight, 2); @@ -26,8 +26,8 @@ public class AutoZoomTest extends TestCase { } public static void testZoom2() { - Geopoint bottomLeft = new Geopoint(49.3, 8.3); - Geopoint topRight = new Geopoint(49.4, 8.4); + final Geopoint bottomLeft = new Geopoint(49.3, 8.3); + final Geopoint topRight = new Geopoint(49.4, 8.4); int zoom = Tile.calcZoomLat(bottomLeft, topRight, 3); @@ -42,28 +42,28 @@ public class AutoZoomTest extends TestCase { } public static void testTiles1x2() { - Geopoint bottomLeft = new Geopoint(49.3, 8.3); - Geopoint topRight = new Geopoint(49.4, 8.4); + final Geopoint bottomLeft = new Geopoint(49.3, 8.3); + final Geopoint topRight = new Geopoint(49.4, 8.4); - Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight)); + final Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight)); assertEquals(2, tiles.size()); } public static void testTiles2x3() { - Geopoint bottomLeft = new Geopoint(49.3, 8.3); - Geopoint topRight = new Geopoint(49.4, 8.4); + final Geopoint bottomLeft = new Geopoint(49.3, 8.3); + final Geopoint topRight = new Geopoint(49.4, 8.4); - Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, Tile.ZOOMLEVEL_MIN); + final Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, Tile.ZOOMLEVEL_MIN); assertEquals(6, tiles.size()); } public static void testTilesZoom13() { - Geopoint bottomLeft = new Geopoint(49.3, 8.3); - Geopoint topRight = new Geopoint(49.4, 8.4); + final Geopoint bottomLeft = new Geopoint(49.3, 8.3); + final Geopoint topRight = new Geopoint(49.4, 8.4); - Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, 13); + final Set<Tile> tiles = Tile.getTilesForViewport(new Viewport(bottomLeft, topRight), 3, 13); assertEquals(16, tiles.size()); } diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java index ec5ebe2..a001f1d 100644 --- a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java @@ -20,11 +20,11 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase { Settings.setCacheType(CacheType.ALL); Login.login(); - String[] tokens = Login.getMapTokens(); + final String[] tokens = Login.getMapTokens(); { final Viewport viewport = new Viewport(new Geopoint("N 52° 25.369 E 9° 35.499"), new Geopoint("N 52° 25.600 E 9° 36.200")); - SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens); + final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens); assertNotNull(searchResult); assertFalse(searchResult.isEmpty()); assertTrue(searchResult.getGeocodes().contains("GC211WG")); @@ -33,7 +33,7 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase { { final Viewport viewport = new Viewport(new Geopoint("N 52° 24.000 E 9° 34.500"), new Geopoint("N 52° 26.000 E 9° 38.500")); - SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens); + final SearchResult searchResult = ConnectorFactory.searchByViewport(viewport, tokens); assertNotNull(searchResult); assertTrue(searchResult.getGeocodes().contains("GC211WG")); } diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java index 980fcaa..15ad7a3 100644 --- a/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/GCConstantsTest.java @@ -48,13 +48,13 @@ public class GCConstantsTest extends AndroidTestCase { } public static void testConstants() { - String session = "userSession = new Groundspeak.Map.UserSession('aKWZ', userOptions:'XPTf', sessionToken:'123pNKwdktYGZL0xd-I7yqA6nm_JE1BDUtM4KcOkifin2TRCMutBd_PZE14Ohpffs2ZgkTnxTSnxYpBigK4hBA2', subscriberType: 3, enablePersonalization: true });"; + final String session = "userSession = new Groundspeak.Map.UserSession('aKWZ', userOptions:'XPTf', sessionToken:'123pNKwdktYGZL0xd-I7yqA6nm_JE1BDUtM4KcOkifin2TRCMutBd_PZE14Ohpffs2ZgkTnxTSnxYpBigK4hBA2', subscriberType: 3, enablePersonalization: true });"; assertEquals("aKWZ", BaseUtils.getMatch(session, GCConstants.PATTERN_USERSESSION, "")); assertTrue(BaseUtils.getMatch(session, GCConstants.PATTERN_SESSIONTOKEN, "").startsWith("123pNK")); } public static void testTBWithSpecialChar() { - String page = "<meta name=\"og:site_name\" content=\"Geocaching.com\" property=\"og:site_name\" /><meta name=\"og:type\" content=\"article\" property=\"og:type\" /><meta name=\"fb:app_id\" content=\"100167303362705\" property=\"fb:app_id\" /><meta name=\"og:url\" content=\"http://coord.info/TB4VPZD\" property=\"og:url\" /><meta name=\"og:description\" property=\"og:description\" /><meta name=\"og:image\" content=\"http://www.geocaching.com/images/facebook/wpttypes/24.png\" property=\"og:image\" /><meta name=\"og:title\" content=\"Schlauchen&ravestorm\" property=\"og:title\" /></head>\n"; + final String page = "<meta name=\"og:site_name\" content=\"Geocaching.com\" property=\"og:site_name\" /><meta name=\"og:type\" content=\"article\" property=\"og:type\" /><meta name=\"fb:app_id\" content=\"100167303362705\" property=\"fb:app_id\" /><meta name=\"og:url\" content=\"http://coord.info/TB4VPZD\" property=\"og:url\" /><meta name=\"og:description\" property=\"og:description\" /><meta name=\"og:image\" content=\"http://www.geocaching.com/images/facebook/wpttypes/24.png\" property=\"og:image\" /><meta name=\"og:title\" content=\"Schlauchen&ravestorm\" property=\"og:title\" /></head>\n"; assertEquals("Schlauchen&ravestorm", Html.fromHtml(BaseUtils.getMatch(page, GCConstants.PATTERN_TRACKABLE_NAME, "")).toString()); } } diff --git a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java index 4063ed0..cf1df46 100644 --- a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java @@ -37,7 +37,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { private void assertUnpublished(final int cache) { final String page = getFileContent(cache); - SearchResult result = GCParser.parseCacheFromText(page, null); + final SearchResult result = GCParser.parseCacheFromText(page, null); assertNotNull(result); assertTrue(result.isEmpty()); assertEquals(StatusCode.UNPUBLISHED_CACHE, result.getError()); @@ -53,10 +53,10 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { private void assertPublishedCache(final int cachePage, final String cacheName) { final String page = getFileContent(cachePage); - SearchResult result = GCParser.parseCacheFromText(page, null); + final SearchResult result = GCParser.parseCacheFromText(page, null); assertNotNull(result); assertEquals(1, result.getCount()); - Geocache cache = result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); + final Geocache cache = result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); assertEquals(cacheName, cache.getName()); } @@ -74,9 +74,9 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { private static Geocache createCache(int index) { final MockedCache mockedCache = RegExPerformanceTest.MOCKED_CACHES.get(index); // to get the same results we have to use the date format used when the mocked data was created - String oldCustomDate = Settings.getGcCustomDate(); + final String oldCustomDate = Settings.getGcCustomDate(); - SearchResult searchResult; + final SearchResult searchResult; try { Settings.setGcCustomDate(MockedCache.getDateFormat()); searchResult = GCParser.parseCacheFromText(mockedCache.getData(), null); @@ -98,7 +98,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { */ @MediumTest public static void testParseCacheFromTextWithMockedData() { - String gcCustomDate = Settings.getGcCustomDate(); + final String gcCustomDate = Settings.getGcCustomDate(); try { for (MockedCache mockedCache : RegExPerformanceTest.MOCKED_CACHES) { // to get the same results we have to use the date format used when the mocked data was created @@ -152,20 +152,20 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { @MediumTest public static void testEditModifiedCoordinates() { - Geocache cache = new Geocache(); + final Geocache cache = new Geocache(); cache.setGeocode("GC2ZN4G"); // upload coordinates GCParser.editModifiedCoordinates(cache, new Geopoint("N51 21.544", "E07 02.566")); cache.drop(new Handler()); - String page = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0"); - Geocache cache2 = GCParser.parseCacheFromText(page, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY); + final String page = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0"); + final Geocache cache2 = GCParser.parseCacheFromText(page, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY); assertTrue(cache2.hasUserModifiedCoords()); assertEquals(new Geopoint("N51 21.544", "E07 02.566"), cache2.getCoords()); // delete coordinates GCParser.deleteModifiedCoordinates(cache2); cache2.drop(new Handler()); - String page2 = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0"); - Geocache cache3 = GCParser.parseCacheFromText(page2, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY); + final String page2 = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0"); + final Geocache cache3 = GCParser.parseCacheFromText(page2, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY); assertFalse(cache3.hasUserModifiedCoords()); } @@ -189,7 +189,7 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase { private Geocache parseCache(int resourceId) { final String page = getFileContent(resourceId); - SearchResult result = GCParser.parseCacheFromText(page, null); + final SearchResult result = GCParser.parseCacheFromText(page, null); assertNotNull(result); assertFalse(result.isEmpty()); return result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); diff --git a/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java index ea430ac..cd130db 100644 --- a/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/TrackablesTest.java @@ -14,16 +14,16 @@ import java.util.List; public class TrackablesTest extends AbstractResourceInstrumentationTestCase { public void testLogPageWithTrackables() { - List<TrackableLog> tbLogs = GCParser.parseTrackableLog(getFileContent(R.raw.log_with_2tb)); + final List<TrackableLog> tbLogs = GCParser.parseTrackableLog(getFileContent(R.raw.log_with_2tb)); assertNotNull(tbLogs); assertEquals(2, tbLogs.size()); - TrackableLog log = tbLogs.get(0); + final TrackableLog log = tbLogs.get(0); assertEquals("Steffen's Kaiserwagen", log.name); assertEquals("1QG1EE", log.trackCode); } public void testLogPageWithoutTrackables() { - List<TrackableLog> tbLogs = GCParser.parseTrackableLog(getFileContent(R.raw.log_without_tb)); + final List<TrackableLog> tbLogs = GCParser.parseTrackableLog(getFileContent(R.raw.log_without_tb)); assertNotNull(tbLogs); assertEquals(0, tbLogs.size()); } @@ -45,7 +45,7 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase { final Trackable trackable = getTBXATG(); assertEquals("TBXATG", trackable.getGeocode()); - List<LogEntry> log = trackable.getLogs(); + final List<LogEntry> log = trackable.getLogs(); assertNotNull(log); assertEquals(10, log.size()); // log entry 4 has several images; just check first two @@ -72,7 +72,7 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase { } public void testParseTrackableWithoutReleaseDate() { - Trackable trackable = parseTrackable(R.raw.tb14wfv); + final Trackable trackable = parseTrackable(R.raw.tb14wfv); assertNotNull(trackable); assertEquals("The Brickster", trackable.getName()); assertEquals("Adrian C", trackable.getOwner()); @@ -95,7 +95,7 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase { } private Trackable parseTrackable(int trackablePage) { - String pageContent = getFileContent(trackablePage); + final String pageContent = getFileContent(trackablePage); return GCParser.parseTrackable(BaseUtils.replaceWhitespace(pageContent), null); } @@ -105,7 +105,7 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase { final List<LogEntry> logs = trackable.getLogs(); assertNotNull(logs); assertFalse(logs.isEmpty()); - LogEntry marked = logs.get(4); + final LogEntry marked = logs.get(4); assertEquals(LogType.MARKED_MISSING, marked.type); } @@ -118,7 +118,7 @@ public class TrackablesTest extends AbstractResourceInstrumentationTestCase { } public void testParseTrackableNotExisting() { - Trackable trackable = GCParser.parseTrackable(getFileContent(R.raw.tb_not_existing), null); + final Trackable trackable = GCParser.parseTrackable(getFileContent(R.raw.tb_not_existing), null); assertNull(trackable); } diff --git a/tests/src/cgeo/geocaching/connector/gc/WaypointsTest.java b/tests/src/cgeo/geocaching/connector/gc/WaypointsTest.java index f4b1e0c..d186526 100644 --- a/tests/src/cgeo/geocaching/connector/gc/WaypointsTest.java +++ b/tests/src/cgeo/geocaching/connector/gc/WaypointsTest.java @@ -1,8 +1,8 @@ package cgeo.geocaching.connector.gc; import cgeo.CGeoTestCase; -import cgeo.geocaching.SearchResult; import cgeo.geocaching.Geocache; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgData; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.utils.CancellableHandler; @@ -11,7 +11,7 @@ import android.os.Message; public class WaypointsTest extends CGeoTestCase { - public static CancellableHandler handler = new CancellableHandler() { + public static final CancellableHandler handler = new CancellableHandler() { @Override protected void handleRegularMessage(final Message message) { // Dummy diff --git a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java b/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java index a5631e1..ca2e302 100644 --- a/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java +++ b/tests/src/cgeo/geocaching/connector/opencaching/OCXMLTest.java @@ -11,9 +11,9 @@ import java.util.Collection; public class OCXMLTest extends CGeoTestCase { public static void testOCGetCache() { - String geoCode = "OCDE76"; + final String geoCode = "OCDE76"; - Geocache cache = OCXMLClient.getCache(geoCode); + final Geocache cache = OCXMLClient.getCache(geoCode); assertNotNull(cache); assertEquals(geoCode, cache.getGeocode()); assertEquals("Gitarrenspielplatz", cache.getName()); @@ -24,11 +24,11 @@ public class OCXMLTest extends CGeoTestCase { public static void testOCLogAttendedAsFound() { - String oldOCName = Settings.getOCConnectorUserName(); + final String oldOCName = Settings.getOCConnectorUserName(); try { Settings.setOCConnectorUserName("ra_sch"); - String geoCode = "OCD541"; - Geocache cache = OCXMLClient.getCache(geoCode); + final String geoCode = "OCD541"; + final Geocache cache = OCXMLClient.getCache(geoCode); assertNotNull(cache); assertTrue(cache.isFound()); @@ -38,11 +38,11 @@ public class OCXMLTest extends CGeoTestCase { } public static void testOCOwner() { - String oldOCName = Settings.getOCConnectorUserName(); + final String oldOCName = Settings.getOCConnectorUserName(); try { Settings.setOCConnectorUserName("andi12.2"); - String geoCode = "OCC9BE"; - Geocache cache = OCXMLClient.getCache(geoCode); + final String geoCode = "OCC9BE"; + final Geocache cache = OCXMLClient.getCache(geoCode); assertNotNull(cache); assertTrue(cache.isOwner()); @@ -53,8 +53,8 @@ public class OCXMLTest extends CGeoTestCase { } public static void testOC0537Description() { - String geoCode = "OC0537"; - Geocache cache = OCXMLClient.getCache(geoCode); + final String geoCode = "OC0537"; + final Geocache cache = OCXMLClient.getCache(geoCode); assertNotNull(cache); assertFalse(cache.getDescription().length() < 100); @@ -62,17 +62,17 @@ public class OCXMLTest extends CGeoTestCase { public static void testNoArchivedInNearby() { - boolean oldExcludeDisabled = Settings.isExcludeDisabledCaches(); - boolean oldExcludeMine = Settings.isExcludeMyCaches(); + final boolean oldExcludeDisabled = Settings.isExcludeDisabledCaches(); + final boolean oldExcludeMine = Settings.isExcludeMyCaches(); try { Settings.setExcludeDisabledCaches(false); Settings.setExcludeMine(false); // get an archived cache - Geocache cache = OCXMLClient.getCache("OCD541"); + final Geocache cache = OCXMLClient.getCache("OCD541"); assertNotNull(cache); assertTrue(cache.isArchived()); // Get nearby for this cache - Collection<Geocache> caches = OCXMLClient.getCachesAround(cache.getCoords(), 0.5); + final Collection<Geocache> caches = OCXMLClient.getCachesAround(cache.getCoords(), 0.5); // Should not be in the result! assertFalse(caches.contains(cache)); } finally { diff --git a/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java b/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java index 130b24d..9173c6a 100644 --- a/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java +++ b/tests/src/cgeo/geocaching/connector/opencaching/OkapiClientTest.java @@ -9,7 +9,7 @@ import cgeo.geocaching.enumerations.LoadFlags; public class OkapiClientTest extends CGeoTestCase { public static void testGetOCCache() { - String geoCode = "OU0331"; + final String geoCode = "OU0331"; Geocache cache = OkapiClient.getCache(geoCode); assertNotNull(cache); assertEquals(geoCode, cache.getGeocode()); diff --git a/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java b/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java index e5573ba..8d2d114 100644 --- a/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java +++ b/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java @@ -24,7 +24,7 @@ public class CacheAttributeTest extends AndroidTestCase { } public static void testGetL10n() { - CacheAttribute attribute = CacheAttribute.HIKING; + final CacheAttribute attribute = CacheAttribute.HIKING; // This test is language dependend. It does not make sense to test it // with every attribute. We just want to know if getL10n works // correctly @@ -33,7 +33,7 @@ public class CacheAttributeTest extends AndroidTestCase { } public static void testGetBy() { - CacheAttribute attribute = CacheAttribute.HIKING; // an attribute that is present in GC and OC + final CacheAttribute attribute = CacheAttribute.HIKING; // an attribute that is present in GC and OC assertTrue("Test cannot be run with this attribute", attribute.gcid >= 0); assertTrue("Test cannot be run with this attribute", attribute.ocid >= 0); assertSame(CacheAttribute.getByRawName(attribute.rawName), attribute); @@ -42,9 +42,9 @@ public class CacheAttributeTest extends AndroidTestCase { } public static void testIsEnabled() { - CacheAttribute attribute = CacheAttribute.HIKING; - String hiking_yes = attribute.getAttributeName(true); - String hiking_no = attribute.getAttributeName(false); + final CacheAttribute attribute = CacheAttribute.HIKING; + final String hiking_yes = attribute.getAttributeName(true); + final String hiking_no = attribute.getAttributeName(false); assertTrue(CacheAttribute.isEnabled(hiking_yes)); assertFalse(CacheAttribute.isEnabled(hiking_no)); } diff --git a/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java b/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java index 57d06d4..96796f2 100644 --- a/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java +++ b/tests/src/cgeo/geocaching/enumerations/CacheTypeTest.java @@ -38,7 +38,7 @@ public class CacheTypeTest extends AndroidTestCase { } } - public static void testContainsCache() throws Exception { + public static void testContainsCache() { final Geocache traditional = new Geocache(); traditional.setType(CacheType.TRADITIONAL); diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java index 5ece2ee..86369a3 100644 --- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java +++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java @@ -30,10 +30,10 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { private boolean importWpStaticMaps; public void testGetWaypointsFileNameForGpxFile() throws IOException { - String[] gpxFiles = new String[] { "1234567.gpx", "1.gpx", "1234567.9.gpx", + final String[] gpxFiles = new String[] { "1234567.gpx", "1.gpx", "1234567.9.gpx", "1234567.GPX", "gpx.gpx.gpx", ".gpx", "1234567_query.gpx", "123-4.gpx", "123(5).gpx" }; - String[] wptsFiles = new String[] { "1234567-wpts.gpx", "1-wpts.gpx", "1234567.9-wpts.gpx", + final String[] wptsFiles = new String[] { "1234567-wpts.gpx", "1-wpts.gpx", "1234567.9-wpts.gpx", "1234567-wpts.GPX", "gpx.gpx-wpts.gpx", "-wpts.gpx", "1234567_query-wpts.gpx", "123-wpts-4.gpx", "123-wpts(5).gpx" }; for (int i = 0; i < gpxFiles.length; i++) { @@ -50,28 +50,28 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { gpx.delete(); wpts.delete(); } - File gpx1 = new File(tempDir, "abc.gpx"); + final File gpx1 = new File(tempDir, "abc.gpx"); assertNull(GPXImporter.getWaypointsFileNameForGpxFile(gpx1)); } public void testImportGpx() throws IOException { final String geocode = "GC31J2H"; removeCacheCompletely(geocode); - File gc31j2h = new File(tempDir, "gc31j2h.gpx"); + final File gc31j2h = new File(tempDir, "gc31j2h.gpx"); copyResourceToFile(R.raw.gc31j2h, gc31j2h); - GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); + final GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); runImportThread(importThread); assertEquals(4, importStepHandler.messages.size()); - Iterator<Message> iMsg = importStepHandler.messages.iterator(); + final Iterator<Message> iMsg = importStepHandler.messages.iterator(); assertEquals(GPXImporter.IMPORT_STEP_START, iMsg.next().what); assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, iMsg.next().what); assertEquals(GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, iMsg.next().what); assertEquals(GPXImporter.IMPORT_STEP_FINISHED, iMsg.next().what); - SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; + final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes())); - Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + final Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); assertCacheProperties(cache); assertTrue(cache.getWaypoints().isEmpty()); @@ -88,17 +88,17 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { } public void testImportGpxWithWaypoints() throws IOException { - File gc31j2h = new File(tempDir, "gc31j2h.gpx"); + final File gc31j2h = new File(tempDir, "gc31j2h.gpx"); copyResourceToFile(R.raw.gc31j2h, gc31j2h); copyResourceToFile(R.raw.gc31j2h_wpts, new File(tempDir, "gc31j2h-wpts.gpx")); - GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); + final GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); runImportThread(importThread); assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; + final SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; assertEquals(Collections.singletonList("GC31J2H"), new ArrayList<String>(search.getGeocodes())); - Geocache cache = cgData.loadCache("GC31J2H", LoadFlags.LOAD_CACHE_OR_DB); + final Geocache cache = cgData.loadCache("GC31J2H", LoadFlags.LOAD_CACHE_OR_DB); assertCacheProperties(cache); assertEquals(2, cache.getWaypoints().size()); } @@ -124,16 +124,16 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { } public void testImportLoc() throws IOException { - File oc5952 = new File(tempDir, "oc5952.loc"); + final File oc5952 = new File(tempDir, "oc5952.loc"); copyResourceToFile(R.raw.oc5952_loc, oc5952); - GPXImporter.ImportLocFileThread importThread = new GPXImporter.ImportLocFileThread(oc5952, listId, importStepHandler, progressHandler); + final GPXImporter.ImportLocFileThread importThread = new GPXImporter.ImportLocFileThread(oc5952, listId, importStepHandler, progressHandler); runImportThread(importThread); assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; + final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; assertEquals(Collections.singletonList("OC5952"), new ArrayList<String>(search.getGeocodes())); - Geocache cache = cgData.loadCache("OC5952", LoadFlags.LOAD_CACHE_OR_DB); + final Geocache cache = cgData.loadCache("OC5952", LoadFlags.LOAD_CACHE_OR_DB); assertCacheProperties(cache); } @@ -144,21 +144,21 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { } public void testImportGpxError() throws IOException { - File gc31j2h = new File(tempDir, "gc31j2h.gpx"); + final File gc31j2h = new File(tempDir, "gc31j2h.gpx"); copyResourceToFile(R.raw.gc31j2h_err, gc31j2h); - GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); + final GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); runImportThread(importThread); assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_FINISHED_WITH_ERROR); } public void testImportGpxCancel() throws IOException { - File gc31j2h = new File(tempDir, "gc31j2h.gpx"); + final File gc31j2h = new File(tempDir, "gc31j2h.gpx"); copyResourceToFile(R.raw.gc31j2h, gc31j2h); progressHandler.cancel(); - GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); + final GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler); runImportThread(importThread); assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_CANCELED); @@ -167,15 +167,15 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { public void testImportGpxAttachment() { final String geocode = "GC31J2H"; removeCacheCompletely(geocode); - Uri uri = Uri.parse("android.resource://cgeo.geocaching.test/raw/gc31j2h"); + final Uri uri = Uri.parse("android.resource://cgeo.geocaching.test/raw/gc31j2h"); - GPXImporter.ImportGpxAttachmentThread importThread = new GPXImporter.ImportGpxAttachmentThread(uri, getInstrumentation().getContext().getContentResolver(), listId, importStepHandler, progressHandler); + final GPXImporter.ImportGpxAttachmentThread importThread = new GPXImporter.ImportGpxAttachmentThread(uri, getInstrumentation().getContext().getContentResolver(), listId, importStepHandler, progressHandler); runImportThread(importThread); assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; + final SearchResult search = (SearchResult) importStepHandler.messages.get(3).obj; assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes())); - Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + final Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); assertCacheProperties(cache); assertTrue(cache.getWaypoints().isEmpty()); @@ -184,25 +184,25 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { public void testImportGpxZip() throws IOException { final String geocode = "GC31J2H"; removeCacheCompletely(geocode); - File pq7545915 = new File(tempDir, "7545915.zip"); + final File pq7545915 = new File(tempDir, "7545915.zip"); copyResourceToFile(R.raw.pq7545915, pq7545915); - GPXImporter.ImportGpxZipFileThread importThread = new GPXImporter.ImportGpxZipFileThread(pq7545915, listId, importStepHandler, progressHandler); + final GPXImporter.ImportGpxZipFileThread importThread = new GPXImporter.ImportGpxZipFileThread(pq7545915, listId, importStepHandler, progressHandler); runImportThread(importThread); assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; + final SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes())); - Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + final Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); assertCacheProperties(cache); assertEquals(1, cache.getWaypoints().size()); // this is the original pocket query result without test waypoint } public void testImportGpxZipErr() throws IOException { - File pqError = new File(tempDir, "pq_error.zip"); + final File pqError = new File(tempDir, "pq_error.zip"); copyResourceToFile(R.raw.pq_error, pqError); - GPXImporter.ImportGpxZipFileThread importThread = new GPXImporter.ImportGpxZipFileThread(pqError, listId, importStepHandler, progressHandler); + final GPXImporter.ImportGpxZipFileThread importThread = new GPXImporter.ImportGpxZipFileThread(pqError, listId, importStepHandler, progressHandler); runImportThread(importThread); assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_FINISHED_WITH_ERROR); @@ -211,15 +211,15 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { public void testImportGpxZipAttachment() { final String geocode = "GC31J2H"; removeCacheCompletely(geocode); - Uri uri = Uri.parse("android.resource://cgeo.geocaching.test/raw/pq7545915"); + final Uri uri = Uri.parse("android.resource://cgeo.geocaching.test/raw/pq7545915"); - GPXImporter.ImportGpxZipAttachmentThread importThread = new GPXImporter.ImportGpxZipAttachmentThread(uri, getInstrumentation().getContext().getContentResolver(), listId, importStepHandler, progressHandler); + final GPXImporter.ImportGpxZipAttachmentThread importThread = new GPXImporter.ImportGpxZipAttachmentThread(uri, getInstrumentation().getContext().getContentResolver(), listId, importStepHandler, progressHandler); runImportThread(importThread); assertImportStepMessages(GPXImporter.IMPORT_STEP_START, GPXImporter.IMPORT_STEP_READ_FILE, GPXImporter.IMPORT_STEP_READ_WPT_FILE, GPXImporter.IMPORT_STEP_STORE_STATIC_MAPS, GPXImporter.IMPORT_STEP_FINISHED); - SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; + final SearchResult search = (SearchResult) importStepHandler.messages.get(4).obj; assertEquals(Collections.singletonList(geocode), new ArrayList<String>(search.getGeocodes())); - Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); + final Geocache cache = cgData.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB); assertCacheProperties(cache); assertEquals(1, cache.getWaypoints().size()); // this is the original pocket query result without test waypoint } @@ -271,8 +271,8 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase { @Override protected void tearDown() throws Exception { - SearchResult search = cgData.getBatchOfStoredCaches(null, CacheType.ALL, listId); - List<Geocache> cachesInList = new ArrayList<Geocache>(); + final SearchResult search = cgData.getBatchOfStoredCaches(null, CacheType.ALL, listId); + final List<Geocache> cachesInList = new ArrayList<Geocache>(); cachesInList.addAll(search.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB)); cgData.markDropped(cachesInList); cgData.removeList(listId); diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java index 3579d5a..f6c0b99 100644 --- a/tests/src/cgeo/geocaching/files/GPXParserTest.java +++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java @@ -98,9 +98,9 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase { public void testGc31j2hWpts() throws IOException, ParserException { removeCacheCompletely("GC31J2H"); - List<Geocache> caches = readGPX10(R.raw.gc31j2h, R.raw.gc31j2h_wpts); + final List<Geocache> caches = readGPX10(R.raw.gc31j2h, R.raw.gc31j2h_wpts); assertEquals(1, caches.size()); - Geocache cache = caches.get(0); + final Geocache cache = caches.get(0); assertGc31j2h(cache); assertGc31j2hWaypoints(cache); } @@ -224,7 +224,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase { public static void testParseDateWithHugeFraction() throws ParseException { // see issue 821 - String dateString = "2011-11-07T00:00:00.0000000-07:00"; + final String dateString = "2011-11-07T00:00:00.0000000-07:00"; GPXParser.parseDate(dateString); } @@ -242,7 +242,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase { public void testGeoToad() throws Exception { final List<Geocache> caches = readGPX10(R.raw.geotoad); assertEquals(2, caches.size()); - List<String> codes = new ArrayList<String>(); + final List<String> codes = new ArrayList<String>(); for (Geocache cache : caches) { codes.add(cache.getGeocode()); } @@ -294,7 +294,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase { @Override protected void tearDown() throws Exception { - SearchResult search = cgData.getBatchOfStoredCaches(null, CacheType.ALL, listId); + final SearchResult search = cgData.getBatchOfStoredCaches(null, CacheType.ALL, listId); assertNotNull(search); cgData.removeCaches(search.getGeocodes(), LoadFlags.REMOVE_ALL); cgData.removeList(listId); diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java index 76c0f09..c0cea01 100644 --- a/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java +++ b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java @@ -8,7 +8,7 @@ public class GeoPointFormatterTest extends AndroidTestCase { public static void testFormat() { // taken from GC30R6G - Geopoint point = new Geopoint("N 51° 21.104 E 010° 15.369"); + final Geopoint point = new Geopoint("N 51° 21.104 E 010° 15.369"); final String format = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECDEGREE_COMMA, point); assertEquals(format, "51.351733,10.256150", format); final String formatMinute = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECMINUTE_RAW, point); diff --git a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java index 1401cb6..8aaeef8 100644 --- a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java +++ b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java @@ -72,7 +72,7 @@ public class GeopointTest extends AndroidTestCase { checkDDD(gp1, 'N', 51, 30000, 'E', 13, 80000); - Geopoint gp1a = new Geopoint(String.valueOf(gp1.getLatDir()), String.valueOf(gp1.getLatDeg()), String.valueOf(gp1.getLatDegFrac()), + final Geopoint gp1a = new Geopoint(String.valueOf(gp1.getLatDir()), String.valueOf(gp1.getLatDeg()), String.valueOf(gp1.getLatDegFrac()), String.valueOf(gp1.getLonDir()), String.valueOf(gp1.getLonDeg()), String.valueOf(gp1.getLonDegFrac())); Assert.assertTrue(gp1a.equals(gp1)); @@ -82,7 +82,7 @@ public class GeopointTest extends AndroidTestCase { checkDDD(gp2, 'N', 51, 34567, 'E', 13, 87654); - Geopoint gp2a = new Geopoint(String.valueOf(gp2.getLatDir()), String.valueOf(gp2.getLatDeg()), String.valueOf(gp2.getLatDegFrac()), + final Geopoint gp2a = new Geopoint(String.valueOf(gp2.getLatDir()), String.valueOf(gp2.getLatDeg()), String.valueOf(gp2.getLatDegFrac()), String.valueOf(gp2.getLonDir()), String.valueOf(gp2.getLonDeg()), String.valueOf(gp2.getLonDegFrac())); Assert.assertTrue(gp2a.equals(gp2)); @@ -92,7 +92,7 @@ public class GeopointTest extends AndroidTestCase { checkDDD(gp3, 'N', 51, 30000, 'E', 13, 80000); - Geopoint gp3a = new Geopoint(String.valueOf(gp3.getLatDir()), String.valueOf(gp3.getLatDeg()), String.valueOf(gp3.getLatDegFrac()), + final Geopoint gp3a = new Geopoint(String.valueOf(gp3.getLatDir()), String.valueOf(gp3.getLatDeg()), String.valueOf(gp3.getLatDegFrac()), String.valueOf(gp3.getLonDir()), String.valueOf(gp3.getLonDeg()), String.valueOf(gp3.getLonDegFrac())); checkTolerance(gp3, gp3a, 5e-5); @@ -102,7 +102,7 @@ public class GeopointTest extends AndroidTestCase { checkDDD(gp4, 'N', 51, 12, 'E', 13, 89); - Geopoint gp4a = new Geopoint(String.valueOf(gp4.getLatDir()), String.valueOf(gp4.getLatDeg()), String.valueOf(gp4.getLatDegFrac()), + final Geopoint gp4a = new Geopoint(String.valueOf(gp4.getLatDir()), String.valueOf(gp4.getLatDeg()), String.valueOf(gp4.getLatDegFrac()), String.valueOf(gp4.getLonDir()), String.valueOf(gp4.getLonDeg()), String.valueOf(gp4.getLonDegFrac())); checkTolerance(gp4, gp4a, 5e-5); @@ -128,7 +128,7 @@ public class GeopointTest extends AndroidTestCase { checkDMM(gp1, 'N', 51, 18, 0, 'E', 13, 48, 0); - Geopoint gp1a = new Geopoint(String.valueOf(gp1.getLatDir()), String.valueOf(gp1.getLatDeg()), String.valueOf(gp1.getLatMin()), String.valueOf(gp1.getLatMinFrac()), + final Geopoint gp1a = new Geopoint(String.valueOf(gp1.getLatDir()), String.valueOf(gp1.getLatDeg()), String.valueOf(gp1.getLatMin()), String.valueOf(gp1.getLatMinFrac()), String.valueOf(gp1.getLonDir()), String.valueOf(gp1.getLonDeg()), String.valueOf(gp1.getLonMin()), String.valueOf(gp1.getLonMinFrac())); Assert.assertTrue(gp1a.equals(gp1)); @@ -138,7 +138,7 @@ public class GeopointTest extends AndroidTestCase { checkDMM(gp2, 'N', 51, 20, 740, 'E', 13, 52, 592); - Geopoint gp2a = new Geopoint(String.valueOf(gp2.getLatDir()), String.valueOf(gp2.getLatDeg()), String.valueOf(gp2.getLatMin()), String.valueOf(gp2.getLatMinFrac()), + final Geopoint gp2a = new Geopoint(String.valueOf(gp2.getLatDir()), String.valueOf(gp2.getLatDeg()), String.valueOf(gp2.getLatMin()), String.valueOf(gp2.getLatMinFrac()), String.valueOf(gp2.getLonDir()), String.valueOf(gp2.getLonDeg()), String.valueOf(gp2.getLonMin()), String.valueOf(gp2.getLonMinFrac())); checkTolerance(gp2, gp2a, 5e-5); @@ -148,7 +148,7 @@ public class GeopointTest extends AndroidTestCase { checkDMM(gp3, 'N', 51, 18, 0, 'E', 13, 48, 0); - Geopoint gp3a = new Geopoint(String.valueOf(gp3.getLatDir()), String.valueOf(gp3.getLatDeg()), String.valueOf(gp3.getLatMin()), String.valueOf(gp3.getLatMinFrac()), + final Geopoint gp3a = new Geopoint(String.valueOf(gp3.getLatDir()), String.valueOf(gp3.getLatDeg()), String.valueOf(gp3.getLatMin()), String.valueOf(gp3.getLatMinFrac()), String.valueOf(gp3.getLonDir()), String.valueOf(gp3.getLonDeg()), String.valueOf(gp3.getLonMin()), String.valueOf(gp3.getLonMinFrac())); checkTolerance(gp3, gp3a, 5e-5); @@ -158,7 +158,7 @@ public class GeopointTest extends AndroidTestCase { checkDMM(gp4, 'N', 51, 0, 7, 'E', 13, 0, 53); - Geopoint gp4a = new Geopoint(String.valueOf(gp4.getLatDir()), String.valueOf(gp4.getLatDeg()), String.valueOf(gp4.getLatMin()), String.valueOf(gp4.getLatMinFrac()), + final Geopoint gp4a = new Geopoint(String.valueOf(gp4.getLatDir()), String.valueOf(gp4.getLatDeg()), String.valueOf(gp4.getLatMin()), String.valueOf(gp4.getLatMinFrac()), String.valueOf(gp4.getLonDir()), String.valueOf(gp4.getLonDeg()), String.valueOf(gp4.getLonMin()), String.valueOf(gp4.getLonMinFrac())); checkTolerance(gp4, gp4a, 5e-5); @@ -181,7 +181,7 @@ public class GeopointTest extends AndroidTestCase { checkDMS(gp1, 'N', 51, 18, 0, 0, 'E', 13, 48, 0, 0); - Geopoint gp1a = new Geopoint(String.valueOf(gp1.getLatDir()), String.valueOf(gp1.getLatDeg()), String.valueOf(gp1.getLatMin()), String.valueOf(gp1.getLatSec()), String.valueOf(gp1.getLatSecFrac()), + final Geopoint gp1a = new Geopoint(String.valueOf(gp1.getLatDir()), String.valueOf(gp1.getLatDeg()), String.valueOf(gp1.getLatMin()), String.valueOf(gp1.getLatSec()), String.valueOf(gp1.getLatSecFrac()), String.valueOf(gp1.getLonDir()), String.valueOf(gp1.getLonDeg()), String.valueOf(gp1.getLonMin()), String.valueOf(gp1.getLonSec()), String.valueOf(gp1.getLonSecFrac())); Assert.assertTrue(gp1a.equals(gp1)); @@ -191,7 +191,7 @@ public class GeopointTest extends AndroidTestCase { checkDMS(gp2, 'N', 51, 20, 44, 412, 'E', 13, 52, 35, 544); - Geopoint gp2a = new Geopoint(String.valueOf(gp2.getLatDir()), String.valueOf(gp2.getLatDeg()), String.valueOf(gp2.getLatMin()), String.valueOf(gp2.getLatSec()), String.valueOf(gp2.getLatSecFrac()), + final Geopoint gp2a = new Geopoint(String.valueOf(gp2.getLatDir()), String.valueOf(gp2.getLatDeg()), String.valueOf(gp2.getLatMin()), String.valueOf(gp2.getLatSec()), String.valueOf(gp2.getLatSecFrac()), String.valueOf(gp2.getLonDir()), String.valueOf(gp2.getLonDeg()), String.valueOf(gp2.getLonMin()), String.valueOf(gp2.getLonSec()), String.valueOf(gp2.getLonSecFrac())); checkTolerance(gp2, gp2a, 5e-6); @@ -201,7 +201,7 @@ public class GeopointTest extends AndroidTestCase { checkDMS(gp3, 'N', 51, 17, 59, 994, 'E', 13, 48, 0, 0); - Geopoint gp3a = new Geopoint(String.valueOf(gp3.getLatDir()), String.valueOf(gp3.getLatDeg()), String.valueOf(gp3.getLatMin()), String.valueOf(gp3.getLatSec()), String.valueOf(gp3.getLatSecFrac()), + final Geopoint gp3a = new Geopoint(String.valueOf(gp3.getLatDir()), String.valueOf(gp3.getLatDeg()), String.valueOf(gp3.getLatMin()), String.valueOf(gp3.getLatSec()), String.valueOf(gp3.getLatSecFrac()), String.valueOf(gp3.getLonDir()), String.valueOf(gp3.getLonDeg()), String.valueOf(gp3.getLonMin()), String.valueOf(gp3.getLonSec()), String.valueOf(gp3.getLonSecFrac())); checkTolerance(gp3, gp3a, 5e-6); @@ -211,7 +211,7 @@ public class GeopointTest extends AndroidTestCase { checkDMS(gp4, 'N', 51, 0, 0, 432, 'E', 13, 0, 3, 204); - Geopoint gp4a = new Geopoint(String.valueOf(gp4.getLatDir()), String.valueOf(gp4.getLatDeg()), String.valueOf(gp4.getLatMin()), String.valueOf(gp4.getLatSec()), String.valueOf(gp4.getLatSecFrac()), + final Geopoint gp4a = new Geopoint(String.valueOf(gp4.getLatDir()), String.valueOf(gp4.getLatDeg()), String.valueOf(gp4.getLatMin()), String.valueOf(gp4.getLatSec()), String.valueOf(gp4.getLatSecFrac()), String.valueOf(gp4.getLonDir()), String.valueOf(gp4.getLonDeg()), String.valueOf(gp4.getLonMin()), String.valueOf(gp4.getLonSec()), String.valueOf(gp4.getLonSecFrac())); checkTolerance(gp4, gp4a, 5e-6); @@ -254,7 +254,7 @@ public class GeopointTest extends AndroidTestCase { }); } - public static void testParseParam2() throws Exception { + public static void testParseParam2() { assertParseException(new Runnable() { @SuppressWarnings("unused") @@ -265,7 +265,7 @@ public class GeopointTest extends AndroidTestCase { }); } - public static void testParseParam6() throws Exception { + public static void testParseParam6() { assertParseException(new Runnable() { @SuppressWarnings("unused") @@ -276,7 +276,7 @@ public class GeopointTest extends AndroidTestCase { }); } - public static void testParseParam8() throws Exception { + public static void testParseParam8() { assertParseException(new Runnable() { @SuppressWarnings("unused") @@ -287,7 +287,7 @@ public class GeopointTest extends AndroidTestCase { }); } - public static void testParseParam10() throws Exception { + public static void testParseParam10() { assertParseException(new Runnable() { @SuppressWarnings("unused") diff --git a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java index bd30532..ec84824 100644 --- a/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java +++ b/tests/src/cgeo/geocaching/test/RegExPerformanceTest.java @@ -76,7 +76,7 @@ public class RegExPerformanceTest extends TestCase { } public static void testRegEx() { - List<String> output = doTheTests(10); + final List<String> output = doTheTests(10); for (String s : output) { System.out.println(s); @@ -85,7 +85,7 @@ public class RegExPerformanceTest extends TestCase { public static List<String> doTheTests(final int iterations) { - List<String> output = new ArrayList<String>(); + final List<String> output = new ArrayList<String>(); output.addAll(measure(iterations, "description", PATTERN_DESCRIPTION_OLD, PATTERN_DESCRIPTION)); @@ -94,7 +94,7 @@ public class RegExPerformanceTest extends TestCase { private static List<String> measure(int iterations, String fieldName, Pattern p1, Pattern p2) { - List<String> output = new ArrayList<String>(); + final List<String> output = new ArrayList<String>(); output.add(fieldName + ":"); for (MockedCache cache : MOCKED_CACHES) { @@ -106,15 +106,13 @@ public class RegExPerformanceTest extends TestCase { long diff1, diff2; output.add("Parsing " + cache.getGeocode() + " " + cache.getName()); - { - diff1 = parse(page, p1, iterations); - output.add("Time pattern 1:\t" + diff1 + " ms"); - } - - { - diff2 = parse(page, p2, iterations); - output.add("Time pattern 2:\t" + diff2 + " ms"); - } + + diff1 = parse(page, p1, iterations); + output.add("Time pattern 1:\t" + diff1 + " ms"); + + diff2 = parse(page, p2, iterations); + output.add("Time pattern 2:\t" + diff2 + " ms"); + float reduction = (float) diff2 * 100 / diff1; output.add("New runtime:\t" + String.format("%.1f", reduction) + "%\n"); } @@ -124,7 +122,7 @@ public class RegExPerformanceTest extends TestCase { } private static long parse(String page, Pattern pattern, int iterations) { - long start = System.currentTimeMillis(); + final long start = System.currentTimeMillis(); for (int j = 0; j < iterations; j++) { BaseUtils.getMatch(page, pattern, true, ""); } diff --git a/tests/src/cgeo/geocaching/test/RegExRealPerformanceTest.java b/tests/src/cgeo/geocaching/test/RegExRealPerformanceTest.java index 3867082..07c4c95 100644 --- a/tests/src/cgeo/geocaching/test/RegExRealPerformanceTest.java +++ b/tests/src/cgeo/geocaching/test/RegExRealPerformanceTest.java @@ -17,7 +17,7 @@ public class RegExRealPerformanceTest extends AndroidTestCase { public static void testRegEx() { - List<String> output = RegExPerformanceTest.doTheTests(10); + final List<String> output = RegExPerformanceTest.doTheTests(10); for (String s : output) { Log.d(s); diff --git a/tests/src/cgeo/geocaching/test/WhitespaceTest.java b/tests/src/cgeo/geocaching/test/WhitespaceTest.java index a78f2fa..6138755 100644 --- a/tests/src/cgeo/geocaching/test/WhitespaceTest.java +++ b/tests/src/cgeo/geocaching/test/WhitespaceTest.java @@ -57,10 +57,10 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase { } public void testRegex() { - Pattern pattern = Pattern.compile("\\s+"); + final Pattern pattern = Pattern.compile("\\s+"); final long start = System.currentTimeMillis(); - Matcher matcher = pattern.matcher(data); - String result = matcher.replaceAll(" ").trim(); + final Matcher matcher = pattern.matcher(data); + final String result = matcher.replaceAll(" ").trim(); final long end = System.currentTimeMillis(); assertEquals(EXPECTED_SIZE - 1, result.length()); Log.d((end - start) + " ms regex"); @@ -68,14 +68,14 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase { public void testReplaceAll() { final long start = System.currentTimeMillis(); - String result = data.replaceAll("\\s+", " "); + final String result = data.replaceAll("\\s+", " "); final long end = System.currentTimeMillis(); assertEquals(EXPECTED_SIZE + 1, result.length()); Log.d((end - start) + " ms replaceAll"); } public void testActualImplementation() { - String result; + final String result; final long start = System.currentTimeMillis(); result = BaseUtils.replaceWhitespace(data); final long end = System.currentTimeMillis(); @@ -84,7 +84,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase { } public void testManually() { - String result; + final String result; final long start = System.currentTimeMillis(); result = replaceWhitespaceManually(data); final long end = System.currentTimeMillis(); @@ -93,7 +93,7 @@ public class WhitespaceTest extends AbstractResourceInstrumentationTestCase { } public void testStringUtils() { - String result; + final String result; final long start = System.currentTimeMillis(); result = replaceWhitespaceStringUtils(data); final long end = System.currentTimeMillis(); diff --git a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java index 035c7bc..6de8f4f 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java +++ b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java @@ -96,7 +96,7 @@ public class GC1ZXX2 extends MockedCache { @Override public List<String> getAttributes() { - String[] attributes = new String[] { + final String[] attributes = new String[] { "bicycles_yes", "available_yes", "stroller_yes", @@ -111,7 +111,7 @@ public class GC1ZXX2 extends MockedCache { @Override public Map<LogType, Integer> getLogCounts() { - Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); + final Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); logCounts.put(LogType.PUBLISH_LISTING, 1); logCounts.put(LogType.FOUND_IT, 368); logCounts.put(LogType.POST_REVIEWER_NOTE, 1); diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java index a7722d4..107384f 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java +++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java @@ -130,7 +130,7 @@ public class GC2CJPF extends MockedCache { @Override public List<String> getAttributes() { - String[] attributes = new String[] { + final String[] attributes = new String[] { "motorcycles_no", "wheelchair_no", "winter_yes", @@ -147,7 +147,7 @@ public class GC2CJPF extends MockedCache { @Override public Map<LogType, Integer> getLogCounts() { - Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); + final Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); logCounts.put(LogType.PUBLISH_LISTING, 1); logCounts.put(LogType.FOUND_IT, 119); logCounts.put(LogType.DIDNT_FIND_IT, 3); diff --git a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java index ca558ac..b598cfa 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java +++ b/tests/src/cgeo/geocaching/test/mock/GC3XX5J.java @@ -96,7 +96,7 @@ public class GC3XX5J extends MockedCache { @Override public List<String> getAttributes() { - String[] attributes = new String[] { + final String[] attributes = new String[] { "stroller_no", "kids_no", "bicycles_yes", @@ -114,7 +114,7 @@ public class GC3XX5J extends MockedCache { @Override public Map<LogType, Integer> getLogCounts() { - Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); + final Map<LogType, Integer> logCounts = new HashMap<LogType, Integer>(); logCounts.put(LogType.PUBLISH_LISTING, 2); logCounts.put(LogType.FOUND_IT, 65); logCounts.put(LogType.RETRACT, 1); diff --git a/tests/src/cgeo/geocaching/ui/FormatterTest.java b/tests/src/cgeo/geocaching/ui/FormatterTest.java index 5546ea5..e65f425 100644 --- a/tests/src/cgeo/geocaching/ui/FormatterTest.java +++ b/tests/src/cgeo/geocaching/ui/FormatterTest.java @@ -18,7 +18,7 @@ public class FormatterTest extends AndroidTestCase { } public static void testOwnWaypoint() { - Waypoint own = new Waypoint("my own", WaypointType.OWN, true); + final Waypoint own = new Waypoint("my own", WaypointType.OWN, true); own.setPrefix(Waypoint.PREFIX_OWN); assertFormatting(own, cgeoapplication.getInstance().getString(R.string.waypoint_custom)); } diff --git a/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java b/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java index 2cedb2f..07ad7fe 100644 --- a/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java +++ b/tests/src/cgeo/geocaching/utils/BaseUtilsTest.java @@ -9,7 +9,7 @@ import java.util.regex.Pattern; public class BaseUtilsTest extends AndroidTestCase { public static void testRegEx() { - String page = MockedCache.readCachePage("GC2CJPF"); + final String page = MockedCache.readCachePage("GC2CJPF"); assertEquals("blafoo", BaseUtils.getMatch(page, GCConstants.PATTERN_LOGIN_NAME, true, "???")); assertTrue(page.contains("id=\"ctl00_hlRenew\"") || GCConstants.MEMBER_STATUS_PM.equals(BaseUtils.getMatch(page, GCConstants.PATTERN_MEMBER_STATUS, true, "???"))); int cachesFound = 0; @@ -26,7 +26,7 @@ public class BaseUtilsTest extends AndroidTestCase { } public static void testControlCharactersCleanup() { - Pattern patternAll = Pattern.compile("(.*)", Pattern.DOTALL); + final Pattern patternAll = Pattern.compile("(.*)", Pattern.DOTALL); assertEquals("some control characters removed", BaseUtils.getMatch("some" + "\u001C" + "control" + (char) 0x1D + "characters removed", patternAll, "")); assertEquals("newline also removed", BaseUtils.getMatch("newline\nalso\nremoved", patternAll, "")); } diff --git a/tests/src/cgeo/geocaching/utils/CryptUtilsTest.java b/tests/src/cgeo/geocaching/utils/CryptUtilsTest.java index d092cd8..fff24f2 100644 --- a/tests/src/cgeo/geocaching/utils/CryptUtilsTest.java +++ b/tests/src/cgeo/geocaching/utils/CryptUtilsTest.java @@ -18,7 +18,7 @@ public class CryptUtilsTest extends TestCase { assertEquals(61731, GCConstants.gccodeToGCId("GCF123")); } - public static void testIssue1902() throws Exception { + public static void testIssue1902() { assertEquals("ƖƖlƖƖƖƖ", CryptUtils.rot13("ƖƖyƖƖƖƖ")); } } diff --git a/tests/src/cgeo/geocaching/utils/DateUtilsTest.java b/tests/src/cgeo/geocaching/utils/DateUtilsTest.java index caf5e3c..0a9d3e3 100644 --- a/tests/src/cgeo/geocaching/utils/DateUtilsTest.java +++ b/tests/src/cgeo/geocaching/utils/DateUtilsTest.java @@ -7,7 +7,7 @@ import junit.framework.TestCase; public class DateUtilsTest extends TestCase { public static void testDaysSince() { - Calendar start = Calendar.getInstance(); + final Calendar start = Calendar.getInstance(); for (int hour = 0; hour < 24; hour++) { start.set(Calendar.HOUR_OF_DAY, hour); assertEquals(0, DateUtils.daysSince(start.getTimeInMillis())); diff --git a/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java index 092e45e..52b816e 100644 --- a/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java +++ b/tests/src/cgeo/geocaching/utils/HtmlUtilsTest.java @@ -5,7 +5,7 @@ import junit.framework.TestCase; public class HtmlUtilsTest extends TestCase { public static void testNonLatinCharConv() { - String res = HtmlUtils.convertNonLatinCharactersToHTML("abcΦςቡぢれ"); + final String res = HtmlUtils.convertNonLatinCharactersToHTML("abcΦςቡぢれ"); assertEquals("abcΦςቡぢれ", res); } } diff --git a/tests/src/cgeo/geocaching/utils/MemorySubjectTest.java b/tests/src/cgeo/geocaching/utils/MemorySubjectTest.java index 7b30180..ee46950 100644 --- a/tests/src/cgeo/geocaching/utils/MemorySubjectTest.java +++ b/tests/src/cgeo/geocaching/utils/MemorySubjectTest.java @@ -5,8 +5,8 @@ import android.test.AndroidTestCase; public class MemorySubjectTest extends AndroidTestCase { private static class Observer implements IObserver<Integer> { - public int times = 0; - public Integer value; + private int times = 0; + private Integer value; @Override public void update(final Integer data) { diff --git a/tests/src/cgeo/test/Compare.java b/tests/src/cgeo/test/Compare.java index ca3313e..8af1541 100644 --- a/tests/src/cgeo/test/Compare.java +++ b/tests/src/cgeo/test/Compare.java @@ -48,8 +48,8 @@ public abstract class Compare { // The inventories can differ too often, therefore we don't compare them. Also, the personal note // cannot be expected to match with different tester accounts. - int actualSpoilersSize = null != actual.getSpoilers() ? actual.getSpoilers().size() : 0; - int expectedSpoilersSize = null != expected.getSpoilers() ? expected.getSpoilers().size() : 0; + final int actualSpoilersSize = null != actual.getSpoilers() ? actual.getSpoilers().size() : 0; + final int expectedSpoilersSize = null != expected.getSpoilers() ? expected.getSpoilers().size() : 0; assertEquals(expectedSpoilersSize, actualSpoilersSize); } } |