Add check for import error

This commit is contained in:
madwasp79 2019-03-05 10:56:40 +02:00
parent 62848ac1d6
commit d299c0d93d

View file

@ -20,11 +20,9 @@ import android.support.v7.app.AppCompatActivity;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import net.osmand.GPXUtilities.GPXTrackAnalysis;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
@ -61,7 +59,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -561,7 +558,7 @@ public class ImportHelper {
if (save) {
new SaveAsyncTask(result, name, useImportDir).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
showGpxOnMap(result);
showGpxInDetailsActivity(result);
}
if (gpxImportCompleteListener != null) {
gpxImportCompleteListener.onComplete(true);
@ -668,13 +665,12 @@ public class ImportHelper {
@Override
protected void onPostExecute(final String warning) {
final String msg = warning == null ? MessageFormat.format(app.getString(R.string.gpx_saved_sucessfully), result.path) : warning;
//Toast.makeText(activity, msg, Toast.LENGTH_LONG).show();
//showGpxOnMap(result);
showGpxDetailsActivity(result);
if(Algorithms.isEmpty(warning)) {
showGpxInDetailsActivity(result);
} else {
Toast.makeText(activity, warning, Toast.LENGTH_LONG).show();
}
}
}
private MapActivity getMapActivity() {
@ -685,6 +681,15 @@ public class ImportHelper {
}
}
private void showGpxInDetailsActivity(final GPXFile gpxFile) {
if (gpxFile.path != null) {
Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity());
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path);
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(newIntent);
}
}
private void showGpxOnMap(final GPXFile result) {
if (mapView != null && getMapActivity() != null) {
app.getSelectedGpxHelper().setGpxFileToDisplay(result);
@ -699,15 +704,6 @@ public class ImportHelper {
}
}
private void showGpxDetailsActivity(final GPXFile gpxFile) {
if (gpxFile.path != null) {
Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity());
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path);
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(newIntent);
}
}
private void importFavourites(final GPXFile gpxFile, final String fileName, final boolean save,
final boolean useImportDir, final boolean forceImportFavourites) {
if (gpxFile == null || gpxFile.isPointsEmpty()) {