diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2011-09-28 18:09:54 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2011-09-29 09:35:48 +0200 |
commit | 695e2cd89d9d97687a5bfc8b4933c923618ed7a5 (patch) | |
tree | 057739c6391e0daf784cf5c714fecbac73389780 /main | |
parent | f5def956a2bb6bf37fa50b4feb7a1cea00b3ce7f (diff) | |
download | cgeo-695e2cd89d9d97687a5bfc8b4933c923618ed7a5.zip cgeo-695e2cd89d9d97687a5bfc8b4933c923618ed7a5.tar.gz cgeo-695e2cd89d9d97687a5bfc8b4933c923618ed7a5.tar.bz2 |
Minor cleanups
Remove unuse method parameters. Make classes and methods
abstract. Write some docstrings.
Diffstat (limited to 'main')
-rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 6 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgGPXListAdapter.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgLogForm.java | 6 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgSettings.java | 6 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgUpdateDir.java | 6 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgUpdateLoc.java | 6 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeo.java | 28 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeoabout.java | 21 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeoapplication.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeocaches.java | 10 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeodetail.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeogpxes.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeohelpers.java | 9 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeoinit.java | 14 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeopopup.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeowaypoint.java | 4 |
17 files changed, 62 insertions, 72 deletions
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index ebf6f17..d31e693 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -2583,7 +2583,7 @@ public class cgBase { } final cgSearch search = app.getHistoryOfCaches(true, cachetype); - search.totalCnt = app.getAllHistoricCachesCount(true, cachetype); + search.totalCnt = app.getAllHistoricCachesCount(); return search.getCurrentId(); } @@ -3637,7 +3637,7 @@ public class cgBase { } } - public static void dropCache(cgeoapplication app, Activity activity, cgCache cache, Handler handler) { + public static void dropCache(final cgeoapplication app, final cgCache cache, final Handler handler) { try { app.markDropped(cache.geocode); app.removeCacheFromCache(cache.geocode); @@ -4096,7 +4096,7 @@ public class cgBase { /** * Generate a numeric date and time string according to system-wide settings (locale, * date format) such as "7 sept. à 12:35". - * + * * @param context * a Context * @param date diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index 492ab67..e01152d 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -2569,7 +2569,7 @@ public class cgData { return count; } - public int getAllHistoricCachesCount(boolean detailedOnly, String cachetype) { + public int getAllHistoricCachesCount() { init(); int count = 0; diff --git a/main/src/cgeo/geocaching/cgGPXListAdapter.java b/main/src/cgeo/geocaching/cgGPXListAdapter.java index df1933c..3153c98 100644 --- a/main/src/cgeo/geocaching/cgGPXListAdapter.java +++ b/main/src/cgeo/geocaching/cgGPXListAdapter.java @@ -16,7 +16,7 @@ public class cgGPXListAdapter extends ArrayAdapter<File> { private cgeogpxes parent = null; private LayoutInflater inflater = null; - public cgGPXListAdapter(cgeogpxes parentIn, cgSettings settingsIn, List<File> listIn) { + public cgGPXListAdapter(cgeogpxes parentIn, List<File> listIn) { super(parentIn, 0, listIn); parent = parentIn; diff --git a/main/src/cgeo/geocaching/cgLogForm.java b/main/src/cgeo/geocaching/cgLogForm.java index 12f894e..184ef99 100644 --- a/main/src/cgeo/geocaching/cgLogForm.java +++ b/main/src/cgeo/geocaching/cgLogForm.java @@ -4,12 +4,10 @@ import cgeo.geocaching.activity.AbstractActivity; import java.util.Calendar; -public class cgLogForm extends AbstractActivity { +abstract public class cgLogForm extends AbstractActivity { public cgLogForm(String helpTopic) { super(helpTopic); } - public void setDate(Calendar dateIn) { - // to be overwritten - } + abstract public void setDate(Calendar dateIn); }
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/cgSettings.java b/main/src/cgeo/geocaching/cgSettings.java index fef2f80..2a79313 100644 --- a/main/src/cgeo/geocaching/cgSettings.java +++ b/main/src/cgeo/geocaching/cgSettings.java @@ -251,14 +251,14 @@ public class cgSettings { } public static String getStorage() { - return getStorageSpecific(null)[0]; + return getStorageSpecific()[0]; } public static String getStorageSec() { - return getStorageSpecific(null)[1]; + return getStorageSpecific()[1]; } - public static String[] getStorageSpecific(Boolean hidden) { + public static String[] getStorageSpecific() { String external = Environment.getExternalStorageDirectory() + "/" + cache + "/"; String data = Environment.getDataDirectory() + "/data/cgeo.geocaching/" + cache + "/"; diff --git a/main/src/cgeo/geocaching/cgUpdateDir.java b/main/src/cgeo/geocaching/cgUpdateDir.java index dd09a55..236d7a8 100644 --- a/main/src/cgeo/geocaching/cgUpdateDir.java +++ b/main/src/cgeo/geocaching/cgUpdateDir.java @@ -1,7 +1,5 @@ package cgeo.geocaching; -public class cgUpdateDir { - public void updateDir(cgDirection dir) { - // to be overriden - } +abstract public class cgUpdateDir { + abstract public void updateDir(cgDirection dir); } diff --git a/main/src/cgeo/geocaching/cgUpdateLoc.java b/main/src/cgeo/geocaching/cgUpdateLoc.java index a341081..763ca85 100644 --- a/main/src/cgeo/geocaching/cgUpdateLoc.java +++ b/main/src/cgeo/geocaching/cgUpdateLoc.java @@ -1,7 +1,5 @@ package cgeo.geocaching; -public class cgUpdateLoc { - public void updateLoc(cgGeo geo) { - // to be overriden - } +abstract public class cgUpdateLoc { + abstract public void updateLoc(cgGeo geo); } diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java index 404effa..6294fa1 100644 --- a/main/src/cgeo/geocaching/cgeo.java +++ b/main/src/cgeo/geocaching/cgeo.java @@ -279,7 +279,7 @@ public class cgeo extends AbstractActivity { final int id = item.getItemId(); switch (id) { case MENU_ABOUT: - showAbout(null); + showAbout(); return true; case MENU_HELPERS: context.startActivity(new Intent(context, cgeohelpers.class)); @@ -470,7 +470,7 @@ public class cgeo extends AbstractActivity { findOnMap.setClickable(true); findOnMap.setOnClickListener(new OnClickListener() { public void onClick(View v) { - cgeoFindOnMap(v); + cgeoFindOnMap(); } }); @@ -478,7 +478,7 @@ public class cgeo extends AbstractActivity { findByOffline.setClickable(true); findByOffline.setOnClickListener(new OnClickListener() { public void onClick(View v) { - cgeoFindByOffline(v); + cgeoFindByOffline(); } }); registerForContextMenu(findByOffline); @@ -489,7 +489,7 @@ public class cgeo extends AbstractActivity { advanced.setClickable(true); advanced.setOnClickListener(new OnClickListener() { public void onClick(View v) { - cgeoSearch(v); + cgeoSearch(); } }); @@ -497,7 +497,7 @@ public class cgeo extends AbstractActivity { any.setClickable(true); any.setOnClickListener(new OnClickListener() { public void onClick(View v) { - cgeoPoint(v); + cgeoPoint(); } }); @@ -534,7 +534,7 @@ public class cgeo extends AbstractActivity { findNearest.setClickable(true); findNearest.setOnClickListener(new OnClickListener() { public void onClick(View v) { - cgeoFindNearest(v); + cgeoFindNearest(); } }); findNearest.setBackgroundResource(R.drawable.main_nearby); @@ -604,12 +604,12 @@ public class cgeo extends AbstractActivity { } } - public void cgeoFindOnMap(View v) { + public void cgeoFindOnMap() { findViewById(R.id.map).setPressed(true); context.startActivity(new Intent(context, settings.getMapFactory().getMapClass())); } - public void cgeoFindNearest(View v) { + public void cgeoFindNearest() { if (geo == null) { return; } @@ -623,24 +623,24 @@ public class cgeo extends AbstractActivity { context.startActivity(cachesIntent); } - public void cgeoFindByOffline(View v) { + public void cgeoFindByOffline() { findViewById(R.id.search_offline).setPressed(true); final Intent cachesIntent = new Intent(context, cgeocaches.class); cachesIntent.putExtra("type", "offline"); context.startActivity(cachesIntent); } - public void cgeoSearch(View v) { + public void cgeoSearch() { findViewById(R.id.advanced_button).setPressed(true); context.startActivity(new Intent(context, cgeoadvsearch.class)); } - public void cgeoPoint(View v) { + public void cgeoPoint() { findViewById(R.id.any_button).setPressed(true); context.startActivity(new Intent(context, cgeopoint.class)); } - public void cgeoFilter(View v) { + public void cgeoFilter() { findViewById(R.id.filter_button).setPressed(true); findViewById(R.id.filter_button).performClick(); } @@ -755,11 +755,11 @@ public class cgeo extends AbstractActivity { } } - public void showAbout(View view) { + public void showAbout() { context.startActivity(new Intent(context, cgeoabout.class)); } - public void goSearch(View view) { + public void goSearch() { onSearchRequested(); } } diff --git a/main/src/cgeo/geocaching/cgeoabout.java b/main/src/cgeo/geocaching/cgeoabout.java index 1c09614..18128a0 100644 --- a/main/src/cgeo/geocaching/cgeoabout.java +++ b/main/src/cgeo/geocaching/cgeoabout.java @@ -9,7 +9,6 @@ import android.net.Uri; import android.os.Bundle; import android.text.method.LinkMovementMethod; import android.util.Log; -import android.view.View; import android.widget.TextView; public class cgeoabout extends AbstractActivity { @@ -52,39 +51,35 @@ public class cgeoabout extends AbstractActivity { } } - public void donateMore(View view) { + public void donateMore() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FMLNN8GXZKJEE"))); - //activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=N2FKGNCPPRUVE"))); - //activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2Z69QWLRCBE9N&lc=US&item_name=c%3ageo¤cy_code=EUR&amount=15&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"))); } - public void donateLess(View view) { + public void donateLess() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FMLNN8GXZKJEE"))); - //activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4PRD9CX4Y8XR6"))); - //activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2Z69QWLRCBE9N&lc=US&item_name=c%3ageo¤cy_code=EUR&amount=7&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"))); } - public void author(View view) { + public void author() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://carnero.cc/"))); } - public void support(View view) { + public void support() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:support@cgeo.org"))); } - public void website(View view) { + public void website() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.cgeo.org/"))); } - public void facebook(View view) { + public void facebook() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/pages/cgeo/297269860090"))); } - public void twitter(View view) { + public void twitter() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://twitter.com/android_gc"))); } - public void nutshellmanual(View view) { + public void nutshellmanual() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.cgeo.org/"))); } } diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java index 2b9f919..dab6b9a 100644 --- a/main/src/cgeo/geocaching/cgeoapplication.java +++ b/main/src/cgeo/geocaching/cgeoapplication.java @@ -590,12 +590,12 @@ public class cgeoapplication extends Application { return storage.getAllStoredCachesCount(detailedOnly, cachetype, list); } - public int getAllHistoricCachesCount(boolean detailedOnly, String cachetype) { + public int getAllHistoricCachesCount() { if (storage == null) { storage = new cgData(this); } - return storage.getAllHistoricCachesCount(detailedOnly, cachetype); + return storage.getAllHistoricCachesCount(); } public void markStored(String geocode, int listId) { diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index 726a660..d0d4e86 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -997,7 +997,7 @@ public class cgeocaches extends AbstractListActivity { setComparator(item, new GeocodeComparator()); return false; case MENU_SWITCH_LIST: - selectList(null); + selectList(); return false; case MENU_SORT_RATING: setComparator(item, new RatingComparator()); @@ -1254,7 +1254,7 @@ public class cgeocaches extends AbstractListActivity { } else if (id == MENU_FILTER_TYPE_GPS) { return setFilter(new cgFilterByType("gps")); } else if (id == MENU_DROP_CACHE) { - cgBase.dropCache(app, this, cache, new Handler() { + cgBase.dropCache(app, cache, new Handler() { @Override public void handleMessage(Message msg) { refreshCurrentList(); @@ -2391,7 +2391,7 @@ public class cgeocaches extends AbstractListActivity { } } - public void selectList(View view) { + public void selectList() { if (type.equals("offline") == false) { return; } @@ -2551,7 +2551,7 @@ public class cgeocaches extends AbstractListActivity { alert.show(); } - public void goMap(View view) { + public void goMap() { if (searchId == null || CollectionUtils.isEmpty(cacheList)) { showToast(res.getString(R.string.warn_no_cache_coord)); @@ -2565,7 +2565,7 @@ public class cgeocaches extends AbstractListActivity { startActivity(mapIntent); } - public void goManual(View view) { + public void goManual() { if (type != null && type.equals("offline")) { ActivityMixin.goManual(this, "c:geo-stored"); } else if (type != null && type.equals("history")) { diff --git a/main/src/cgeo/geocaching/cgeodetail.java b/main/src/cgeo/geocaching/cgeodetail.java index 1df6994..c2a231f 100644 --- a/main/src/cgeo/geocaching/cgeodetail.java +++ b/main/src/cgeo/geocaching/cgeodetail.java @@ -1783,7 +1783,7 @@ public class cgeodetail extends AbstractActivity { @Override public void run() { - cgBase.dropCache(app, cgeodetail.this, cache, handler); + cgBase.dropCache(app, cache, handler); } } @@ -1918,7 +1918,7 @@ public class cgeodetail extends AbstractActivity { } } - public void goCompass(View view) { + public void goCompass() { if (cache == null || cache.coords == null) { showToast(res.getString(R.string.cache_coordinates_no)); diff --git a/main/src/cgeo/geocaching/cgeogpxes.java b/main/src/cgeo/geocaching/cgeogpxes.java index 4f32676..20cef00 100644 --- a/main/src/cgeo/geocaching/cgeogpxes.java +++ b/main/src/cgeo/geocaching/cgeogpxes.java @@ -58,7 +58,7 @@ public class cgeogpxes extends FileList<cgGPXListAdapter> { @Override protected cgGPXListAdapter getAdapter(List<File> files) { - return new cgGPXListAdapter(this, getSettings(), files); + return new cgGPXListAdapter(this, files); } @Override diff --git a/main/src/cgeo/geocaching/cgeohelpers.java b/main/src/cgeo/geocaching/cgeohelpers.java index cc288b1..4b7a211 100644 --- a/main/src/cgeo/geocaching/cgeohelpers.java +++ b/main/src/cgeo/geocaching/cgeohelpers.java @@ -5,7 +5,6 @@ import cgeo.geocaching.activity.AbstractActivity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.view.View; import java.util.Locale; @@ -38,7 +37,7 @@ public class cgeohelpers extends AbstractActivity { finish(); } - public void installManual(View view) { + public void installManual() { final Locale loc = Locale.getDefault(); final String language = loc.getLanguage(); @@ -50,15 +49,15 @@ public class cgeohelpers extends AbstractActivity { } } - public void installLocus(View view) { + public void installLocus() { installFromMarket("menion.android.locus"); } - public void installGpsStatus(View view) { + public void installGpsStatus() { installFromMarket("com.eclipsim.gpsstatus2"); } - public void installBluetoothGps(View view) { + public void installBluetoothGps() { installFromMarket("googoo.android.btgps"); } } diff --git a/main/src/cgeo/geocaching/cgeoinit.java b/main/src/cgeo/geocaching/cgeoinit.java index 55791fa..781917d 100644 --- a/main/src/cgeo/geocaching/cgeoinit.java +++ b/main/src/cgeo/geocaching/cgeoinit.java @@ -487,7 +487,7 @@ public class cgeoinit extends AbstractActivity { } } - public void backup(View view) { + public void backup() { // avoid overwriting an existing backup with an empty database (can happen directly after reinstalling the app) if (app.getAllStoredCachesCount(true, null, null) == 0) { return; @@ -514,7 +514,7 @@ public class cgeoinit extends AbstractActivity { } } - public void restore(View view) { + public void restore() { final boolean status = app.restoreDatabase(); if (status) { @@ -557,15 +557,17 @@ public class cgeoinit extends AbstractActivity { * Returns the Int Value in the Field * * @param field - * @param def - * @return + * the field to retrieve the integer value from + * @param defaultValue + * the default value + * @return either the field content or the default value */ - private int safeParse(TextView field, int def) { + static private int safeParse(final TextView field, int defaultValue) { try { return Integer.parseInt(field.getText().toString()); } catch (NumberFormatException e) { - return def; + return defaultValue; } } diff --git a/main/src/cgeo/geocaching/cgeopopup.java b/main/src/cgeo/geocaching/cgeopopup.java index 6b7f363..07c8412 100644 --- a/main/src/cgeo/geocaching/cgeopopup.java +++ b/main/src/cgeo/geocaching/cgeopopup.java @@ -602,7 +602,7 @@ public class cgeopopup extends AbstractActivity { @Override public void run() { - cgBase.dropCache(app, cgeopopup.this, cache, handler); + cgBase.dropCache(app, cache, handler); } } @@ -643,7 +643,7 @@ public class cgeopopup extends AbstractActivity { detailsList.addView(itemLayout); } - public void goCompass(View view) { + public void goCompass() { if (cache == null || cache.coords == null) { showToast(res.getString(R.string.cache_coordinates_no)); diff --git a/main/src/cgeo/geocaching/cgeowaypoint.java b/main/src/cgeo/geocaching/cgeowaypoint.java index 5951e47..25049c9 100644 --- a/main/src/cgeo/geocaching/cgeowaypoint.java +++ b/main/src/cgeo/geocaching/cgeowaypoint.java @@ -243,7 +243,7 @@ public class cgeowaypoint extends AbstractActivity { public boolean onOptionsItemSelected(MenuItem item) { final int menuItem = item.getItemId(); if (menuItem == MENU_ID_COMPASS) { - goCompass(null); + goCompass(); return true; } else if (menuItem == MENU_ID_CACHES_AROUND) { cachesAround(); @@ -308,7 +308,7 @@ public class cgeowaypoint extends AbstractActivity { } } - public void goCompass(View view) { + public void goCompass() { if (!navigationPossible()) { return; } |