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 /main/src | |
| 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
Diffstat (limited to 'main/src')
25 files changed, 127 insertions, 126 deletions
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(); } } |
