forked from upstream-mirrors/OpenTracks
Fixing issue 35 - detecting errors during "export all".
This commit is contained in:
@@ -17,6 +17,7 @@ package com.google.android.apps.mytracks;
|
|||||||
|
|
||||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||||
|
import com.google.android.apps.mytracks.io.TrackWriter;
|
||||||
import com.google.android.apps.mytracks.io.TrackWriterFactory;
|
import com.google.android.apps.mytracks.io.TrackWriterFactory;
|
||||||
import com.google.android.apps.mytracks.io.TrackWriterFactory.TrackFileFormat;
|
import com.google.android.apps.mytracks.io.TrackWriterFactory.TrackFileFormat;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
@@ -154,6 +155,7 @@ public class ExportAllTracks {
|
|||||||
if (cursor == null) {
|
if (cursor == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int trackCount = cursor.getCount();
|
final int trackCount = cursor.getCount();
|
||||||
Log.i(MyTracksConstants.TAG,
|
Log.i(MyTracksConstants.TAG,
|
||||||
"ExportAllTracks: Exporting: " + cursor.getCount() + " tracks.");
|
"ExportAllTracks: Exporting: " + cursor.getCount() + " tracks.");
|
||||||
@@ -161,7 +163,9 @@ public class ExportAllTracks {
|
|||||||
MyTracks.getInstance().runOnUiThread(new Runnable() {
|
MyTracks.getInstance().runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
makeProgressDialog(trackCount);
|
makeProgressDialog(trackCount);
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
for (int i = 0; cursor.moveToNext(); i++) {
|
for (int i = 0; cursor.moveToNext(); i++) {
|
||||||
final int status = i;
|
final int status = i;
|
||||||
MyTracks.getInstance().runOnUiThread(new Runnable() {
|
MyTracks.getInstance().runOnUiThread(new Runnable() {
|
||||||
@@ -177,16 +181,27 @@ public class ExportAllTracks {
|
|||||||
|
|
||||||
long id = cursor.getLong(idxTrackId);
|
long id = cursor.getLong(idxTrackId);
|
||||||
Log.i(MyTracksConstants.TAG, "ExportAllTracks: exporting: " + id);
|
Log.i(MyTracksConstants.TAG, "ExportAllTracks: exporting: " + id);
|
||||||
TrackWriterFactory.newWriter(context, providerUtils, id, format)
|
TrackWriter writer =
|
||||||
.writeTrack();
|
TrackWriterFactory.newWriter(context, providerUtils, id, format);
|
||||||
|
writer.writeTrack();
|
||||||
|
|
||||||
|
if (!writer.wasSuccess()) {
|
||||||
|
// Abort the whole export on the first error.
|
||||||
|
int error = writer.getErrorMessage();
|
||||||
|
Toast.makeText(context, error, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
if (progress != null) {
|
||||||
if (progress != null) {
|
synchronized (this) {
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
|
progress = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user