Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
KnollFrank committed Dec 19, 2024
1 parent db8efbf commit c129d34
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ public boolean onPreferenceClick(Preference preference) {
Integer selectedValueIndex = enabled ? hazmatParameters.findIndexOfValue(selectedValue) : null;
HazmatCategoryBottomSheet.showInstance(manager, this, HAZMAT_TRANSPORTING_ENABLED, appMode, false, hazmatParameters.localizedNames, hazmatParameters.values, selectedValueIndex);
}
} else if (GOODS_RESTRICTIONS_PREFERENCE.equals(prefId)) {
} else if (isGoodsRestrictionsPreference(preference)) {
this
.getPreferenceDialogForGoodsRestrictionsPreference(preference, this)
.show();
Expand Down Expand Up @@ -630,15 +630,23 @@ public boolean showPreferenceFragment(final PreferenceFragmentCompat preferenceF
public Optional<ShowableSearchablePreferenceDialog<?>> getShowableSearchablePreferenceDialog(
final Preference preference,
final Fragment target) {
if (settings.ROUTE_RECALCULATION_DISTANCE.getId().equals(preference.getKey())) {
if (isRouteRecalculationDistancePreference(preference)) {
return Optional.of(getPreferenceDialogForRouteRecalculationDistancePreference(preference, target));
}
if (GOODS_RESTRICTIONS_PREFERENCE.equals(preference.getKey())) {
if (isGoodsRestrictionsPreference(preference)) {
return Optional.of(getPreferenceDialogForGoodsRestrictionsPreference(preference, target));
}
return Optional.empty();
}

private boolean isRouteRecalculationDistancePreference(final Preference preference) {
return settings.ROUTE_RECALCULATION_DISTANCE.getId().equals(preference.getKey());
}

private static boolean isGoodsRestrictionsPreference(final Preference preference) {
return GOODS_RESTRICTIONS_PREFERENCE.equals(preference.getKey());
}

private ShowableSearchablePreferenceDialog<RecalculateRouteInDeviationBottomSheet> getPreferenceDialogForRouteRecalculationDistancePreference(
final Preference preference,
final Fragment target) {
Expand Down Expand Up @@ -680,7 +688,7 @@ public void onDisplayPreferenceDialog(Preference preference) {
ApplicationMode appMode = getSelectedAppMode();
FragmentManager manager = getFragmentManager();

if (settings.ROUTE_RECALCULATION_DISTANCE.getId().equals(prefId)) {
if (isRouteRecalculationDistancePreference(preference)) {
this
.getPreferenceDialogForRouteRecalculationDistancePreference(preference, this)
.show();
Expand Down

0 comments on commit c129d34

Please sign in to comment.