Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
KnollFrank committed Dec 15, 2024
1 parent 47f5b91 commit cc05f31
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,11 @@ protected void setupPreferences() {

@Override
public void onDisplayPreferenceDialog(Preference preference) {
final Optional<SearchablePreferenceDialog> preferenceDialog = createPreferenceDialog(preference, this);
if (preferenceDialog.isPresent()) {
show(preferenceDialog.get());
} else {
super.onDisplayPreferenceDialog(preference);
}
this
.createPreferenceDialog(preference, this)
.ifPresentOrElse(
this::show,
() -> super.onDisplayPreferenceDialog(preference));
}

private Optional<SearchablePreferenceDialog> createPreferenceDialog(final Preference preference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ public boolean onPreferenceClick(Preference preference) {
@Override
public void onDisplayPreferenceDialog(Preference preference) {
this
.createPreferenceDialog(
preference,
this,
false)
.createPreferenceDialog(preference, this, false)
.ifPresentOrElse(
this::show,
() -> super.onDisplayPreferenceDialog(preference));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,17 @@ public boolean onPreferenceClick(Preference preference) {

@Override
public void onDisplayPreferenceDialog(Preference preference) {
final Optional<SearchablePreferenceDialog> searchablePreferenceDialog = createSearchablePreferenceDialog(preference, this);
if (searchablePreferenceDialog.isPresent()) {
show(searchablePreferenceDialog.get());
} else if (settings.VOICE_PROVIDER.getId().equals(preference.getKey())) {
VoiceLanguageBottomSheetFragment.showInstance(requireActivity().getSupportFragmentManager(), this, getSelectedAppMode(), false);
} else {
super.onDisplayPreferenceDialog(preference);
}
this
.createSearchablePreferenceDialog(preference, this)
.ifPresentOrElse(
this::show,
() -> {
if (settings.VOICE_PROVIDER.getId().equals(preference.getKey())) {
VoiceLanguageBottomSheetFragment.showInstance(requireActivity().getSupportFragmentManager(), this, getSelectedAppMode(), false);
} else {
super.onDisplayPreferenceDialog(preference);
}
});
}

private Optional<SearchablePreferenceDialog> createSearchablePreferenceDialog(
Expand Down

0 comments on commit cc05f31

Please sign in to comment.