private boolean uploadAllTrackPoints(Fusiontables fusiontables,String tableId,Track track) throws IOException {
  int numberOfPoints=track.getNumberOfPoints();
  List<Location> locations=new ArrayList<Location>(MAX_POINTS_PER_UPLOAD);
  Location lastValidLocation=null;
  boolean sentStartMarker=false;
  int readCount=0;
  LocationIterator locationIterator=null;
  try {
    locationIterator=myTracksProviderUtils.getTrackPointLocationIterator(trackId,-1L,false,MyTracksProviderUtils.DEFAULT_LOCATION_FACTORY);
    while (locationIterator.hasNext()) {
      Location location=locationIterator.next();
      locations.add(location);
      if (LocationUtils.isValidLocation(location)) {
        lastValidLocation=location;
      }
      if (!sentStartMarker && lastValidLocation != null) {
        String name=context.getString(R.string.marker_label_start,track.getName());
        createNewPoint(fusiontables,tableId,name,"",lastValidLocation,MARKER_TYPE_START);
        sentStartMarker=true;
      }
      readCount++;
      if (readCount % MAX_POINTS_PER_UPLOAD == 0) {
        if (!prepareAndUploadPoints(fusiontables,tableId,track,locations,false)) {
          Log.d(TAG,"Unable to upload points");
          return false;
        }
        updateProgress(readCount,numberOfPoints);
        locations.clear();
      }
    }
    if (!prepareAndUploadPoints(fusiontables,tableId,track,locations,true)) {
      Log.d(TAG,"Unable to upload points");
      return false;
    }
    if (lastValidLocation != null) {
      String name=context.getString(R.string.marker_label_end,track.getName());
      DescriptionGenerator descriptionGenerator=new DescriptionGeneratorImpl(context);
      String description=descriptionGenerator.generateTrackDescription(track,null,null,true);
      createNewPoint(fusiontables,tableId,name,description,lastValidLocation,MARKER_TYPE_END);
    }
    return true;
  }
  finally {
    if (locationIterator != null) {
      locationIterator.close();
    }
  }
}

private boolean uploadAllTrackPoints ( Fusiontables fusiontables , String tableId , Track track ) throws IOException { int numberOfPoints = track . getNumberOfPoints ( ) ; List < Location > locations = new ArrayList < Location > ( MAX_POINTS_PER_UPLOAD ) ; Location lastValidLocation = null ; boolean sentStartMarker = false ; int readCount = 0 ; LocationIterator locationIterator = null ; try { locationIterator = myTracksProviderUtils . getTrackPointLocationIterator ( trackId , - 1L , false , MyTracksProviderUtils . DEFAULT_LOCATION_FACTORY ) ; while ( locationIterator . hasNext ( ) ) { Location location = locationIterator . next ( ) ; locations . add ( location ) ; if ( LocationUtils . isValidLocation ( location ) ) { lastValidLocation = location ; } if ( ! sentStartMarker && lastValidLocation != null ) { String name = context . getString ( R . string . marker_label_start , track . getName ( ) ) ; createNewPoint ( fusiontables , tableId , name , "" , lastValidLocation , MARKER_TYPE_START ) ; sentStartMarker = true ; } readCount ++ ; if ( readCount % MAX_POINTS_PER_UPLOAD == 0 ) { if ( ! prepareAndUploadPoints ( fusiontables , tableId , track , locations , false ) ) { Log . d ( TAG , "Unable to upload points" ) ; return false ; } updateProgress ( readCount , numberOfPoints ) ; locations . clear ( ) ; } } if ( ! prepareAndUploadPoints ( fusiontables , tableId , track , locations , true ) ) { Log . d ( TAG , "Unable to upload points" ) ; return false ; } if ( lastValidLocation != null ) { String name = context . getString ( R . string . marker_label_end , track . getName ( ) ) ; DescriptionGenerator descriptionGenerator = new DescriptionGeneratorImpl ( context ) ; String description = descriptionGenerator . generateTrackDescription ( track , null , null , true ) ; createNewPoint ( fusiontables , tableId , name , description , lastValidLocation , MARKER_TYPE_END ) ; } return true ; } finally { if ( locationIterator != null ) { locationIterator . close ( ) ; } } }
uploads all the points in a track .
