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
|
package it.niedermann.owncloud.notes.main.items.list;
import android.content.Context;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithoutExcerptBinding;
import it.niedermann.owncloud.notes.main.items.NoteViewHolder;
import it.niedermann.owncloud.notes.persistence.entity.Note;
import it.niedermann.owncloud.notes.shared.model.DBStatus;
import it.niedermann.owncloud.notes.shared.model.NoteClickListener;
public class NoteViewHolderWithoutExcerpt extends NoteViewHolder {
@NonNull
private final ItemNotesListNoteItemWithoutExcerptBinding binding;
public NoteViewHolderWithoutExcerpt(@NonNull ItemNotesListNoteItemWithoutExcerptBinding binding, @NonNull NoteClickListener noteClickListener) {
super(binding.getRoot(), noteClickListener);
this.binding = binding;
}
public void showSwipe(boolean left) {
binding.noteFavoriteLeft.setVisibility(left ? View.VISIBLE : View.INVISIBLE);
binding.noteDeleteRight.setVisibility(left ? View.INVISIBLE : View.VISIBLE);
binding.noteSwipeFrame.setBackgroundResource(left ? R.color.bg_warning : R.color.bg_attention);
}
public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, int color, @Nullable CharSequence searchQuery) {
super.bind(isSelected, note, showCategory, color, searchQuery);
@NonNull final Context context = itemView.getContext();
binding.noteSwipeable.setAlpha(DBStatus.LOCAL_DELETED.equals(note.getStatus()) ? 0.5f : 1.0f);
bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), color);
bindStatus(binding.noteStatus, note.getStatus(), color);
bindFavorite(binding.noteFavorite, note.getFavorite());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindActions(binding.noteActions, color);
}
@NonNull
public View getNoteSwipeable() {
return binding.noteSwipeable;
}
}
|