Search in sources :

Example 1 with FoodEatenUpdatedEvent

use of com.faltenreich.diaguard.shared.event.ui.FoodEatenUpdatedEvent in project Diaguard by Faltenreich.

the class FoodInputViewHolder method showNumberPicker.

private void showNumberPicker() {
    if (getContext() instanceof AppCompatActivity) {
        AppCompatActivity activity = (AppCompatActivity) getContext();
        new NumberPickerDialog(getContext(), R.string.grams_milliliters_acronym, getAmountFromButton(), 1, 10000, (number) -> {
            FoodEaten foodEaten = getItem();
            foodEaten.setAmountInGrams(number.floatValue());
            Events.post(new FoodEatenUpdatedEvent(foodEaten, getAdapterPosition()));
        }).show(activity.getSupportFragmentManager());
    }
}
Also used : FoodEaten(com.faltenreich.diaguard.shared.data.database.entity.FoodEaten) FloatUtils(com.faltenreich.diaguard.shared.data.primitive.FloatUtils) BaseViewHolder(com.faltenreich.diaguard.shared.view.recyclerview.viewholder.BaseViewHolder) ListItemMeasurementMealFoodItemBinding(com.faltenreich.diaguard.databinding.ListItemMeasurementMealFoodItemBinding) FoodEatenRemovedEvent(com.faltenreich.diaguard.shared.event.ui.FoodEatenRemovedEvent) ColorUtils(com.faltenreich.diaguard.shared.view.resource.ColorUtils) PreferenceStore(com.faltenreich.diaguard.feature.preference.data.PreferenceStore) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) AppCompatButton(androidx.appcompat.widget.AppCompatButton) NumberPickerDialog(com.faltenreich.diaguard.shared.view.picker.NumberPickerDialog) ViewGroup(android.view.ViewGroup) ColorStateList(android.content.res.ColorStateList) Color(android.graphics.Color) R(com.faltenreich.diaguard.R) SuppressLint(android.annotation.SuppressLint) Food(com.faltenreich.diaguard.shared.data.database.entity.Food) Events(com.faltenreich.diaguard.shared.event.Events) View(android.view.View) FoodEatenUpdatedEvent(com.faltenreich.diaguard.shared.event.ui.FoodEatenUpdatedEvent) FoodEatenUpdatedEvent(com.faltenreich.diaguard.shared.event.ui.FoodEatenUpdatedEvent) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) NumberPickerDialog(com.faltenreich.diaguard.shared.view.picker.NumberPickerDialog) FoodEaten(com.faltenreich.diaguard.shared.data.database.entity.FoodEaten)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 ColorStateList (android.content.res.ColorStateList)1 Color (android.graphics.Color)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)1 AppCompatButton (androidx.appcompat.widget.AppCompatButton)1 R (com.faltenreich.diaguard.R)1 ListItemMeasurementMealFoodItemBinding (com.faltenreich.diaguard.databinding.ListItemMeasurementMealFoodItemBinding)1 PreferenceStore (com.faltenreich.diaguard.feature.preference.data.PreferenceStore)1 Food (com.faltenreich.diaguard.shared.data.database.entity.Food)1 FoodEaten (com.faltenreich.diaguard.shared.data.database.entity.FoodEaten)1 FloatUtils (com.faltenreich.diaguard.shared.data.primitive.FloatUtils)1 Events (com.faltenreich.diaguard.shared.event.Events)1 FoodEatenRemovedEvent (com.faltenreich.diaguard.shared.event.ui.FoodEatenRemovedEvent)1 FoodEatenUpdatedEvent (com.faltenreich.diaguard.shared.event.ui.FoodEatenUpdatedEvent)1 NumberPickerDialog (com.faltenreich.diaguard.shared.view.picker.NumberPickerDialog)1 BaseViewHolder (com.faltenreich.diaguard.shared.view.recyclerview.viewholder.BaseViewHolder)1 ColorUtils (com.faltenreich.diaguard.shared.view.resource.ColorUtils)1