use of com.faltenreich.diaguard.feature.timeline.table.CategoryImageListItem in project Diaguard by Faltenreich.
the class TimelineDayFragment method invalidateList.
public void invalidateList() {
if (isAdded() && !data.needsListData()) {
Log.d(TAG, "Invalidating view for list on " + data.getDay().toString());
List<CategoryValueListItem> valueListItems = data.getListData();
if (valueAdapter.getItemCount() > 0) {
for (int index = 0; index < valueListItems.size(); index++) {
CategoryValueListItem listItem = valueListItems.get(index);
RecyclerView.ViewHolder viewHolder = valueListView.findViewHolderForAdapterPosition(index);
if (viewHolder instanceof CategoryValueViewHolder) {
valueAdapter.setItem(listItem, index);
// We access the ViewHolder directly for better performance compared to notifyItem(Range)Changed
CategoryValueViewHolder categoryValueViewHolder = (CategoryValueViewHolder) viewHolder;
categoryValueViewHolder.bind(listItem);
}
}
} else {
for (Category category : categories) {
imageAdapter.addItem(new CategoryImageListItem(category));
}
imageAdapter.notifyDataSetChanged();
// Other notify methods lead to rendering issues on view paging
valueAdapter.addItems(valueListItems);
valueAdapter.notifyDataSetChanged();
}
}
}
Aggregations