Search in sources :

Example 1 with SwipeDismissTouchListener

use of com.faltenreich.diaguard.shared.view.swipe.SwipeDismissTouchListener in project Diaguard by Faltenreich.

the class MeasurementView method initLayout.

private void initLayout() {
    Category category = measurement.getCategory();
    setRadius(getContext().getResources().getDimension(R.dimen.card_corner_radius));
    setCardElevation(getContext().getResources().getDimension(R.dimen.card_elevation));
    setUseCompatPadding(true);
    setOnTouchListener(new SwipeDismissTouchListener(this, null, new SwipeDismissTouchListener.DismissCallbacks() {

        @Override
        public boolean canDismiss(Object token) {
            return true;
        }

        @Override
        public void onDismiss(View view, Object token) {
            remove();
        }
    }));
    deleteButton.setOnClickListener((view) -> remove());
    pinnedCheckbox.setChecked(PreferenceStore.getInstance().isCategoryPinned(category));
    pinnedCheckbox.setOnCheckedChangeListener((checkbox, isChecked) -> togglePinnedCategory(isChecked));
    pinnedCheckbox.setSaveEnabled(false);
    String categoryName = getContext().getString(category.getStringResId());
    showcaseImageView.setImageResource(category.getShowcaseImageResourceId());
    categoryImageView.setImageResource(category.getIconImageResourceId());
    categoryLabel.setText(categoryName);
    deleteButton.setContentDescription(String.format(getContext().getString(R.string.remove_placeholder), categoryName));
    contentLayout.addView(inputView);
}
Also used : Category(com.faltenreich.diaguard.shared.data.database.entity.Category) SwipeDismissTouchListener(com.faltenreich.diaguard.shared.view.swipe.SwipeDismissTouchListener) GenericInputView(com.faltenreich.diaguard.feature.entry.edit.input.GenericInputView) PressureInputView(com.faltenreich.diaguard.feature.entry.edit.input.PressureInputView) ImageView(android.widget.ImageView) InsulinInputView(com.faltenreich.diaguard.feature.entry.edit.input.InsulinInputView) View(android.view.View) CardView(androidx.cardview.widget.CardView) MeasurementInputView(com.faltenreich.diaguard.feature.entry.edit.input.MeasurementInputView) MealInputView(com.faltenreich.diaguard.feature.entry.edit.input.MealInputView) TextView(android.widget.TextView)

Aggregations

View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 CardView (androidx.cardview.widget.CardView)1 GenericInputView (com.faltenreich.diaguard.feature.entry.edit.input.GenericInputView)1 InsulinInputView (com.faltenreich.diaguard.feature.entry.edit.input.InsulinInputView)1 MealInputView (com.faltenreich.diaguard.feature.entry.edit.input.MealInputView)1 MeasurementInputView (com.faltenreich.diaguard.feature.entry.edit.input.MeasurementInputView)1 PressureInputView (com.faltenreich.diaguard.feature.entry.edit.input.PressureInputView)1 Category (com.faltenreich.diaguard.shared.data.database.entity.Category)1 SwipeDismissTouchListener (com.faltenreich.diaguard.shared.view.swipe.SwipeDismissTouchListener)1