WeakReference - mapActivity, import header
This commit is contained in:
parent
99c432d9ff
commit
03a450f9e2
2 changed files with 15 additions and 13 deletions
|
@ -31,6 +31,8 @@ import net.osmand.plus.track.TrackMenuFragment;
|
||||||
import net.osmand.plus.track.TrackSelectSegmentBottomSheet;
|
import net.osmand.plus.track.TrackSelectSegmentBottomSheet;
|
||||||
import net.osmand.plus.widgets.TextViewExProgress;
|
import net.osmand.plus.widgets.TextViewExProgress;
|
||||||
|
|
||||||
|
import static net.osmand.plus.track.TrackMenuFragment.startNavigationForGPX;
|
||||||
|
|
||||||
public class MapRouteInfoMenuFragment extends ContextMenuFragment implements TrackSelectSegmentBottomSheet.OnSegmentSelectedListener {
|
public class MapRouteInfoMenuFragment extends ContextMenuFragment implements TrackSelectSegmentBottomSheet.OnSegmentSelectedListener {
|
||||||
public static final String TAG = MapRouteInfoMenuFragment.class.getName();
|
public static final String TAG = MapRouteInfoMenuFragment.class.getName();
|
||||||
|
|
||||||
|
@ -508,11 +510,10 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment implements Tra
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSegmentSelect(GPXUtilities.GPXFile gpxFile, int selectedSegment) {
|
public void onSegmentSelect(GPXUtilities.GPXFile gpxFile, int selectedSegment) {
|
||||||
if (getMyApplication() != null) {
|
|
||||||
getMyApplication().getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
TrackMenuFragment.startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity);
|
mapActivity.getMyApplication().getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
|
||||||
|
startNavigationForGPX(gpxFile, mapActivity.getMapActions(), mapActivity);
|
||||||
GPXRouteParams.GPXRouteParamsBuilder paramsBuilder = getMyApplication().getRoutingHelper().getCurrentGPXRoute();
|
GPXRouteParams.GPXRouteParamsBuilder paramsBuilder = getMyApplication().getRoutingHelper().getCurrentGPXRoute();
|
||||||
if (paramsBuilder != null) {
|
if (paramsBuilder != null) {
|
||||||
paramsBuilder.setSelectedSegment(selectedSegment);
|
paramsBuilder.setSelectedSegment(selectedSegment);
|
||||||
|
@ -522,4 +523,3 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment implements Tra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -906,11 +906,13 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
|
|
||||||
public static void startNavigationForGPX(final GPXFile gpxFile, MapActivityActions mapActions, final MapActivity mapActivity) {
|
public static void startNavigationForGPX(final GPXFile gpxFile, MapActivityActions mapActions, final MapActivity mapActivity) {
|
||||||
if (mapActivity.getMyApplication().getRoutingHelper().isFollowingMode()) {
|
if (mapActivity.getMyApplication().getRoutingHelper().isFollowingMode()) {
|
||||||
|
final WeakReference<MapActivity> activityRef = new WeakReference<>(mapActivity);
|
||||||
mapActions.stopNavigationActionConfirm(null, new Runnable() {
|
mapActions.stopNavigationActionConfirm(null, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mapActivity != null) {
|
MapActivity activity = activityRef.get();
|
||||||
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpxFile, null,
|
if (activity != null) {
|
||||||
|
activity.getMapActions().enterRoutePlanningModeGivenGpx(gpxFile, null,
|
||||||
null, null, true, true, MenuState.HEADER_ONLY);
|
null, null, true, true, MenuState.HEADER_ONLY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue