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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
package it.niedermann.nextcloud.deck.ui.card;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.MenuRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.card.MaterialCardView;
import java.util.List;
import it.niedermann.nextcloud.deck.databinding.ItemCardCompactBinding;
import it.niedermann.nextcloud.deck.model.Account;
import it.niedermann.nextcloud.deck.model.Label;
import it.niedermann.nextcloud.deck.model.full.FullCard;
public class CompactCardViewHolder extends AbstractCardViewHolder {
private final ItemCardCompactBinding binding;
@SuppressWarnings("WeakerAccess")
public CompactCardViewHolder(@NonNull ItemCardCompactBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
/**
* Removes all {@link OnClickListener} and {@link OnLongClickListener}
*/
public void bind(@NonNull FullCard fullCard, @NonNull Account account, @Nullable Long boardRemoteId, boolean hasEditPermission, @MenuRes int optionsMenu, @NonNull CardOptionsItemSelectedListener optionsItemsSelectedListener, @NonNull String counterMaxValue, @ColorInt int mainColor) {
super.bind(fullCard, account, boardRemoteId, hasEditPermission, optionsMenu, optionsItemsSelectedListener, counterMaxValue, mainColor);
List<Label> labels = fullCard.getLabels();
if (labels != null && labels.size() > 0) {
binding.labels.updateLabels(labels);
binding.labels.setVisibility(View.VISIBLE);
} else {
binding.labels.removeAllViews();
binding.labels.setVisibility(View.GONE);
}
}
public void bindCardClickListener(@Nullable OnClickListener l) {
binding.card.setOnClickListener(l);
}
public void bindCardLongClickListener(@Nullable OnLongClickListener l) {
binding.card.setOnLongClickListener(l);
}
public MaterialCardView getDraggable() {
return binding.card;
}
@Override
protected TextView getCardDueDate() {
return binding.cardDueDate;
}
@Override
protected ImageView getNotSyncedYet() {
return binding.notSyncedYet;
}
@Override
protected TextView getCardTitle() {
return binding.cardTitle;
}
@Override
protected View getCardMenu() {
return binding.cardMenu;
}
@Override
protected MaterialCardView getCard() {
return binding.card;
}
}
|