Updated onLocationChanged() to be synchronous and tweaked the waypoit

algorithm.

Change-Id: I1e29bfa072239dca7e4592f1de4db8e65537da73
Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-03-10 12:11:11 -05:00
parent 9174336fc9
commit b2475f8474

View File

@@ -280,7 +280,7 @@ public class NavigationActivity extends FragmentActivity implements CompassListe
* @see com.TwentyCodes.android.location.GeoPointLocationListener#onLocationChanged(com.google.android.maps.GeoPoint, int) * @see com.TwentyCodes.android.location.GeoPointLocationListener#onLocationChanged(com.google.android.maps.GeoPoint, int)
*/ */
@Override @Override
public void onLocationChanged(GeoPoint point, int accuracy) { public synchronized void onLocationChanged(GeoPoint point, int accuracy) {
mLast = System.currentTimeMillis(); mLast = System.currentTimeMillis();
mAccuracyTextView.setText(accuracy+getString(R.string.m)); 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 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); mIOIOManager.setDriveValue(IOIOTruckValues.DRIVE_STOP);
updateGoButton(true); updateGoButton(true);
updateLog(R.string.dest_reached); updateLog(R.string.dest_reached);
} else { } else {
mIndex ++; 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); mPoint = mPoints.get(mIndex);
} else { } else {
updateLog("Waypoint reached, moving to next"); updateLog("last Waypoint reached, moving to dest");
mPoint = mDestPoint; mPoint = mDestPoint;
} }