1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-22 02:53:09 +01:00

Cleanup up some code

This commit is contained in:
litetex 2021-10-26 19:23:48 +02:00
parent 5c9705d94e
commit 467bd21de2

View File

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