diff --git a/app/src/main/java/com/example/citrusclient/views/HomeFragment.java b/app/src/main/java/com/example/citrusclient/views/HomeFragment.java index 1006c55..73ddb7d 100644 --- a/app/src/main/java/com/example/citrusclient/views/HomeFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/HomeFragment.java @@ -150,7 +150,7 @@ todoRecyclerView.setHasFixedSize(true); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(view.getContext()); todoRecyclerView.setLayoutManager(layoutManager); - MyTodoshelfAdapter todoAdapter = new MyTodoshelfAdapter(todoList, integerBookHashMap, todosViewModel, citrus); + MyTodoshelfAdapter todoAdapter = new MyTodoshelfAdapter(todoList, integerBookHashMap, todosViewModel, citrus, getActivity()); todoRecyclerView.setAdapter(todoAdapter); RecyclerView scheduleRecyclerView = view.findViewById(R.id.my_schedule_list); @@ -163,7 +163,7 @@ FloatingActionButton todoAddButton = view.findViewById(R.id.todo_add_button); todoAddButton.setOnClickListener(v -> { - ((MainActivity) getActivity()).showFragment(new CreateTodoFragment()); + ((MainActivity) getActivity()).showFragment(new CreateTodoFragment(year, month, day)); }); FloatingActionButton scheduleAddButton = view.findViewById(R.id.schedule_add_button); @@ -280,8 +280,11 @@ private Citrus citrus; private String accountId; private String token; + private Context context; - MyTodoshelfAdapter(List todos, HashMap idBookHashMap, TodosViewModel todosViewModel, Citrus citrus) { + + + MyTodoshelfAdapter(List todos, HashMap idBookHashMap, TodosViewModel todosViewModel, Citrus citrus, Context context) { this.citrus = citrus; this.token = citrus.getToken(); this.accountId = citrus.getAccountId(); @@ -292,6 +295,7 @@ } else { this.idBookHashMap = new HashMap<>(); // 空のHashMapを作成 } + this.context = context; } public void setTodos(List todos ,HashMap idBookHashMap) { @@ -325,6 +329,11 @@ holder.todoButton.setTextColor(Color.rgb(255 - red, 255 - green, 255 - blue)); } + holder.todoButton.setOnClickListener(v -> { + Activity activity = (Activity) context; + ((MainActivity) activity).showFragment(new CreateTodoFragment(todoData)); + }); + holder.todoCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> { // チェック状態が変更された時の処理を記述 if (isChecked) { @@ -343,6 +352,10 @@ return todoList.size(); } + public void sortTodosById(Todo todo) { + notifyDataSetChanged(); + } + static class MyTodoViewHolder extends RecyclerView.ViewHolder { Button todoButton; CheckBox todoCheckBox;