null check on vibration invocation & track size check
This commit is contained in:
parent
40a96a0bb4
commit
df8e5ef0fd
2 changed files with 4 additions and 2 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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());
|
||||||
|
|
Loading…
Reference in a new issue