mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-26 14:57:38 +03:00
Use stable ids in adapter
This commit is contained in:
parent
6b0e47da85
commit
56ab5105e7
3 changed files with 13 additions and 5 deletions
|
@ -47,6 +47,14 @@ public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i
|
|||
this.gridView = gridView;
|
||||
this.mainColor = context.getResources().getColor(R.color.defaultBrand);
|
||||
this.textColor = Color.WHITE;
|
||||
setHasStableIds(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return getItemViewType(position) == TYPE_SECTION
|
||||
? ((SectionItem) getItem(position)).getTitle().hashCode()
|
||||
: ((DBNote) getItem(position)).getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -138,7 +138,6 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder implements
|
|||
}
|
||||
|
||||
private void bindContent(@NonNull TextView textView, @NonNull CharSequence charSequence) {
|
||||
textView.setText(charSequence);
|
||||
if (renderMarkdown) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
|
@ -148,6 +147,8 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder implements
|
|||
// Workaround for RxMarkdown: https://github.com/stefan-niedermann/nextcloud-notes/issues/668
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
textView.setText(charSequence);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,13 +11,12 @@ public class SectionViewHolder extends RecyclerView.ViewHolder {
|
|||
public SectionViewHolder(ItemNotesListSectionItemBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
|
||||
if (itemView.getLayoutParams() != null && itemView.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
|
||||
((StaggeredGridLayoutManager.LayoutParams) itemView.getLayoutParams()).setFullSpan(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void bind(SectionItem item) {
|
||||
binding.sectionTitle.setText(item.getTitle());
|
||||
if (itemView.getLayoutParams() != null && itemView.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
|
||||
((StaggeredGridLayoutManager.LayoutParams) itemView.getLayoutParams()).setFullSpan(true);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue