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);
}
Aggregations