Cleanup up some code

This commit is contained in:
litetex 2021-10-26 19:23:48 +02:00
parent 5c9705d94e
commit 467bd21de2
1 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,7 @@
package org.schabi.newpipe.settings; package org.schabi.newpipe.settings;
import static org.schabi.newpipe.CheckForNewAppVersion.startNewVersionCheckService;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
@ -7,17 +9,15 @@ import androidx.preference.Preference;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import static org.schabi.newpipe.CheckForNewAppVersion.startNewVersionCheckService;
public class UpdateSettingsFragment extends BasePreferenceFragment { public class UpdateSettingsFragment extends BasePreferenceFragment {
private final Preference.OnPreferenceChangeListener updatePreferenceChange private final Preference.OnPreferenceChangeListener updatePreferenceChange
= (preference, checkForUpdates) -> { = (preference, checkForUpdates) -> {
defaultPreferences.edit() defaultPreferences.edit()
.putBoolean(getString(R.string.update_app_key), (boolean) checkForUpdates).apply(); .putBoolean(getString(R.string.update_app_key), (boolean) checkForUpdates).apply();
if ((boolean) checkForUpdates) { if ((boolean) checkForUpdates) {
checkNewVersionNow(); checkNewVersionNow();
} }
return true; return true;
}; };
@ -40,9 +40,9 @@ public class UpdateSettingsFragment extends BasePreferenceFragment {
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) { public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
addPreferencesFromResource(R.xml.update_settings); addPreferencesFromResource(R.xml.update_settings);
final String updateToggleKey = getString(R.string.update_app_key); findPreference(getString(R.string.update_app_key))
final String manualUpdateKey = getString(R.string.manual_update_key); .setOnPreferenceChangeListener(updatePreferenceChange);
findPreference(updateToggleKey).setOnPreferenceChangeListener(updatePreferenceChange); findPreference(getString(R.string.manual_update_key))
findPreference(manualUpdateKey).setOnPreferenceClickListener(manualUpdateClick); .setOnPreferenceClickListener(manualUpdateClick);
} }
} }