Search in sources :

Example 31 with Category

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);
}
Also used : Category(com.faltenreich.diaguard.shared.data.database.entity.Category)

Aggregations

Category (com.faltenreich.diaguard.shared.data.database.entity.Category)31 ArrayList (java.util.ArrayList)18 Measurement (com.faltenreich.diaguard.shared.data.database.entity.Measurement)15 Entry (com.faltenreich.diaguard.shared.data.database.entity.Entry)13 List (java.util.List)10 EntryTag (com.faltenreich.diaguard.shared.data.database.entity.EntryTag)7 FoodEaten (com.faltenreich.diaguard.shared.data.database.entity.FoodEaten)7 Meal (com.faltenreich.diaguard.shared.data.database.entity.Meal)7 Tag (com.faltenreich.diaguard.shared.data.database.entity.Tag)7 View (android.view.View)6 ImageView (android.widget.ImageView)5 CategoryValueListItem (com.faltenreich.diaguard.feature.timeline.table.CategoryValueListItem)5 Context (android.content.Context)4 Point (com.pdfjet.Point)4 DateTime (org.joda.time.DateTime)4 LayoutInflater (android.view.LayoutInflater)3 LinearLayout (android.widget.LinearLayout)3 TextView (android.widget.TextView)3 CellBuilder (com.faltenreich.diaguard.feature.export.job.pdf.view.CellBuilder)3 BloodSugar (com.faltenreich.diaguard.shared.data.database.entity.BloodSugar)3