diff options
Diffstat (limited to 'main/src/cgeo/geocaching/NavigateAnyPointActivity.java')
| -rw-r--r-- | main/src/cgeo/geocaching/NavigateAnyPointActivity.java | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/main/src/cgeo/geocaching/NavigateAnyPointActivity.java b/main/src/cgeo/geocaching/NavigateAnyPointActivity.java index 741414b..d0733e5 100644 --- a/main/src/cgeo/geocaching/NavigateAnyPointActivity.java +++ b/main/src/cgeo/geocaching/NavigateAnyPointActivity.java @@ -1,6 +1,7 @@ package cgeo.geocaching; import butterknife.InjectView; +import butterknife.Optional; import butterknife.Views; import cgeo.geocaching.activity.AbstractActivity; @@ -43,13 +44,15 @@ import java.util.List; public class NavigateAnyPointActivity extends AbstractActivity { - @InjectView(R.id.buttonLatitude) protected Button latButton; - @InjectView(R.id.buttonLongitude) protected Button lonButton; - @InjectView(R.id.current) protected Button buttonCurrent; @InjectView(R.id.historyList) protected ListView historyListView; - @InjectView(R.id.distanceUnit) protected Spinner distanceUnitSelector; - @InjectView(R.id.bearing) protected EditText bearingEditText; - @InjectView(R.id.distance) protected EditText distanceEditText; + + // list header fields are optional, due to being expanded later than the list itself + @Optional @InjectView(R.id.buttonLatitude) protected Button latButton; + @Optional @InjectView(R.id.buttonLongitude) protected Button lonButton; + @Optional @InjectView(R.id.distance) protected EditText distanceEditText; + @Optional @InjectView(R.id.distanceUnit) protected Spinner distanceUnitSelector; + @Optional @InjectView(R.id.current) protected Button buttonCurrent; + @Optional @InjectView(R.id.bearing) protected EditText bearingEditText; private boolean changed = false; private List<Destination> historyOfSearchedLocations; @@ -214,7 +217,7 @@ public class NavigateAnyPointActivity extends AbstractActivity { private List<Destination> getHistoryOfSearchedLocations() { if (historyOfSearchedLocations == null) { // Load from database - historyOfSearchedLocations = cgData.loadHistoryOfSearchedLocations(); + historyOfSearchedLocations = DataStore.loadHistoryOfSearchedLocations(); } return historyOfSearchedLocations; @@ -331,7 +334,7 @@ public class NavigateAnyPointActivity extends AbstractActivity { menu.findItem(R.id.menu_caches_around).setVisible(visible); menu.findItem(R.id.menu_clear_history).setEnabled(!getHistoryOfSearchedLocations().isEmpty()); - } catch (Exception e) { + } catch (RuntimeException e) { // nothing } @@ -377,7 +380,7 @@ public class NavigateAnyPointActivity extends AbstractActivity { getHistoryOfSearchedLocations().add(0, loc); // Save location - cgData.saveSearchedDestination(loc); + DataStore.saveSearchedDestination(loc); // Ensure to remove the footer historyListView.removeFooterView(getEmptyHistoryFooter()); @@ -396,7 +399,7 @@ public class NavigateAnyPointActivity extends AbstractActivity { getHistoryOfSearchedLocations().remove(destination); // Save - cgData.removeSearchedDestination(destination); + DataStore.removeSearchedDestination(destination); if (getHistoryOfSearchedLocations().isEmpty()) { if (historyListView.getFooterViewsCount() == 0) { @@ -415,7 +418,7 @@ public class NavigateAnyPointActivity extends AbstractActivity { getHistoryOfSearchedLocations().clear(); // Save - cgData.clearSearchedDestinations(); + DataStore.clearSearchedDestinations(); if (historyListView.getFooterViewsCount() == 0) { historyListView.addFooterView(getEmptyHistoryFooter()); @@ -443,7 +446,7 @@ public class NavigateAnyPointActivity extends AbstractActivity { return; } - cgeocaches.startActivityCoordinates(this, coords); + CacheListActivity.startActivityCoordinates(this, coords); finish(); } @@ -454,7 +457,7 @@ public class NavigateAnyPointActivity extends AbstractActivity { try { latButton.setHint(geo.getCoords().format(GeopointFormatter.Format.LAT_DECMINUTE_RAW)); lonButton.setHint(geo.getCoords().format(GeopointFormatter.Format.LON_DECMINUTE_RAW)); - } catch (final Exception e) { + } catch (final RuntimeException e) { Log.w("Failed to update location."); } } |
