|
15 | 15 | import com.android.settings.R;
|
16 | 16 |
|
17 | 17 | import java.util.Objects;
|
| 18 | +import java.util.function.Consumer; |
18 | 19 |
|
19 | 20 | public abstract class AswAppInfoFragment<T extends AppSwitch>
|
20 | 21 | extends RadioButtonAppInfoFragment implements Preference.OnPreferenceChangeListener {
|
@@ -147,14 +148,10 @@ protected CharSequence getSummaryForImmutabilityReason(int ir) {
|
147 | 148 | return null;
|
148 | 149 | }
|
149 | 150 |
|
150 |
| - private interface GosPackageStateUpdater { |
151 |
| - void run(GosPackageState.Editor ed); |
152 |
| - } |
153 |
| - |
154 |
| - private void updateGosPackageState(GosPackageStateUpdater updater) { |
| 151 | + private void updateGosPackageState(Consumer<GosPackageState.Editor> updater) { |
155 | 152 | GosPackageState.Editor ed = GosPackageState.edit(mPackageName, mUserId);
|
156 | 153 |
|
157 |
| - updater.run(ed); |
| 154 | + updater.accept(ed); |
158 | 155 |
|
159 | 156 | ed.setKillUidAfterApply(shouldKillUidAfterChange());
|
160 | 157 |
|
@@ -194,19 +191,16 @@ public final void onEntrySelected(int id) {
|
194 | 191 | }
|
195 | 192 |
|
196 | 193 | @Override
|
197 |
| - public boolean onPreferenceChange(@NonNull Preference preference, Object o) { |
| 194 | + public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) { |
198 | 195 | if (!preference.equals(notificationPreference)) {
|
199 | 196 | return false;
|
200 | 197 | }
|
201 | 198 |
|
202 |
| - SwitchPreferenceCompat np = notificationPreference; |
203 | 199 | AppSwitch asw = adapter.getAppSwitch();
|
204 |
| - |
205 |
| - boolean oldValue = np.isChecked(); |
206 |
| - boolean newValue = !oldValue; |
| 200 | + boolean newChecked = (boolean) newValue; |
207 | 201 |
|
208 | 202 | updateGosPackageState(ed -> {
|
209 |
| - if (newValue) { |
| 203 | + if (newChecked) { |
210 | 204 | asw.removeSuppressNotificationFlag(ed);
|
211 | 205 | } else {
|
212 | 206 | asw.addSuppressNotificationFlag(ed);
|
|
0 commit comments