Merge pull request #4219 from osmandapp/npe_track_segment_fragment

Fix NPE in track segment
This commit is contained in:
Alexey 2017-07-28 12:26:05 +03:00 committed by GitHub
commit 4e6a8f0e61

View file

@ -278,14 +278,24 @@ public class TrackSegmentFragment extends OsmAndListFragment {
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
WptPt pointToShow = getGpx() != null ? getGpx().findPointToShow() : null;
GpxDataItem gpxDataItem = getGpxDataItem();
GPXFile gpx = getGpx();
WptPt pointToShow = gpx != null ? gpx.findPointToShow() : null;
if (pointToShow != null) {
LatLon location = new LatLon(pointToShow.getLatitude(),
pointToShow.getLongitude());
final OsmandSettings settings = app.getSettings();
String trackName = "";
if (gpx.showCurrentTrack) {
trackName = getString(R.string.shared_string_currently_recording_track);
} else if (gpxDataItem != null) {
trackName = gpxDataItem.getFile().getName();
} else {
trackName = gpx.path;
}
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
settings.getLastKnownMapZoom(),
new PointDescription(PointDescription.POINT_TYPE_WPT, getGpxDataItem().getFile().getName()),
new PointDescription(PointDescription.POINT_TYPE_WPT, trackName),
false,
getRect()
);