Merge "Fix NPE in date time settings" into main
This commit is contained in:
@@ -39,6 +39,11 @@ public class AutoTimePreferenceController extends TogglePreferenceController {
|
|||||||
public AutoTimePreferenceController(Context context, String preferenceKey) {
|
public AutoTimePreferenceController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mTimeManager = context.getSystemService(TimeManager.class);
|
mTimeManager = context.getSystemService(TimeManager.class);
|
||||||
|
// This is a no-op implementation of UpdateTimeAndDateCallback to avoid a NPE when
|
||||||
|
// setTimeAndDateCallback() isn't called, e.g. for slices and other cases where the
|
||||||
|
// controller is instantiated outside of the context of the real Date & Time settings
|
||||||
|
// screen.
|
||||||
|
mCallback = (c) -> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDateAndTimeCallback(UpdateTimeAndDateCallback callback) {
|
public void setDateAndTimeCallback(UpdateTimeAndDateCallback callback) {
|
||||||
|
@@ -40,6 +40,11 @@ public class AutoTimeZonePreferenceController extends TogglePreferenceController
|
|||||||
public AutoTimeZonePreferenceController(Context context, String preferenceKey) {
|
public AutoTimeZonePreferenceController(Context context, String preferenceKey) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mTimeManager = context.getSystemService(TimeManager.class);
|
mTimeManager = context.getSystemService(TimeManager.class);
|
||||||
|
// This is a no-op implementation of UpdateTimeAndDateCallback to avoid a NPE when
|
||||||
|
// setTimeAndDateCallback() isn't called, e.g. for slices and other cases where the
|
||||||
|
// controller is instantiated outside of the context of the real Date & Time settings
|
||||||
|
// screen.
|
||||||
|
mCallback = (c) -> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -43,6 +43,11 @@ public class TimeFormatPreferenceController extends TogglePreferenceController {
|
|||||||
public TimeFormatPreferenceController(Context context, String key) {
|
public TimeFormatPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mDummyDate = Calendar.getInstance();
|
mDummyDate = Calendar.getInstance();
|
||||||
|
// This is a no-op implementation of UpdateTimeAndDateCallback to avoid a NPE when
|
||||||
|
// setTimeAndDateCallback() isn't called, e.g. for slices and other cases where the
|
||||||
|
// controller is instantiated outside of the context of the real Date & Time settings
|
||||||
|
// screen.
|
||||||
|
mUpdateTimeAndDateCallback = (c) -> {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user