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 f4c4375 commit 60ecd27
Showing 1 changed file with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 60ecd27

Please sign in to comment.