効率化, リファクタ, 修正
This commit is contained in:
parent
161d9d7602
commit
4916c05b08
|
@ -156,16 +156,20 @@ public class HistoryItemListAdapter extends RecyclerView.Adapter<HistoryItemList
|
||||||
((MonthHeaderViewHolder) holder).monthHeaderTitle.setText(historyData.getRegisteredAt().getDate() + "日");
|
((MonthHeaderViewHolder) holder).monthHeaderTitle.setText(historyData.getRegisteredAt().getDate() + "日");
|
||||||
((MonthHeaderViewHolder) holder).monthTotalTextView.setText(getMonthTotal(historyData) + "円");
|
((MonthHeaderViewHolder) holder).monthTotalTextView.setText(getMonthTotal(historyData) + "円");
|
||||||
((MonthHeaderViewHolder) holder).checkAllButton.setOnClickListener(v -> {
|
((MonthHeaderViewHolder) holder).checkAllButton.setOnClickListener(v -> {
|
||||||
// TODO: 一括で外すことも出来るように
|
// 次のヘッダーまでの間のアイテムを全てチェックする
|
||||||
// 判定が変わるまで全部チェックする
|
int index = position + 1;
|
||||||
try {
|
try {
|
||||||
int index = historyDataList.getList().indexOf(historyData);
|
|
||||||
while (!isFirstOfMonth(this.historyDataList.getList().get(index))) {
|
while (!isFirstOfMonth(this.historyDataList.getList().get(index))) {
|
||||||
this.historyDataList.getList().get(index).setChecked(true);
|
this.historyDataList.getList().get(index).setChecked(true);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
// 自身を更新 Workaround: なぜかindexを+1しないとチェックをつけれないので
|
||||||
|
this.historyDataList.getList().get(position).setChecked(true);
|
||||||
|
// 表示更新
|
||||||
|
notifyItemRangeChanged(position, index - position);
|
||||||
|
// notifyDataSetChanged();
|
||||||
} catch (IndexOutOfBoundsException e) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
// 1個しかない場合? Workaround
|
// 1個しかない場合 Workaround
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user