5252
5353public class ItemAdapter extends RecyclerView .Adapter <RecyclerView .ViewHolder > implements Branded {
5454
55-
5655 public static final int TYPE_SECTION = 0 ;
5756 public static final int TYPE_NOTE_WITH_EXCERPT = 1 ;
5857 public static final int TYPE_NOTE_WITHOUT_EXCERPT = 2 ;
@@ -85,8 +84,8 @@ public <T extends Context & NoteClickListener> ItemAdapter(@NonNull T context, b
8584 setHasStableIds (true );
8685 }
8786
88-
89- // FIXME this causes {@link it.niedermann.owncloud.notes.noteslist.items.list.NotesListViewItemTouchHelper} to not call clearView anymore → After marking a note as favorite, it stays yellow.
87+ // FIXME this causes {@link it.niedermann.owncloud.notes.noteslist.items.list.NotesListViewItemTouchHelper} to
88+ // not call clearView anymore → After marking a note as favorite, it stays yellow.
9089 @ Override
9190 public long getItemId (int position ) {
9291 return getItemViewType (position ) == TYPE_SECTION
@@ -118,13 +117,31 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
118117 return new SectionViewHolder (binding );
119118 }
120119 case TYPE_NOTE_ONLY_TITLE -> {
121- ItemNotesListNoteItemGridOnlyTitleBinding binding = ItemNotesListNoteItemGridOnlyTitleBinding .inflate (inflater , parent , false );
120+ ItemNotesListNoteItemGridOnlyTitleBinding binding = ItemNotesListNoteItemGridOnlyTitleBinding
121+ .inflate (inflater , parent , false );
122122 BrandingUtil .of (color , parent .getContext ()).notes .themeCard (binding .noteCard );
123+ BrandingUtil .of (color , parent .getContext ()).platform .colorTextView (
124+ binding .noteTitle , ColorRole .ON_SURFACE
125+ );
126+ BrandingUtil .of (color , parent .getContext ()).platform .colorTextView (
127+ binding .noteModified , ColorRole .ON_SURFACE_VARIANT
128+ );
123129 return new NoteViewGridHolderOnlyTitle (binding , noteClickListener , monospace , fontSize );
124130 }
125131 case TYPE_NOTE_WITH_EXCERPT , TYPE_NOTE_WITHOUT_EXCERPT -> {
126- ItemNotesListNoteItemGridBinding binding = ItemNotesListNoteItemGridBinding .inflate (inflater , parent , false );
132+ ItemNotesListNoteItemGridBinding binding = ItemNotesListNoteItemGridBinding .inflate (
133+ inflater , parent , false
134+ );
127135 BrandingUtil .of (color , parent .getContext ()).notes .themeCard (binding .noteCard );
136+ BrandingUtil .of (color , parent .getContext ()).platform .colorTextView (
137+ binding .noteTitle , ColorRole .ON_SURFACE
138+ );
139+ BrandingUtil .of (color , parent .getContext ()).platform .colorTextView (
140+ binding .noteExcerpt , ColorRole .ON_SURFACE_VARIANT
141+ );
142+ BrandingUtil .of (color , parent .getContext ()).platform .colorTextView (
143+ binding .noteModified , ColorRole .ON_SURFACE_VARIANT
144+ );
128145 return new NoteViewGridHolder (binding , noteClickListener , monospace , fontSize );
129146 }
130147 default -> {
@@ -139,8 +156,18 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
139156 return new SectionViewHolder (binding );
140157 }
141158 case TYPE_NOTE_WITH_EXCERPT , TYPE_NOTE_ONLY_TITLE , TYPE_NOTE_WITHOUT_EXCERPT -> {
142- ItemNotesListNoteItemWithExcerptBinding binding = ItemNotesListNoteItemWithExcerptBinding .inflate (inflater , parent , false );
159+ ItemNotesListNoteItemWithExcerptBinding binding = ItemNotesListNoteItemWithExcerptBinding
160+ .inflate (inflater , parent , false );
143161 BrandingUtil .of (color , parent .getContext ()).notes .themeCard (binding .noteCard );
162+ BrandingUtil .of (color , parent .getContext ()).platform .colorTextView (
163+ binding .noteTitle , ColorRole .ON_SURFACE
164+ );
165+ BrandingUtil .of (color , parent .getContext ()).platform .colorTextView (
166+ binding .noteExcerpt , ColorRole .ON_SURFACE_VARIANT
167+ );
168+ BrandingUtil .of (color , parent .getContext ()).platform .colorTextView (
169+ binding .noteModified , ColorRole .ON_SURFACE_VARIANT
170+ );
144171 return new NoteViewListHolder (binding , noteClickListener );
145172 }
146173 default -> {
@@ -166,18 +193,30 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
166193 case TYPE_SECTION ->
167194 ((SectionViewHolder ) holder ).bind ((SectionItem ) itemList .get (position ));
168195 case TYPE_NOTE_WITH_EXCERPT , TYPE_NOTE_WITHOUT_EXCERPT , TYPE_NOTE_ONLY_TITLE -> {
169- holder .itemView .findViewById (R .id .custom_checkbox ).setVisibility (tracker != null && tracker .hasSelection () ? View .VISIBLE : View .GONE );
196+ holder .itemView .findViewById (R .id .custom_checkbox ).setVisibility (tracker != null &&
197+ tracker .hasSelection () ? View .VISIBLE : View .GONE );
170198 holder .itemView .setSelected (isSelected );
171199 if (isSelected ) {
172200 ((MaterialCardView ) holder .itemView .findViewById (R .id .noteCard )).setStrokeWidth ((int ) holder .itemView .getResources ().getDimension (R .dimen .card_stroke_width_selected ));
173- ((ImageView ) holder .itemView .findViewById (R .id .custom_checkbox )).setImageDrawable (BrandingUtil .getInstance (holder .itemView .getContext ()).platform .tintDrawable (holder .itemView .getContext (), R .drawable .ic_checkbox_marked , ColorRole .PRIMARY ));
201+ ((ImageView ) holder .itemView .findViewById (R .id .custom_checkbox )).setImageDrawable (
202+ BrandingUtil .getInstance (holder .itemView .getContext ()).platform .tintDrawable (
203+ holder .itemView .getContext (), R .drawable .ic_checkbox_marked , ColorRole .PRIMARY )
204+ );
174205 } else {
175206 ((MaterialCardView ) holder .itemView .findViewById (R .id .noteCard )).setStrokeWidth ((int ) holder .itemView .getResources ().getDimension (R .dimen .card_stroke_width ));
176- ((ImageView ) holder .itemView .findViewById (R .id .custom_checkbox )).setImageResource (R .drawable .ic_checkbox_blank_outline );
207+ ((ImageView ) holder .itemView .findViewById (R .id .custom_checkbox )).setImageResource (
208+ R .drawable .ic_checkbox_blank_outline
209+ );
177210 }
178- holder .itemView .findViewById (R .id .custom_checkbox ).setVisibility (isMultiSelect ? View .VISIBLE : View .GONE );
179- holder .itemView .findViewById (R .id .noteFavorite ).setVisibility (isMultiSelect ? View .GONE : View .VISIBLE );
180- ((NoteViewHolder ) holder ).bind (isSelected , (Note ) itemList .get (position ), showCategory , color , searchQuery );
211+ holder .itemView .findViewById (R .id .custom_checkbox ).setVisibility (
212+ isMultiSelect ? View .VISIBLE : View .GONE
213+ );
214+ holder .itemView .findViewById (R .id .noteFavorite ).setVisibility (
215+ isMultiSelect ? View .GONE : View .VISIBLE
216+ );
217+ ((NoteViewHolder ) holder ).bind (
218+ isSelected , (Note ) itemList .get (position ), showCategory , color , searchQuery
219+ );
181220 }
182221 }
183222 }
@@ -270,4 +309,4 @@ public Integer getSwipedPosition() {
270309 public void setSwipedPosition (@ Nullable Integer swipedPosition ) {
271310 this .swipedPosition = swipedPosition ;
272311 }
273- }
312+ }
0 commit comments