Small fix for final mapActivity
This commit is contained in:
parent
e1d02fabd2
commit
03d379b055
1 changed files with 24 additions and 16 deletions
|
@ -231,7 +231,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
MapActivity mapActivity = (MapActivity) getActivity();
|
||||||
if (mapActivity == null) {
|
if (mapActivity == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -375,13 +375,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
mainView.findViewById(R.id.options_button).setOnClickListener(new OnClickListener() {
|
mainView.findViewById(R.id.options_button).setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
boolean trackSnappedToRoad = !editingCtx.isApproximationNeeded();
|
MapActivity mapActivity = getMapActivity();
|
||||||
boolean addNewSegmentAllowed = editingCtx.isAddNewSegmentAllowed();
|
if (mapActivity != null) {
|
||||||
OptionsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
boolean trackSnappedToRoad = !editingCtx.isApproximationNeeded();
|
||||||
MeasurementToolFragment.this,
|
boolean addNewSegmentAllowed = editingCtx.isAddNewSegmentAllowed();
|
||||||
trackSnappedToRoad, addNewSegmentAllowed,
|
OptionsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||||
editingCtx.getAppMode().getStringKey()
|
MeasurementToolFragment.this,
|
||||||
);
|
trackSnappedToRoad, addNewSegmentAllowed,
|
||||||
|
editingCtx.getAppMode().getStringKey()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -431,7 +434,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelectPoint(int selectedPointPos) {
|
public void onSelectPoint(int selectedPointPos) {
|
||||||
if (selectedPointPos != -1) {
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null && selectedPointPos != -1) {
|
||||||
openSelectedPointMenu(mapActivity);
|
openSelectedPointMenu(mapActivity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,7 +444,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
measurementLayer.setOnMeasureDistanceToCenterListener(new MeasurementToolLayer.OnMeasureDistanceToCenter() {
|
measurementLayer.setOnMeasureDistanceToCenterListener(new MeasurementToolLayer.OnMeasureDistanceToCenter() {
|
||||||
@Override
|
@Override
|
||||||
public void onMeasure(float distance, float bearing) {
|
public void onMeasure(float distance, float bearing) {
|
||||||
String distStr = OsmAndFormatter.getFormattedDistance(distance, mapActivity.getMyApplication());
|
String distStr = OsmAndFormatter.getFormattedDistance(distance, app);
|
||||||
String azimuthStr = OsmAndFormatter.getFormattedAzimuth(bearing, app);
|
String azimuthStr = OsmAndFormatter.getFormattedAzimuth(bearing, app);
|
||||||
distanceToCenterTv.setText(String.format("%1$s • %2$s", distStr, azimuthStr));
|
distanceToCenterTv.setText(String.format("%1$s • %2$s", distStr, azimuthStr));
|
||||||
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
|
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
|
||||||
|
@ -499,6 +503,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
} else if (editingCtx.isNewData() || editingCtx.hasChanges()) {
|
} else if (editingCtx.isNewData() || editingCtx.hasChanges()) {
|
||||||
saveChanges(FinalSaveAction.SHOW_SNACK_BAR_AND_CLOSE, false);
|
saveChanges(FinalSaveAction.SHOW_SNACK_BAR_AND_CLOSE, false);
|
||||||
} else {
|
} else {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
dismiss(mapActivity, false);
|
dismiss(mapActivity, false);
|
||||||
}
|
}
|
||||||
|
@ -539,9 +544,12 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
configBtn.setOnClickListener(new OnClickListener() {
|
configBtn.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
RouteOptionsBottomSheet.showInstance(
|
MapActivity mapActivity = getMapActivity();
|
||||||
mapActivity, MeasurementToolFragment.this, DialogMode.PLAN_ROUTE,
|
if (mapActivity != null) {
|
||||||
editingCtx.getAppMode().getStringKey());
|
RouteOptionsBottomSheet.showInstance(
|
||||||
|
mapActivity, MeasurementToolFragment.this, DialogMode.PLAN_ROUTE,
|
||||||
|
editingCtx.getAppMode().getStringKey());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -935,7 +943,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
||||||
app.getRoutingHelper().onSettingsChanged(true);
|
app.getRoutingHelper().onSettingsChanged(true);
|
||||||
} else {
|
} else {
|
||||||
mapActivity.getMapActions().stopNavigationActionConfirm(null , new Runnable() {
|
mapActivity.getMapActions().stopNavigationActionConfirm(null, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
@ -1149,7 +1157,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChangeApplicationMode(ApplicationMode mode, RouteBetweenPointsDialogType dialogType,
|
public void onChangeApplicationMode(ApplicationMode mode, RouteBetweenPointsDialogType dialogType,
|
||||||
RouteBetweenPointsDialogMode dialogMode) {
|
RouteBetweenPointsDialogMode dialogMode) {
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
ChangeRouteType changeRouteType = ChangeRouteType.NEXT_SEGMENT;
|
ChangeRouteType changeRouteType = ChangeRouteType.NEXT_SEGMENT;
|
||||||
|
@ -1951,7 +1959,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx,
|
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx,
|
||||||
boolean followTrackMode) {
|
boolean followTrackMode) {
|
||||||
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
||||||
fragment.setEditingCtx(editingCtx);
|
fragment.setEditingCtx(editingCtx);
|
||||||
fragment.setMode(FOLLOW_TRACK_MODE, followTrackMode);
|
fragment.setMode(FOLLOW_TRACK_MODE, followTrackMode);
|
||||||
|
|
Loading…
Reference in a new issue