Fix several crashes

This commit is contained in:
Vitaliy 2021-02-08 15:24:54 +02:00
parent 45539461c2
commit 5f98962573
7 changed files with 19 additions and 12 deletions

View file

@ -8,10 +8,10 @@ import androidx.annotation.Nullable;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.plus.track.GpxSplitType;
import net.osmand.GPXUtilities.GPXTrackAnalysis;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.track.GpxSplitType;
import net.osmand.plus.track.GradientScaleType;
import java.io.File;
@ -238,7 +238,7 @@ public class GpxDbHelper {
gpxFile = readingItems.poll();
while (gpxFile != null && !isCancelled()) {
GpxDataItem item = readingItemsMap.remove(gpxFile);
if (item.getFile() == null) {
if (item != null && item.getFile() == null) {
item = db.getItem(gpxFile, conn);
}
if (isAnalyseNeeded(gpxFile, item)) {

View file

@ -257,7 +257,7 @@ public class IntentHelper {
if (intent.hasExtra(TrackMenuFragment.OPEN_TRACK_MENU)) {
String path = intent.getStringExtra(TRACK_FILE_NAME);
boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false);
TrackMenuFragment.showInstance(mapActivity, path, currentRecording);
TrackMenuFragment.showInstance(mapActivity, path, currentRecording, null);
mapActivity.setIntent(null);
}
}

View file

@ -1257,7 +1257,9 @@ public class MenuBuilder {
controller.setOnBackButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mapContextMenu.show();
if (mapContextMenu != null) {
mapContextMenu.show();
}
}
});
controller.setOnTitleClickListener(new OnClickListener() {

View file

@ -45,7 +45,9 @@ public class SelectedGpxMenuController extends MenuController {
mapContextMenu.hide(false);
WptPt wptPt = selectedGpxPoint.selectedPoint;
LatLon latLon = new LatLon(wptPt.lat, wptPt.lon);
TrackMenuFragment.showInstance(mapActivity, selectedGpxPoint.getSelectedGpxFile(), latLon);
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
String path = selectedGpxFile.getGpxFile().path;
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), latLon);
}
};
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);

View file

@ -1236,11 +1236,10 @@ public class MapMarkersHelper {
removeGroupActiveMarkers(group, true);
return;
}
for (FavouritePoint fp : favGroup.getPoints()) {
List<FavouritePoint> points = new ArrayList<>(favGroup.getPoints());
for (FavouritePoint fp : points) {
addNewMarkerIfNeeded(group, groupMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), fp, null);
}
} else if (group.getType() == MapMarkersGroup.GPX_TYPE) {
GpxSelectionHelper gpxHelper = ctx.getSelectedGpxHelper();
File file = new File(group.getId());

View file

@ -7,6 +7,7 @@ import android.os.AsyncTask;
import android.view.ViewGroup;
import com.github.scribejava.core.builder.api.DefaultApi10a;
import com.github.scribejava.core.exceptions.OAuthException;
import com.github.scribejava.core.model.OAuth1AccessToken;
import com.github.scribejava.core.model.OAuth1RequestToken;
import com.github.scribejava.core.model.OAuthAsyncRequestCallback;
@ -171,6 +172,8 @@ public class OsmOAuthAuthorizationAdapter {
log.error(e);
} catch (XmlPullParserException e) {
log.error(e);
} catch (OAuthException e) {
log.error(e);
}
app.getSettings().OSM_USER_DISPLAY_NAME.set(userName);
}

View file

@ -1099,7 +1099,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
boolean currentRecording = file == null;
String path = file != null ? file.getAbsolutePath() : null;
if (context instanceof MapActivity) {
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording);
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null);
} else {
Bundle bundle = new Bundle();
bundle.putString(TRACK_FILE_NAME, path);
@ -1109,7 +1109,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
}
}
public static void showInstance(@NonNull final MapActivity mapActivity, @Nullable String path, boolean showCurrentTrack) {
public static void showInstance(@NonNull final MapActivity mapActivity, @Nullable String path,
boolean showCurrentTrack, @Nullable final LatLon latLon) {
OsmandApplication app = mapActivity.getMyApplication();
SelectedGpxFile selectedGpxFile;
if (showCurrentTrack) {
@ -1118,7 +1119,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(path);
}
if (selectedGpxFile != null) {
showInstance(mapActivity, selectedGpxFile, null);
showInstance(mapActivity, selectedGpxFile, latLon);
} else if (!Algorithms.isEmpty(path)) {
String title = app.getString(R.string.loading_smth, "");
final ProgressDialog progress = ProgressDialog.show(mapActivity, title, app.getString(R.string.loading_data));
@ -1132,7 +1133,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
OsmandApplication app = mapActivity.getMyApplication();
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false);
if (selectedGpxFile != null) {
showInstance(mapActivity, selectedGpxFile, null);
showInstance(mapActivity, selectedGpxFile, latLon);
}
}
if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) {