forked from upstream-mirrors/OpenTracks
fix null pointer error when cannot open a sd card file
This commit is contained in:
@@ -132,7 +132,7 @@ public class SaveActivity extends Activity {
|
|||||||
})
|
})
|
||||||
.setTitle(success ? R.string.generic_success_title : R.string.generic_error_title);
|
.setTitle(success ? R.string.generic_success_title : R.string.generic_error_title);
|
||||||
|
|
||||||
if (success && trackId != -1L && !playTrack) {
|
if (success && trackId != -1L && !playTrack && savedPath != null) {
|
||||||
builder.setNegativeButton(
|
builder.setNegativeButton(
|
||||||
R.string.share_track_share_file, new DialogInterface.OnClickListener() {
|
R.string.share_track_share_file, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -191,7 +191,7 @@ public class SaveActivity extends Activity {
|
|||||||
* To be invoked after showing the result dialog.
|
* To be invoked after showing the result dialog.
|
||||||
*/
|
*/
|
||||||
private void onPostResultDialog() {
|
private void onPostResultDialog() {
|
||||||
if (success && playTrack) {
|
if (success && playTrack && savedPath != null) {
|
||||||
Intent intent = new Intent()
|
Intent intent = new Intent()
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
.putExtra(GOOGLE_EARTH_TOUR_FEATURE_ID, KmlTrackWriter.TOUR_FEATURE_ID)
|
.putExtra(GOOGLE_EARTH_TOUR_FEATURE_ID, KmlTrackWriter.TOUR_FEATURE_ID)
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class TrackWriterImpl implements TrackWriter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAbsolutePath() {
|
public String getAbsolutePath() {
|
||||||
return file.getAbsolutePath();
|
return file == null ? null : file.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeTrackAsync() {
|
private void writeTrackAsync() {
|
||||||
@@ -112,10 +112,8 @@ class TrackWriterImpl implements TrackWriter {
|
|||||||
writeDocument();
|
writeDocument();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.i(Constants.TAG, "The track write was interrupted");
|
Log.i(Constants.TAG, "The track write was interrupted");
|
||||||
if (file != null) {
|
if (file != null && !file.delete()) {
|
||||||
if (!file.delete()) {
|
Log.w(TAG, "Failed to delete file " + file.getAbsolutePath());
|
||||||
Log.w(TAG, "Failed to delete file " + file.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
success = false;
|
success = false;
|
||||||
errorMessage = R.string.external_storage_canceled;
|
errorMessage = R.string.external_storage_canceled;
|
||||||
|
|||||||
Reference in New Issue
Block a user