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,8 +721,10 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
|
|||
Toast.makeText(this, stringResource, Toast.LENGTH_LONG).show();
|
||||
// vibrate 50 milliseconds
|
||||
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
v.vibrate(50);
|
||||
if (v != null) {
|
||||
v.vibrate(50);
|
||||
// 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() {
|
||||
GeoPoint position;
|
||||
|
||||
if (mTrack != null) {
|
||||
if (mTrack != null && mTrack.getSize() > 0) {
|
||||
// set end of track as position
|
||||
Location lastLocation = mTrack.getWayPointLocation(mTrack.getSize() -1);
|
||||
position = new GeoPoint(lastLocation.getLatitude(), lastLocation.getLongitude());
|
||||
|
|
Loading…
Reference in a new issue