aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2013-10-02 21:27:14 +0200
committerBananeweizen <Bananeweizen@gmx.de>2013-10-02 21:27:14 +0200
commit9fe7014575b418f2ca3e456001299d0ca7966057 (patch)
tree751fc58b802c60c4edad9a0ae02906b7f4f8f382 /main/src
parentfa619131bfd3d5cf5286b958ff88c6a225989ec9 (diff)
downloadcgeo-9fe7014575b418f2ca3e456001299d0ca7966057.zip
cgeo-9fe7014575b418f2ca3e456001299d0ca7966057.tar.gz
cgeo-9fe7014575b418f2ca3e456001299d0ca7966057.tar.bz2
refactoring: findbugs cleanups
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java6
-rw-r--r--main/src/cgeo/geocaching/CacheListActivity.java2
-rw-r--r--main/src/cgeo/geocaching/GeoDataProvider.java2
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java2
-rw-r--r--main/src/cgeo/geocaching/files/LocalStorage.java4
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java2
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java3
-rw-r--r--main/src/cgeo/geocaching/ui/CacheListAdapter.java1
-rw-r--r--main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java3
-rw-r--r--main/src/cgeo/geocaching/ui/ImagesList.java1
-rw-r--r--main/src/cgeo/geocaching/ui/LoggingUI.java2
-rw-r--r--main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java7
12 files changed, 29 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index c58b45f..c66741d 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -342,15 +342,18 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
final int viewId = view.getId();
switch (viewId) {
case R.id.value: // coordinates, gc-code, name
+ assert view instanceof TextView;
clickedItemText = ((TextView) view).getText();
final String itemTitle = (String) ((TextView) ((View) view.getParent()).findViewById(R.id.name)).getText();
buildDetailsContextMenu(menu, itemTitle, true);
break;
case R.id.shortdesc:
+ assert view instanceof TextView;
clickedItemText = ((TextView) view).getText();
buildDetailsContextMenu(menu, res.getString(R.string.cache_description), false);
break;
case R.id.longdesc:
+ assert view instanceof TextView;
// combine short and long description
final String shortDesc = cache.getShortDescription();
if (StringUtils.isBlank(shortDesc)) {
@@ -361,14 +364,17 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc
buildDetailsContextMenu(menu, res.getString(R.string.cache_description), false);
break;
case R.id.personalnote:
+ assert view instanceof TextView;
clickedItemText = ((TextView) view).getText();
buildDetailsContextMenu(menu, res.getString(R.string.cache_personal_note), true);
break;
case R.id.hint:
+ assert view instanceof TextView;
clickedItemText = ((TextView) view).getText();
buildDetailsContextMenu(menu, res.getString(R.string.cache_hint), false);
break;
case R.id.log:
+ assert view instanceof TextView;
clickedItemText = ((TextView) view).getText();
buildDetailsContextMenu(menu, res.getString(R.string.cache_logs), false);
break;
diff --git a/main/src/cgeo/geocaching/CacheListActivity.java b/main/src/cgeo/geocaching/CacheListActivity.java
index 813a57e..f560d11 100644
--- a/main/src/cgeo/geocaching/CacheListActivity.java
+++ b/main/src/cgeo/geocaching/CacheListActivity.java
@@ -1648,6 +1648,8 @@ public class CacheListActivity extends AbstractListActivity implements FilteredA
case NEXT_PAGE:
loader = new NextPageGeocacheListLoader(app, search);
break;
+ default:
+ throw new IllegalStateException();
}
setTitle(title);
showProgress(true);
diff --git a/main/src/cgeo/geocaching/GeoDataProvider.java b/main/src/cgeo/geocaching/GeoDataProvider.java
index f615630..0b1c480 100644
--- a/main/src/cgeo/geocaching/GeoDataProvider.java
+++ b/main/src/cgeo/geocaching/GeoDataProvider.java
@@ -303,6 +303,8 @@ class GeoDataProvider extends MemorySubject<IGeoData> {
changed = true;
}
break;
+ default:
+ throw new IllegalStateException();
}
if (changed) {
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index c0090b3..778006f 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -1642,7 +1642,7 @@ public abstract class GCParser {
// TODO: we should update our log data structure to be able to record
// proper coordinates, and make them clickable. In the meantime, it is
// better to integrate those coordinates into the text rather than not
- // display them as all.
+ // display them at all.
final String latLon = entry.getString("LatLonString");
final LogEntry logDone = new LogEntry(
entry.getString("UserName"),
diff --git a/main/src/cgeo/geocaching/files/LocalStorage.java b/main/src/cgeo/geocaching/files/LocalStorage.java
index 40684f8..edbecf6 100644
--- a/main/src/cgeo/geocaching/files/LocalStorage.java
+++ b/main/src/cgeo/geocaching/files/LocalStorage.java
@@ -7,6 +7,7 @@ import cgeo.geocaching.utils.Log;
import ch.boye.httpclientandroidlib.Header;
import ch.boye.httpclientandroidlib.HttpResponse;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.Nullable;
@@ -37,6 +38,7 @@ import java.util.List;
*/
public final class LocalStorage {
+ private static final String FILE_SYSTEM_TABLE_PATH = "/system/etc/vold.fstab";
public static final String HEADER_LAST_MODIFIED = "last-modified";
public static final String HEADER_ETAG = "etag";
@@ -424,7 +426,7 @@ public final class LocalStorage {
String extStorage = Environment.getExternalStorageDirectory().getAbsolutePath();
List<File> storages = new ArrayList<File>();
storages.add(new File(extStorage));
- File file = new File("/system/etc/vold.fstab");
+ File file = new File(FILE_SYSTEM_TABLE_PATH);
if (file.canRead()) {
Reader fr = null;
BufferedReader br = null;
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
index a94b988..f61e523 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeOverlay.java
@@ -31,7 +31,7 @@ public class MapsforgeOverlay extends Overlay implements OverlayImpl {
overlayBase = new ScaleOverlay(activityIn, this);
break;
default:
- throw new IllegalArgumentException();
+ throw new IllegalStateException();
}
}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java
index bdaac98..8c9e0c3 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeOverlay.java
@@ -29,6 +29,9 @@ public class MapsforgeOverlay extends Overlay implements OverlayImpl {
break;
case ScaleOverlay:
overlayBase = new ScaleOverlay(activityIn, this);
+ break;
+ default:
+ throw new IllegalStateException();
}
}
diff --git a/main/src/cgeo/geocaching/ui/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
index be02eab..017eb51 100644
--- a/main/src/cgeo/geocaching/ui/CacheListAdapter.java
+++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java
@@ -517,6 +517,7 @@ public class CacheListAdapter extends ArrayAdapter<Geocache> {
@Override
public void onClick(View view) {
+ assert view instanceof CheckBox;
final boolean checkNow = ((CheckBox) view).isChecked();
cache.setStatusChecked(checkNow);
}
diff --git a/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java b/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java
index afadb33..299256c 100644
--- a/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java
+++ b/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java
@@ -9,7 +9,7 @@ import android.widget.TextView;
/**
* view click listener to automatically switch different coordinate formats
- *
+ *
*/
public class CoordinatesFormatSwitcher implements OnClickListener {
@@ -29,6 +29,7 @@ public class CoordinatesFormatSwitcher implements OnClickListener {
@Override
public void onClick(View view) {
+ assert view instanceof TextView;
position = (position + 1) % availableFormats.length;
TextView textView = (TextView) view;
// rotate coordinate formats on click
diff --git a/main/src/cgeo/geocaching/ui/ImagesList.java b/main/src/cgeo/geocaching/ui/ImagesList.java
index 9cca5b5..4eaf06d 100644
--- a/main/src/cgeo/geocaching/ui/ImagesList.java
+++ b/main/src/cgeo/geocaching/ui/ImagesList.java
@@ -156,6 +156,7 @@ public class ImagesList {
}
public void onCreateContextMenu(ContextMenu menu, View v) {
+ assert v instanceof ImageView;
activity.getMenuInflater().inflate(R.menu.images_list_context, menu);
final Resources res = activity.getResources();
menu.setHeaderTitle(res.getString(R.string.cache_image));
diff --git a/main/src/cgeo/geocaching/ui/LoggingUI.java b/main/src/cgeo/geocaching/ui/LoggingUI.java
index 1423da2..30c719e 100644
--- a/main/src/cgeo/geocaching/ui/LoggingUI.java
+++ b/main/src/cgeo/geocaching/ui/LoggingUI.java
@@ -105,6 +105,8 @@ public class LoggingUI extends AbstractUIFactory {
case CLEAR_LOG:
cache.clearOfflineLog();
break;
+ default:
+ throw new IllegalStateException();
}
} else {
cache.logOffline(activity, logTypeEntry.logType);
diff --git a/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java b/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java
index 91ce7e3..00d4c1a 100644
--- a/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java
+++ b/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java
@@ -3,13 +3,13 @@ package cgeo.geocaching.ui.dialog;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.IGeoData;
import cgeo.geocaching.R;
-import cgeo.geocaching.settings.Settings;
-import cgeo.geocaching.settings.Settings.CoordInputFormatEnum;
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.compatibility.Compatibility;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.GeopointFormatter;
+import cgeo.geocaching.settings.Settings;
+import cgeo.geocaching.settings.Settings.CoordInputFormatEnum;
import org.apache.commons.lang3.StringUtils;
@@ -216,6 +216,8 @@ public class CoordinatesInputDialog extends NoTitleDialog {
eLonSec.setText(addZeros(gp.getLonSec(), 2));
eLonSub.setText(addZeros(gp.getLonSecFrac(), 3));
break;
+ default:
+ throw new IllegalStateException();
}
}
@@ -227,6 +229,7 @@ public class CoordinatesInputDialog extends NoTitleDialog {
@Override
public void onClick(View view) {
+ assert view instanceof Button;
final Button button = (Button) view;
final CharSequence text = button.getText();
if (StringUtils.isBlank(text)) {