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 e72f6fe commit f4c4375
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;

import com.google.common.collect.ImmutableList;

Expand All @@ -28,6 +29,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class SimpleSingleSelectionBottomSheet extends BasePreferenceBottomSheet implements SearchablePreferenceDialog {

Expand All @@ -51,25 +53,21 @@ public class SimpleSingleSelectionBottomSheet extends BasePreferenceBottomSheet
private Object[] values;
private int selectedEntryIndex;

public static @NonNull SimpleSingleSelectionBottomSheet createInstance(final @NonNull Fragment target,
final @NonNull String key,
final @NonNull String title,
final @NonNull String description,
final @NonNull ApplicationMode appMode,
final boolean usedOnMap,
final @NonNull String[] names,
final @NonNull Object[] values,
final int selectedIndex) {
final Bundle args = new Bundle();
args.putString(PREFERENCE_ID, key);

final SimpleSingleSelectionBottomSheet fragment = new SimpleSingleSelectionBottomSheet();
fragment.setArguments(args);
fragment.setAppMode(appMode);
fragment.setUsedOnMap(usedOnMap);
fragment.setTargetFragment(target, 0);
fragment.setParameters(title, description, names, values, selectedIndex);
return fragment;
public static @NonNull SimpleSingleSelectionBottomSheet createInstance(
final @NonNull Fragment target,
final @NonNull Preference preference,
final @NonNull String title,
final @NonNull String description,
final @NonNull ApplicationMode appMode,
final boolean usedOnMap,
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)
.with(Optional.of(preference), appMode, usedOnMap, target);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected void show(final SearchablePreferenceDialog searchablePreferenceDialog)
new ShowableSearchablePreferenceDialog<>(
SimpleSingleSelectionBottomSheet.createInstance(
target,
preference.getKey(),
preference,
pref.getTitle().toString(),
pref.getDescription(),
getSelectedAppMode(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public static Iterable<Object[]> data() {

{"GeneralProfileSettingsFragment", searchQuery(R.string.distance_during_navigation)},

{"DistanceDuringNavigationBottomSheet: description", searchQuery("Choose how distance information is displayed in navigation widgets")}
{"DistanceDuringNavigationBottomSheet: description", searchQuery("Choose how distance information is displayed in navigation widgets")},

{"VehicleParametersFragment: SimpleSingleSelectionBottomSheet, description", searchQuery(R.string.routing_attr_motor_type_description)}
});
}

Expand Down

0 comments on commit f4c4375

Please sign in to comment.