catches a crash that could happen when a location fix was acquired too slow (see #3)
This commit is contained in:
parent
403cb3f134
commit
60a5ba5b5a
5 changed files with 43 additions and 22 deletions
|
@ -26,5 +26,5 @@ dependencies {
|
||||||
compile 'com.android.support:appcompat-v7:24.2.1'
|
compile 'com.android.support:appcompat-v7:24.2.1'
|
||||||
compile 'com.android.support:design:24.2.1'
|
compile 'com.android.support:design:24.2.1'
|
||||||
compile 'org.osmdroid:osmdroid-android:5.2@aar'
|
compile 'org.osmdroid:osmdroid-android:5.2@aar'
|
||||||
compile 'com.google.code.gson:gson:2.4'
|
compile 'com.google.code.gson:gson:2.7'
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,11 +361,19 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
|
||||||
// get last location from MainActivity Fragment
|
// get last location from MainActivity Fragment
|
||||||
Location lastLocation = mMainActivityMapFragment.getCurrentBestLocation();
|
Location lastLocation = mMainActivityMapFragment.getCurrentBestLocation();
|
||||||
|
|
||||||
|
if (lastLocation != null) {
|
||||||
// start tracker service
|
// start tracker service
|
||||||
Intent intent = new Intent(this, TrackerService.class);
|
Intent intent = new Intent(this, TrackerService.class);
|
||||||
intent.setAction(ACTION_START);
|
intent.setAction(ACTION_START);
|
||||||
intent.putExtra(EXTRA_LAST_LOCATION, lastLocation);
|
intent.putExtra(EXTRA_LAST_LOCATION, lastLocation);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, getString(R.string.toast_message_location_services_not_ready), Toast.LENGTH_LONG).show();
|
||||||
|
// change state back
|
||||||
|
mTrackerServiceRunning = false;
|
||||||
|
setFloatingActionButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update tracking state in MainActivityMapFragment
|
// update tracking state in MainActivityMapFragment
|
||||||
|
|
|
@ -299,6 +299,10 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
||||||
// app does not have any location fix
|
// app does not have any location fix
|
||||||
mCurrentBestLocation = LocationHelper.determineLastKnownLocation(mLocationManager);
|
mCurrentBestLocation = LocationHelper.determineLastKnownLocation(mLocationManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// check if really got a position
|
||||||
|
if (mCurrentBestLocation != null) {
|
||||||
position = convertToGeoPoint(mCurrentBestLocation);
|
position = convertToGeoPoint(mCurrentBestLocation);
|
||||||
|
|
||||||
// center map on current position
|
// center map on current position
|
||||||
|
@ -316,8 +320,14 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
||||||
}
|
}
|
||||||
locationInfo = " " + locationAgeString + " | " + mCurrentBestLocation.getProvider();
|
locationInfo = " " + locationAgeString + " | " + mCurrentBestLocation.getProvider();
|
||||||
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_last_location) + locationInfo, Toast.LENGTH_LONG).show();
|
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_last_location) + locationInfo, Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_location_services_not_ready), Toast.LENGTH_LONG).show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CASE DEFAULT
|
// CASE DEFAULT
|
||||||
default:
|
default:
|
||||||
|
@ -374,6 +384,7 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
|
||||||
|
|
||||||
/* Removes track crumbs from map */
|
/* Removes track crumbs from map */
|
||||||
public void clearMap() {
|
public void clearMap() {
|
||||||
|
// TODO clear map or clear intent
|
||||||
if (mTrackOverlay != null) {
|
if (mTrackOverlay != null) {
|
||||||
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_clear_map), Toast.LENGTH_LONG).show();
|
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_clear_map), Toast.LENGTH_LONG).show();
|
||||||
mMapView.getOverlays().remove(mTrackOverlay);
|
mMapView.getOverlays().remove(mTrackOverlay);
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
<string name="tab_last_track">LETZTE AUFZEICHNUNG</string>
|
<string name="tab_last_track">LETZTE AUFZEICHNUNG</string>
|
||||||
|
|
||||||
<!-- notification -->
|
<!-- notification -->
|
||||||
<string name="notification_title_trackbook_not_running">Trackbook ist aktiv</string>
|
<string name="notification_title_trackbook_not_running">Trackbook ist inaktiv</string>
|
||||||
<string name="notification_title_trackbook_running">Trackbook ist inaktiv</string>
|
<string name="notification_title_trackbook_running">Trackbook ist aktiv</string>
|
||||||
<string name="notification_stop">Stopp</string>
|
<string name="notification_stop">Stopp</string>
|
||||||
<string name="notification_swipe_to_clear_map">(Ausblenden setzt Kartenansicht zurück)</string>
|
<string name="notification_swipe_to_clear_map">(Ausblenden setzt Kartenansicht zurück)</string>
|
||||||
<string name="notification_content_duration">Dauer</string>
|
<string name="notification_content_duration">Dauer</string>
|
||||||
|
@ -34,6 +34,7 @@
|
||||||
<string name="toast_message_no_external_storage">Zugriff auf den externen Speicher verweigert.</string>
|
<string name="toast_message_no_external_storage">Zugriff auf den externen Speicher verweigert.</string>
|
||||||
<string name="toast_message_location_offline">Standortdienste sind deaktiviert. Trackbook kann nicht aufzeichnen.</string>
|
<string name="toast_message_location_offline">Standortdienste sind deaktiviert. Trackbook kann nicht aufzeichnen.</string>
|
||||||
<string name="toast_message_acquiring_location">Suche aktuellen Standort.</string>
|
<string name="toast_message_acquiring_location">Suche aktuellen Standort.</string>
|
||||||
|
<string name="toast_message_location_services_not_ready">Standortdienste noch nicht bereit. Bitte erneut versuchen.</string>
|
||||||
<string name="toast_message_last_location">Letzte Position:</string>
|
<string name="toast_message_last_location">Letzte Position:</string>
|
||||||
<string name="toast_message_clear_map">Kartenansicht wird zurückgesetzt</string>
|
<string name="toast_message_clear_map">Kartenansicht wird zurückgesetzt</string>
|
||||||
<string name="toast_message_last_location_age_one_hour">über eine Stunde</string>
|
<string name="toast_message_last_location_age_one_hour">über eine Stunde</string>
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
<string name="toast_message_no_external_storage">Unable to access external storage.</string>
|
<string name="toast_message_no_external_storage">Unable to access external storage.</string>
|
||||||
<string name="toast_message_location_offline">Location is turned off. Trackbook will not work.</string>
|
<string name="toast_message_location_offline">Location is turned off. Trackbook will not work.</string>
|
||||||
<string name="toast_message_acquiring_location">Acquiring current location.</string>
|
<string name="toast_message_acquiring_location">Acquiring current location.</string>
|
||||||
|
<string name="toast_message_location_services_not_ready">Location services not ready. Please retry.</string>
|
||||||
<string name="toast_message_last_location">Last location:</string>
|
<string name="toast_message_last_location">Last location:</string>
|
||||||
<string name="toast_message_clear_map">Clearing map.</string>
|
<string name="toast_message_clear_map">Clearing map.</string>
|
||||||
<string name="toast_message_last_location_age_one_hour">over one hour</string>
|
<string name="toast_message_last_location_age_one_hour">over one hour</string>
|
||||||
|
|
Loading…
Reference in a new issue