Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
KnollFrank committed Dec 18, 2024
1 parent 894ebef commit ac89eb3
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,11 @@ private void setupResetToDefaultButton() {
resetToDefault.setIcon(getActiveIcon(R.drawable.ic_action_reset_to_default_dark));
}

private static abstract class ShowableSearchablePreferenceDialog {
private static abstract class ShowableSearchablePreferenceDialog<T extends Fragment & SearchablePreferenceDialog> {

public final SearchablePreferenceDialog searchablePreferenceDialog;
public final T searchablePreferenceDialog;

public ShowableSearchablePreferenceDialog(final SearchablePreferenceDialog searchablePreferenceDialog) {
public ShowableSearchablePreferenceDialog(final T searchablePreferenceDialog) {
this.searchablePreferenceDialog = searchablePreferenceDialog;
}

Expand All @@ -330,7 +330,7 @@ public ShowableSearchablePreferenceDialog(final SearchablePreferenceDialog searc
@Override
public boolean onPreferenceClick(Preference preference) {
String prefId = preference.getKey();
final Optional<ShowableSearchablePreferenceDialog> preferenceDialog = createPreferenceDialog(preference, this);
final Optional<ShowableSearchablePreferenceDialog<?>> preferenceDialog = createPreferenceDialog(preference, this);
if (preferenceDialog.isPresent()) {
preferenceDialog.get().show();
return true;
Expand Down Expand Up @@ -362,11 +362,11 @@ public boolean onPreferenceClick(Preference preference) {
return super.onPreferenceClick(preference);
}

private Optional<ShowableSearchablePreferenceDialog> createPreferenceDialog(final Preference preference,
final DevelopmentSettingsFragment target) {
private Optional<ShowableSearchablePreferenceDialog<?>> createPreferenceDialog(final Preference preference,
final DevelopmentSettingsFragment target) {
if (SIMULATE_YOUR_LOCATION.equals(preference.getKey())) {
return Optional.of(
new ShowableSearchablePreferenceDialog(
new ShowableSearchablePreferenceDialog<>(
SimulateLocationFragment.createInstance(
null,
false)) {
Expand All @@ -382,7 +382,7 @@ public void show() {
}
if (settings.MEMORY_ALLOCATED_FOR_ROUTING.getId().equals(preference.getKey())) {
return Optional.of(
new ShowableSearchablePreferenceDialog(
new ShowableSearchablePreferenceDialog<>(
AllocatedRoutingMemoryBottomSheet.createInstance(
preference.getKey(),
target,
Expand All @@ -400,7 +400,7 @@ public void show() {
}
if (settings.LOCATION_INTERPOLATION_PERCENT.getId().equals(preference.getKey())) {
return Optional.of(
new ShowableSearchablePreferenceDialog(
new ShowableSearchablePreferenceDialog<>(
LocationInterpolationBottomSheet.createInstance(
preference,
target,
Expand All @@ -425,7 +425,7 @@ public Optional<PreferenceDialogAndSearchableInfoByPreferenceDialogProvider<?>>
.map(showableSearchablePreferenceDialog -> showableSearchablePreferenceDialog.searchablePreferenceDialog)
.map(searchablePreferenceDialog ->
new PreferenceDialogAndSearchableInfoByPreferenceDialogProvider<>(
(Fragment) searchablePreferenceDialog,
searchablePreferenceDialog,
_preferenceDialog -> searchablePreferenceDialog.getSearchableInfo()));
}

Expand Down

0 comments on commit ac89eb3

Please sign in to comment.