From 60ecd271e661416a11fd572c0d66e1b43b128aca Mon Sep 17 00:00:00 2001 From: frankknoll Date: Thu, 19 Dec 2024 11:23:19 +0100 Subject: [PATCH] refactoring --- .../SimpleSingleSelectionBottomSheet.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SimpleSingleSelectionBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SimpleSingleSelectionBottomSheet.java index 07e392a87fb..8e8e8f7860e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SimpleSingleSelectionBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SimpleSingleSelectionBottomSheet.java @@ -10,7 +10,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.preference.Preference; @@ -63,13 +62,32 @@ public class SimpleSingleSelectionBottomSheet extends BasePreferenceBottomSheet final @NonNull String[] names, final @NonNull Object[] values, final int selectedIndex) { - final SimpleSingleSelectionBottomSheet bottomSheet = new SimpleSingleSelectionBottomSheet(); - bottomSheet.setParameters(title, description, names, values, selectedIndex); return BasePreferenceBottomSheetInitializer - .initialize(bottomSheet) + .initialize( + new SimpleSingleSelectionBottomSheet( + title, + description, + names, + values, + selectedIndex)) .with(Optional.of(preference), appMode, usedOnMap, target); } + public SimpleSingleSelectionBottomSheet() { + } + + public SimpleSingleSelectionBottomSheet(@NonNull String title, + @NonNull String description, + @NonNull String[] names, + @NonNull Object[] values, + int selectedEntryIndex) { + this.title = title; + this.description = description; + this.names = names; + this.values = values; + this.selectedEntryIndex = selectedEntryIndex; + } + @Override public void show(final FragmentManager fragmentManager, final OsmandApplication app) { if (AndroidUtils.isFragmentCanBeAdded(fragmentManager, TAG)) { @@ -139,15 +157,6 @@ private void updateRadioButtons() { } } - public void setParameters(@NonNull String title, @NonNull String description, @NonNull String[] names, - @NonNull Object[] values, @Nullable Integer selectedEntryIndex) { - this.title = title; - this.description = description; - this.names = names; - this.values = values; - this.selectedEntryIndex = selectedEntryIndex != null ? selectedEntryIndex : 0; - } - @Override protected int getDismissButtonTextId() { return R.string.shared_string_close;