Rename TrackWriter to TrackExporter

This commit is contained in:
Jimmy Shih
2013-08-27 17:41:45 -07:00
parent 415b0afe38
commit efddcc1dcf
4 changed files with 27 additions and 27 deletions
@@ -52,7 +52,7 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
private final MyTracksProviderUtils myTracksProviderUtils;
private WakeLock wakeLock;
private TrackWriter trackWriter;
private TrackExporter trackExporter;
// true if the AsyncTask has completed
private boolean completed;
@@ -163,8 +163,8 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
@Override
protected void onCancelled() {
if (trackWriter != null) {
trackWriter.stopWriteTrack();
if (trackExporter != null) {
trackExporter.stopWriteTrack();
}
}
@@ -186,8 +186,8 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
return false;
}
trackWriter = new TrackWriter(
context, myTracksProviderUtils, tracks, trackFileFormat, new TrackWriter.OnWriteListener() {
trackExporter = new TrackExporter(
context, myTracksProviderUtils, tracks, trackFileFormat, new TrackExporter.OnWriteListener() {
@Override
public void onWrite(int number, int max) {
/*
@@ -204,20 +204,20 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
try {
file = new File(directory, fileName);
OutputStream outputStream = new FileOutputStream(file);
trackWriter.writeTrack(outputStream);
trackExporter.writeTrack(outputStream);
} catch (FileNotFoundException e) {
Log.d(TAG, "File not found " + fileName, e);
return false;
}
if (trackWriter.wasSuccess()) {
if (trackExporter.wasSuccess()) {
savedPath = file.getAbsolutePath();
} else {
if (!file.delete()) {
Log.w(TAG, "Failed to delete file " + file.getAbsolutePath());
}
}
return trackWriter.wasSuccess();
return trackExporter.wasSuccess();
}
/**
@@ -38,7 +38,7 @@ import java.io.OutputStream;
* @author Sandor Dornbush
* @author Rodrigo Damazio
*/
public class TrackWriter {
public class TrackExporter {
/**
* Listener for when a track location is written.
@@ -55,7 +55,7 @@ public class TrackWriter {
public void onWrite(int number, int max);
}
private final static String TAG = TrackWriter.class.getSimpleName();
private final static String TAG = TrackExporter.class.getSimpleName();
private final MyTracksProviderUtils myTracksProviderUtils;
private final Track[] tracks;
@@ -74,13 +74,13 @@ public class TrackWriter {
* @param trackFileFormat the track file format
* @param onWriteListener the on write listener
*/
public TrackWriter(Context context, MyTracksProviderUtils myTracksProviderUtils, Track[] tracks,
public TrackExporter(Context context, MyTracksProviderUtils myTracksProviderUtils, Track[] tracks,
TrackFileFormat trackFileFormat, OnWriteListener onWriteListener) {
this(myTracksProviderUtils, tracks, trackFileFormat.newFormatWriter(context), onWriteListener);
}
@VisibleForTesting
public TrackWriter(MyTracksProviderUtils myTracksProviderUtils, Track[] tracks,
public TrackExporter(MyTracksProviderUtils myTracksProviderUtils, Track[] tracks,
TrackFormatWriter trackFormatWriter, OnWriteListener onWriteListener) {
this.myTracksProviderUtils = myTracksProviderUtils;
this.tracks = tracks;
@@ -21,7 +21,7 @@ import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.TracksColumns;
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
import com.google.android.apps.mytracks.io.file.TrackWriter;
import com.google.android.apps.mytracks.io.file.TrackExporter;
import com.google.android.apps.mytracks.util.FileUtils;
import com.google.android.apps.mytracks.util.PreferencesUtils;
import com.google.android.maps.mytracks.R;
@@ -441,11 +441,11 @@ public class SyncUtils {
java.io.File file = new java.io.File(directory,
FileUtils.buildUniqueFileName(directory, track.getName(), trackFileFormat.getExtension()));
TrackWriter trackWriter = new TrackWriter(
TrackExporter trackExporter = new TrackExporter(
context, myTracksProviderUtils, new Track[] {track}, trackFileFormat, null);
trackWriter.writeTrack(new FileOutputStream(file));
if (trackWriter.wasSuccess()) {
trackExporter.writeTrack(new FileOutputStream(file));
if (trackExporter.wasSuccess()) {
return file;
}
Log.d(TAG, "Unable to get file for track " + track.getName());