null check on vibration invocation & track size check

This commit is contained in:
y20k 2018-11-28 09:21:10 +01:00
parent 40a96a0bb4
commit df8e5ef0fd
2 changed files with 4 additions and 2 deletions

View file

@ -721,9 +721,11 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
Toast.makeText(this, stringResource, Toast.LENGTH_LONG).show(); Toast.makeText(this, stringResource, Toast.LENGTH_LONG).show();
// vibrate 50 milliseconds // vibrate 50 milliseconds
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
v.vibrate(50); v.vibrate(50);
// v.vibrate(VibrationEffect.createOneShot(50, DEFAULT_AMPLITUDE)); // todo check if there is a support library vibrator // v.vibrate(VibrationEffect.createOneShot(50, DEFAULT_AMPLITUDE)); // todo check if there is a support library vibrator
} }
}

View file

@ -362,7 +362,7 @@ public class MainActivityTrackFragment extends Fragment implements AdapterView.O
private void displayTrack() { private void displayTrack() {
GeoPoint position; GeoPoint position;
if (mTrack != null) { if (mTrack != null && mTrack.getSize() > 0) {
// set end of track as position // set end of track as position
Location lastLocation = mTrack.getWayPointLocation(mTrack.getSize() -1); Location lastLocation = mTrack.getWayPointLocation(mTrack.getSize() -1);
position = new GeoPoint(lastLocation.getLatitude(), lastLocation.getLongitude()); position = new GeoPoint(lastLocation.getLatitude(), lastLocation.getLongitude());