blob: d5898334b680a564acee7299d7e76628f15c9a14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package it.niedermann.nextcloud.deck.ui.board.managelabels;
import android.content.res.ColorStateList;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import it.niedermann.nextcloud.deck.databinding.ItemManageLabelBinding;
import it.niedermann.nextcloud.deck.model.Label;
import it.niedermann.nextcloud.deck.util.ColorUtil;
public class ManageLabelsViewHolder extends RecyclerView.ViewHolder {
private ItemManageLabelBinding binding;
@SuppressWarnings("WeakerAccess")
public ManageLabelsViewHolder(ItemManageLabelBinding binding) {
super(binding.getRoot());
this.binding = binding;
this.binding.label.setClickable(false);
}
public void bind(@NonNull Label label, @NonNull ManageLabelListener listener) {
binding.label.setText(label.getTitle());
final int labelColor = label.getColor();
binding.label.setChipBackgroundColor(ColorStateList.valueOf(labelColor));
final int color = ColorUtil.getForegroundColorForBackgroundColor(labelColor);
binding.label.setTextColor(color);
binding.delete.setOnClickListener((v) -> listener.requestDelete(label));
binding.editText.setOnClickListener((v) -> listener.requestEdit(label));
}
}
|