use of com.faltenreich.diaguard.shared.data.database.entity.Category in project Diaguard by Faltenreich.
the class MeasurementView method togglePinnedCategory.
private void togglePinnedCategory(final boolean isPinned) {
Category category = measurement.getCategory();
int textResId = isPinned ? R.string.category_pin_confirm : R.string.category_unpin_confirm;
String categoryString = getContext().getString(category.getStringResId());
String confirmation = String.format(getContext().getString(textResId), categoryString);
ViewUtils.showSnackbar(MeasurementView.this, confirmation, view -> {
pinnedCheckbox.setOnCheckedChangeListener(null);
pinnedCheckbox.setChecked(!isPinned);
PreferenceStore.getInstance().setCategoryPinned(category, !isPinned);
pinnedCheckbox.setOnCheckedChangeListener((checkbox, isChecked) -> togglePinnedCategory(isChecked));
});
PreferenceStore.getInstance().setCategoryPinned(category, isPinned);
}
Aggregations