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 0408b4a..0b808fe 100644 --- a/app/src/main/java/com/example/citrusclient/views/HomeFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/HomeFragment.java @@ -188,7 +188,8 @@ month = curDate.getMonthValue(); day = curDate.getDayOfMonth(); curDateButton.setText(year + "年" + month + "月" + day + "日"); - + scheduleList.clear(); + scheduleAdapter.setSchedules(scheduleList, integerBookHashMap); scheduleAdapter.updateCurDate(curDate); updateTodoSchedule(integerBookHashMap); }); @@ -200,7 +201,8 @@ month = curDate.getMonthValue(); day = curDate.getDayOfMonth(); curDateButton.setText(year + "年" + month + "月" + day + "日"); - + scheduleList.clear(); + scheduleAdapter.setSchedules(scheduleList, integerBookHashMap); scheduleAdapter.updateCurDate(curDate); updateTodoSchedule(integerBookHashMap); @@ -208,7 +210,6 @@ booksViewModel.loadBooks(accountId, token); - scheduleViewModel.updateSchedulesByDay(accountId, year, month, day, token); System.out.println(token); booksViewModel.getBookLiveData().observe(getViewLifecycleOwner(), new Observer>() { @@ -241,7 +242,7 @@ scheduleList = new ArrayList<>(idScheduleHashMap.values()); scheduleAdapter.setSchedules(scheduleList, integerBookHashMap); } else { - scheduleList = new ArrayList<>(); + scheduleList.clear(); scheduleAdapter.setSchedules(scheduleList, integerBookHashMap); } } @@ -258,14 +259,13 @@ int curBookId = citrus.getCurBookId(); if (idBookHashMap != null) { + todoList.clear(); if(curBookId != -1) { - todoList = new ArrayList<>(); integerBookHashMap = new HashMap<>(); Book book = idBookHashMap.get(curBookId); integerBookHashMap.put(curBookId, book); todosViewModel.loadTodosByDay(accountId, curBookId, year, month, day, token); } else { - todoList = new ArrayList<>(); integerBookHashMap = new HashMap<>(idBookHashMap); for (Book book : integerBookHashMap.values()) { todosViewModel.loadTodosByDay(accountId, book.getBookId(), year, month, day, token);