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 f0b35ff..a73523a 100644 --- a/app/src/main/java/com/example/citrusclient/views/HomeFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/HomeFragment.java @@ -34,9 +34,12 @@ import java.security.PrivateKey; import java.util.ArrayList; +import java.util.Calendar; import java.util.HashMap; import java.util.List; +import java.time.LocalDate; + /** * A simple {@link Fragment} subclass. * Use the {@link HomeFragment#newInstance} factory method to @@ -107,6 +110,11 @@ private HashMap integerBookHashMap; BooksViewModel booksViewModel; + private LocalDate openDate; + int year; + int month; + int day; + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); @@ -114,18 +122,19 @@ Citrus citrus = (Citrus)(getActivity().getApplication()); String token = citrus.getToken(); String accountId = citrus.getAccountId(); - int year = citrus.getCurYear(); - int month = citrus.getCurMouth(); -// int day = citrus.getCurDay(); - int day = 14; + year = citrus.getCurYear(); + month = citrus.getCurMonth(); + day = citrus.getCurDay(); + int curBookId = citrus.getCurBookId(); + openDate = LocalDate.of(year, month, day); todoList = new ArrayList<>(); scheduleList = new ArrayList<>(); - TextView curYMD = view.findViewById(R.id.year_month_day); - curYMD.setText(year + "年" + month + "月" + day + "日"); + TextView curDate = view.findViewById(R.id.year_month_day); + curDate.setText(year + "年" + month + "月" + day + "日"); RecyclerView todoRecyclerView = view.findViewById(R.id.my_todos_list); @@ -157,6 +166,7 @@ todosViewModel.loadTodosByDay(accountId, curBookId, year, month, day, token); citrus.setCurBookId(-1); } else { + todoList = new ArrayList<>(); integerBookHashMap = new HashMap<>(idBookHashMap); for (Book book : integerBookHashMap.values()) { todosViewModel.loadTodosByDay(accountId, book.getBookId(), year, month, day, token); @@ -187,9 +197,23 @@ } }); - } + FloatingActionButton todoAddButton = view.findViewById(R.id.todo_add_button); + todoAddButton.setOnClickListener(v -> { + ((MainActivity) getActivity()).showFragment(new CreateTodoFragment()); + }); - void setCheck(){ + FloatingActionButton scheduleAddButton = view.findViewById(R.id.schedule_add_button); + scheduleAddButton.setOnClickListener(v -> { + ((MainActivity) getActivity()).showFragment(new CreateScheduleFragment()); + }); + +// FloatingActionButton prevBotton = view.findViewById(R.id.prev_day_botton); +// prevBotton.setOnClickListener(v -> { +// openDate = openDate.minusDays(1); +// year = openDate.getYear(); +// month = openDate.getMonthValue(); +// day = openDate.getDayOfMonth(); +// }); }