use of com.faltenreich.diaguard.shared.event.preference.TimelinePreferenceChangedEvent in project Diaguard by Faltenreich.
the class PreferenceFragment method onSharedPreferenceChanged.
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (!isAdded()) {
return;
}
if (key.equals(getString(R.string.preference_unit_bloodsugar))) {
Events.post(new UnitChangedEvent(Category.BLOODSUGAR));
} else if (key.equals(getString(R.string.preference_unit_meal))) {
Events.post(new UnitChangedEvent(Category.MEAL));
} else if (key.equals(getString(R.string.preference_unit_meal_factor))) {
Events.post(new MealFactorUnitChangedEvent());
} else if (key.equals(getString(R.string.preference_unit_hba1c))) {
Events.post(new UnitChangedEvent(Category.HBA1C));
} else if (key.equals(getString(R.string.preference_unit_weight))) {
Events.post(new UnitChangedEvent(Category.WEIGHT));
} else if (key.equals(getString(R.string.preference_timeline_show_dots)) || key.equals(getString(R.string.preference_timeline_show_lines))) {
Events.post(new TimelinePreferenceChangedEvent());
} else if (key.equals(getString(R.string.preference_theme))) {
Theme theme = PreferenceStore.getInstance().getTheme();
ThemeUtils.setDefaultNightMode(theme);
ThemeUtils.setUiMode(getActivity(), theme);
} else if (key.equals(getString(R.string.preference_decimal_places))) {
int decimalPlaces = PreferenceStore.getInstance().getDecimalPlaces();
PreferenceCache.getInstance().setDecimalPlaces(decimalPlaces);
}
}
Aggregations