diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2014-09-07 17:46:02 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2014-09-07 17:46:02 +0200 |
| commit | 815ee250714b2cfb7effbd02880fd688f30778b9 (patch) | |
| tree | bec7540923ce25f2fdad2fe1c32ce29d28d86817 | |
| parent | 8cd0f9d353cc4800deeb6c17375ed27090b71de6 (diff) | |
| download | cgeo-815ee250714b2cfb7effbd02880fd688f30778b9.zip cgeo-815ee250714b2cfb7effbd02880fd688f30778b9.tar.gz cgeo-815ee250714b2cfb7effbd02880fd688f30778b9.tar.bz2 | |
fix some findbugs issues
9 files changed, 40 insertions, 30 deletions
diff --git a/main/src/cgeo/geocaching/CacheListActivity.java b/main/src/cgeo/geocaching/CacheListActivity.java index 7b887aa..5eaf17e 100644 --- a/main/src/cgeo/geocaching/CacheListActivity.java +++ b/main/src/cgeo/geocaching/CacheListActivity.java @@ -787,7 +787,7 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA @Override public void onClick(final DialogInterface dialog, final int which) { progress.show(CacheListActivity.this, null, res.getString(R.string.caches_clear_offlinelogs_progress), true, clearOfflineLogsHandler.cancelMessage()); - new ClearOfflineLogsThread(clearOfflineLogsHandler).start(); + new ClearOfflineLogsThread(clearOfflineLogsHandler, adapter.getCheckedOrAllCaches()).start(); } }); } @@ -1315,14 +1315,14 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA } - private class ClearOfflineLogsThread extends Thread { + private static class ClearOfflineLogsThread extends Thread { final private Handler handler; final private List<Geocache> selected; - public ClearOfflineLogsThread(final Handler handlerIn) { + public ClearOfflineLogsThread(final Handler handlerIn, final List<Geocache> selectedCaches) { handler = handlerIn; - selected = adapter.getCheckedOrAllCaches(); + selected = selectedCaches; } @Override diff --git a/main/src/cgeo/geocaching/CacheMenuHandler.java b/main/src/cgeo/geocaching/CacheMenuHandler.java index 0dc6444..fa58179 100644 --- a/main/src/cgeo/geocaching/CacheMenuHandler.java +++ b/main/src/cgeo/geocaching/CacheMenuHandler.java @@ -18,7 +18,11 @@ import android.view.MenuItem; * TODO: replace by a fragment * */ -public class CacheMenuHandler extends AbstractUIFactory { +public final class CacheMenuHandler extends AbstractUIFactory { + + private CacheMenuHandler() { + // utility class + } /** * Methods to be implemented by the activity to react to the cache menu selections. diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java index 7b444fb..1ba9c5a 100644 --- a/main/src/cgeo/geocaching/EditWaypointActivity.java +++ b/main/src/cgeo/geocaching/EditWaypointActivity.java @@ -67,10 +67,6 @@ public class EditWaypointActivity extends AbstractActionBarActivity implements C @Extra(Intents.EXTRA_GEOCODE) protected String geocode = null; @Extra(Intents.EXTRA_WAYPOINT_ID) protected int waypointId = -1; - /** - * number of waypoints that the corresponding cache has until now - */ - @Extra(Intents.EXTRA_COUNT) protected int wpCount = 0; @InstanceState protected int waypointTypeSelectorPosition = -1; @@ -524,6 +520,6 @@ public class EditWaypointActivity extends AbstractActionBarActivity implements C } public static void startActivityAddWaypoint(final Context context, final Geocache cache) { - EditWaypointActivity_.intent(context).geocode(cache.getGeocode()).wpCount(cache.getWaypoints().size()).start(); + EditWaypointActivity_.intent(context).geocode(cache.getGeocode()).start(); } } diff --git a/main/src/cgeo/geocaching/Intents.java b/main/src/cgeo/geocaching/Intents.java index a2b9dee..5ed2719 100644 --- a/main/src/cgeo/geocaching/Intents.java +++ b/main/src/cgeo/geocaching/Intents.java @@ -89,12 +89,10 @@ public class Intents { if (StringUtils.isBlank(typeName)) { return CacheListType.OFFLINE; } - CacheListType listType; try { - listType = CacheListType.valueOf(typeName); + return CacheListType.valueOf(typeName); } catch (final IllegalArgumentException e) { return CacheListType.OFFLINE; } - return (listType != null) ? listType : CacheListType.OFFLINE; } } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index c00723d..4d98e42 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -27,6 +27,10 @@ import java.util.List; public final class NavigationAppFactory extends AbstractAppFactory { + private NavigationAppFactory() { + // utility class + } + public enum NavigationAppsEnum { /** The internal compass activity */ COMPASS(new CompassApp(), 0, R.string.pref_navigation_menu_compass), diff --git a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java index 5886168..b6706a0 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java @@ -17,6 +17,11 @@ import java.util.ArrayList; import java.util.List; public final class CacheListAppFactory extends AbstractAppFactory { + + private CacheListAppFactory() { + // utility class + } + private static class LazyHolder { public static final CacheListApp[] apps = { new InternalCacheListMap(), @@ -71,10 +76,10 @@ public final class CacheListAppFactory extends AbstractAppFactory { } if (app != null) { try { - boolean result = app.invoke(caches, activity, search); + final boolean result = app.invoke(caches, activity, search); ActivityMixin.invalidateOptionsMenu(activity); return result; - } catch (Exception e) { + } catch (final Exception e) { Log.e("CacheListAppFactory.onMenuItemSelected", e); } } diff --git a/main/src/cgeo/geocaching/apps/cachelist/MapsWithMeCacheListApp.java b/main/src/cgeo/geocaching/apps/cachelist/MapsWithMeCacheListApp.java index ba177f0..c6c7709 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/MapsWithMeCacheListApp.java +++ b/main/src/cgeo/geocaching/apps/cachelist/MapsWithMeCacheListApp.java @@ -26,10 +26,10 @@ public class MapsWithMeCacheListApp extends AbstractApp implements CacheListApp } @Override - public boolean invoke(List<Geocache> caches, Activity activity, SearchResult search) { + public boolean invoke(final List<Geocache> caches, final Activity activity, final SearchResult search) { final MWMPoint[] points = new MWMPoint[caches.size()]; for (int i = 0; i < points.length; i++) { - Geocache geocache = caches.get(i); + final Geocache geocache = caches.get(i); points[i] = new MWMPoint(geocache.getCoords().getLatitude(), geocache.getCoords().getLongitude(), geocache.getName(), geocache.getGeocode()); } MapsWithMeApi.showPointsOnMap(activity, null, getPendingIntent(activity), points); @@ -44,22 +44,20 @@ public class MapsWithMeCacheListApp extends AbstractApp implements CacheListApp /** * get cache code from a PendingIntent after an invocation of MapsWithMe - * + * * @return */ @Nullable public static String getCacheFromMapsWithMe(final Context context, final Intent intent) { final MWMResponse mwmResponse = MWMResponse.extractFromIntent(context, intent); - if (mwmResponse != null) { - final MWMPoint point = mwmResponse.getPoint(); - if (point != null) { - return point.getId(); - } + final MWMPoint point = mwmResponse.getPoint(); + if (point != null) { + return point.getId(); } return null; } - private static PendingIntent getPendingIntent(Context context) { + private static PendingIntent getPendingIntent(final Context context) { final Intent intent = new Intent(context, CacheDetailActivity.class); return PendingIntent.getActivity(context, 0, intent, 0); } diff --git a/main/src/cgeo/geocaching/ui/LoggingUI.java b/main/src/cgeo/geocaching/ui/LoggingUI.java index 8454474..e9656e8 100644 --- a/main/src/cgeo/geocaching/ui/LoggingUI.java +++ b/main/src/cgeo/geocaching/ui/LoggingUI.java @@ -17,7 +17,12 @@ import android.widget.ArrayAdapter; import java.util.ArrayList; import java.util.List; -public class LoggingUI extends AbstractUIFactory { +public final class LoggingUI extends AbstractUIFactory { + + private LoggingUI() { + // utility class + } + public static class LogTypeEntry { private final LogType logType; private final SpecialLogType specialLogType; @@ -79,7 +84,7 @@ public class LoggingUI extends AbstractUIFactory { final List<LogType> logTypes = cache.getPossibleLogTypes(); final ArrayList<LogTypeEntry> list = new ArrayList<>(); - for (LogType logType : logTypes) { + for (final LogType logType : logTypes) { list.add(new LogTypeEntry(logType, null, logType == currentLogType)); } if (cache.isLogOffline()) { @@ -94,7 +99,7 @@ public class LoggingUI extends AbstractUIFactory { builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int item) { + public void onClick(final DialogInterface dialog, final int item) { final LogTypeEntry logTypeEntry = adapter.getItem(item); if (logTypeEntry.logType == null) { switch (logTypeEntry.specialLogType) { @@ -116,7 +121,7 @@ public class LoggingUI extends AbstractUIFactory { } - public static void onPrepareOptionsMenu(Menu menu, Geocache cache) { + public static void onPrepareOptionsMenu(final Menu menu, final Geocache cache) { if (cache == null) { return; } @@ -127,7 +132,7 @@ public class LoggingUI extends AbstractUIFactory { itemOffline.setVisible(cache.supportsLogging() && Settings.getLogOffline()); } - public static void addMenuItems(Activity activity, Menu menu, Geocache cache) { + public static void addMenuItems(final Activity activity, final Menu menu, final Geocache cache) { activity.getMenuInflater().inflate(R.menu.logging_ui, menu); onPrepareOptionsMenu(menu, cache); } diff --git a/tests/src/cgeo/geocaching/waypointactivity/AbstractAddWaypointActivityTest.java b/tests/src/cgeo/geocaching/waypointactivity/AbstractAddWaypointActivityTest.java index 34968a3..b5dea39 100644 --- a/tests/src/cgeo/geocaching/waypointactivity/AbstractAddWaypointActivityTest.java +++ b/tests/src/cgeo/geocaching/waypointactivity/AbstractAddWaypointActivityTest.java @@ -6,7 +6,7 @@ public abstract class AbstractAddWaypointActivityTest extends AbstractWaypointAc @Override protected void setUp() throws Exception { super.setUp(); - setActivityIntent(new EditWaypointActivity_.IntentBuilder_(getInstrumentation().getContext()).geocode(getCache().getGeocode()).wpCount(1).get()); + setActivityIntent(new EditWaypointActivity_.IntentBuilder_(getInstrumentation().getContext()).geocode(getCache().getGeocode()).get()); getActivity(); } } |
