全部✓ボタン挙動 WIP

This commit is contained in:
ろむねこ 2024-07-23 11:49:54 +09:00
parent f4b116cd27
commit a4986cffbc
Signed by: Fujimatsu
GPG Key ID: FA1F39A1BA37D168

View File

@ -5,6 +5,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@ -154,6 +155,19 @@ public class HistoryItemListAdapter extends RecyclerView.Adapter<HistoryItemList
// DEBUG: 月をまたぐデータがないので // DEBUG: 月をまたぐデータがないので
((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 -> {
// TODO: 一括で外すことも出来るように
// 判定が変わるまで全部チェックする
try {
int index = historyDataList.getList().indexOf(historyData);
while (!isFirstOfMonth(this.historyDataList.getList().get(index))) {
this.historyDataList.getList().get(index).setChecked(true);
index++;
}
} catch (IndexOutOfBoundsException e) {
// 1個しかない場合? Workaround
}
});
} }
} }
@ -207,11 +221,13 @@ public class HistoryItemListAdapter extends RecyclerView.Adapter<HistoryItemList
TextView monthHeaderTitle; TextView monthHeaderTitle;
TextView monthTotalTextView; TextView monthTotalTextView;
ImageButton checkAllButton;
public MonthHeaderViewHolder(@NonNull View itemView) { public MonthHeaderViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
monthHeaderTitle = itemView.findViewById(R.id.monthHeaderTitle); monthHeaderTitle = itemView.findViewById(R.id.monthHeaderTitle);
monthTotalTextView = itemView.findViewById(R.id.monthTotalTextView); monthTotalTextView = itemView.findViewById(R.id.monthTotalTextView);
checkAllButton = itemView.findViewById(R.id.checkAllButton);
} }
} }
} }