From 793bda10244a7455e1dc8145fa48f101b06cbf9c Mon Sep 17 00:00:00 2001 From: cepprice Date: Sun, 28 Feb 2021 23:35:21 +0500 Subject: [PATCH] Simplify code --- .../bottomsheets/BooleanPreferenceBottomSheet.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java index b0536fe72b..5eb3dd226c 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java @@ -66,7 +66,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { ? getString(R.string.shared_string_disabled) : summaryOff.toString(); final int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic); final int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary); - boolean checked = isPreferenceChecked(pref, app); + boolean checked = switchPreference.isChecked(); final BottomSheetItemWithCompoundButton[] preferenceBtn = new BottomSheetItemWithCompoundButton[1]; preferenceBtn[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() @@ -77,7 +77,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - boolean newValue = !isPreferenceChecked(pref, app); + boolean newValue = !switchPreference.isChecked(); Fragment targetFragment = getTargetFragment(); if (targetFragment instanceof OnConfirmPreferenceChange) { ApplyQueryType applyQueryType = getApplyQueryType(); @@ -156,13 +156,6 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { return (SwitchPreferenceEx) getPreference(); } - private boolean isPreferenceChecked(BooleanPreference preference, OsmandApplication app) { - boolean checked = preference.getModeValue(getAppMode()); - boolean shouldInvertSetting = app.getSettings().DISABLE_COMPLEX_ROUTING.getId() - .equals(preference.getId()); - return checked != shouldInvertSetting; - } - public static void showInstance(@NonNull FragmentManager fm, String prefId, Fragment target, boolean usedOnMap, @Nullable ApplicationMode appMode, ApplyQueryType applyQueryType, boolean profileDependent) {