From b2475f84740f02a62a2d45eb65182f346bc6be21 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 10 Mar 2012 12:11:11 -0500 Subject: [PATCH] Updated onLocationChanged() to be synchronous and tweaked the waypoit algorithm. Change-Id: I1e29bfa072239dca7e4592f1de4db8e65537da73 Signed-off-by: Ricky Barrette --- .../android/IOIOTruck/NavigationActivity.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/IOIOTruck/src/com/TwentyCodes/android/IOIOTruck/NavigationActivity.java b/IOIOTruck/src/com/TwentyCodes/android/IOIOTruck/NavigationActivity.java index 154ad6a..b023d3f 100644 --- a/IOIOTruck/src/com/TwentyCodes/android/IOIOTruck/NavigationActivity.java +++ b/IOIOTruck/src/com/TwentyCodes/android/IOIOTruck/NavigationActivity.java @@ -280,7 +280,7 @@ public class NavigationActivity extends FragmentActivity implements CompassListe * @see com.TwentyCodes.android.location.GeoPointLocationListener#onLocationChanged(com.google.android.maps.GeoPoint, int) */ @Override - public void onLocationChanged(GeoPoint point, int accuracy) { + public synchronized void onLocationChanged(GeoPoint point, int accuracy) { mLast = System.currentTimeMillis(); mAccuracyTextView.setText(accuracy+getString(R.string.m)); @@ -301,18 +301,22 @@ public class NavigationActivity extends FragmentActivity implements CompassListe /* * if ther points list is null, or there are no more points */ - if(mPoints == null || mIndex == mPoints.size()+1){ + if(mPoints == null || mIndex == mPoints.size()){ mIOIOManager.setDriveValue(IOIOTruckValues.DRIVE_STOP); updateGoButton(true); updateLog(R.string.dest_reached); } else { mIndex ++; - if(mIndex <= mPoints.size()) { - updateLog("last Waypoint reached, moving to dest"); + /* + * if there are more waypoints, then move on to the next + * otherwise move on to the dest + */ + if(mIndex < mPoints.size()) { + updateLog("Waypoint reached, moving to next"); mPoint = mPoints.get(mIndex); } else { - updateLog("Waypoint reached, moving to next"); + updateLog("last Waypoint reached, moving to dest"); mPoint = mDestPoint; }