diff --git a/app/src/main/java/com/example/citrusclient/views/CalendarFragment.java b/app/src/main/java/com/example/citrusclient/views/CalendarFragment.java index 12984f0..bc701ca 100644 --- a/app/src/main/java/com/example/citrusclient/views/CalendarFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/CalendarFragment.java @@ -130,7 +130,7 @@ HashMap books; HashMap> schedules; - HashMap> todos; + HashMap> todos; public TextView[][] calendar(int firstDayOfWeek, int prevMonthDay, int lastDay) { int curDay = 1; @@ -233,10 +233,10 @@ if(integerHashMapHashMap != null && !integerHashMapHashMap.isEmpty()) { for (int day : integerHashMapHashMap.keySet()) { if (todos.get(day) == null) { - todos.put(day, new HashMap<>()); + todos.put(day, new ArrayList<>()); } for (int todoId : integerHashMapHashMap.get(day).keySet()) { - todos.get(day).put(todoId, integerHashMapHashMap.get(day).get(todoId)); + todos.get(day).add(integerHashMapHashMap.get(day).get(todoId)); } } } @@ -299,7 +299,10 @@ month = 1; year++; } + todos.clear(); scheduleViewModel.updateSchedulesByMonth(accountId, year, month, token); + booksViewModel.loadBooks(accountId, token); + updateCalendar(curMonth); } }); @@ -312,7 +315,10 @@ month = 12; year--; } + todos.clear(); scheduleViewModel.updateSchedulesByMonth(accountId, year, month, token); + booksViewModel.loadBooks(accountId, token); + updateCalendar(curMonth); } }); @@ -438,7 +444,7 @@ if(select != -1){ if(select == R.id.rbTodo){ if (this.todos.get(Integer.parseInt(days[i][j])) != null) { - for (Todo schedule : this.todos.get(Integer.parseInt(days[i][j])).values()) { + for (Todo schedule : this.todos.get(Integer.parseInt(days[i][j]))) { schedules.add(schedule); } } @@ -450,7 +456,7 @@ } } else { if (this.todos.get(Integer.parseInt(days[i][j])) != null) { - for (Todo schedule : this.todos.get(Integer.parseInt(days[i][j])).values()) { + for (Todo schedule : this.todos.get(Integer.parseInt(days[i][j]))) { schedules.add(schedule); } } diff --git a/app/src/main/java/com/example/citrusclient/views/OtherCalendarFragment.java b/app/src/main/java/com/example/citrusclient/views/OtherCalendarFragment.java index 0161adb..4001914 100644 --- a/app/src/main/java/com/example/citrusclient/views/OtherCalendarFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/OtherCalendarFragment.java @@ -68,6 +68,11 @@ month = calendar.get(Calendar.MONTH) + 1; //現在の月 } + public OtherCalendarFragment(int year, int month) { + this.year = year; + this.month = month; + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -106,7 +111,7 @@ HashMap books; private Book book; HashMap> schedules; - HashMap> todos; + HashMap> todos; public TextView[][] calendar(int firstDayOfWeek, int prevMonthDay, int lastDay) { int curDay = 1; @@ -195,8 +200,6 @@ } todosViewModel.loadTodosByMonth(accountId, book.getBookId(), year, month, token); updateCalendar(curMonth); - Log.d("Debug", "Book: " + book); - Log.d("Debug", "Color: " + (book != null ? book.getColor() : "No color")); } } }); @@ -207,11 +210,9 @@ TextView curMonth = view.findViewById(R.id.otherMonth); if(integerHashMapHashMap != null && !integerHashMapHashMap.isEmpty()) { for (int day : integerHashMapHashMap.keySet()) { - if (todos.get(day) == null) { - todos.put(day, new HashMap<>()); - } + todos.put(day, new ArrayList<>()); for (int todoId : integerHashMapHashMap.get(day).keySet()) { - todos.get(day).put(todoId, integerHashMapHashMap.get(day).get(todoId)); + todos.get(day).add(integerHashMapHashMap.get(day).get(todoId)); } } } @@ -260,8 +261,11 @@ month = 1; year++; } + todos.clear(); scheduleViewModel.updateSchedulesByMonthAndBookId(accountId, year, month, token, bookId); + booksViewModel.loadBook(accountId, token, bookId); todosViewModel.loadTodosByMonth(accountId, bookId, year, month, token); + updateCalendar(curMonth); } }); @@ -274,8 +278,11 @@ month = 12; year--; } + todos.clear(); scheduleViewModel.updateSchedulesByMonthAndBookId(accountId, year, month, token, bookId); + booksViewModel.loadBook(accountId, token, bookId); todosViewModel.loadTodosByMonth(accountId, bookId, year, month, token); + updateCalendar(curMonth); } }); @@ -407,7 +414,7 @@ if(select != -1){ if(select == R.id.otherRbTodo){ if (this.todos.get(Integer.parseInt(days[i][j])) != null) { - for (Todo schedule : this.todos.get(Integer.parseInt(days[i][j])).values()) { + for (Todo schedule : this.todos.get(Integer.parseInt(days[i][j]))) { schedules.add(schedule); } } @@ -419,7 +426,7 @@ } } else { if (this.todos.get(Integer.parseInt(days[i][j])) != null) { - for (Todo schedule : this.todos.get(Integer.parseInt(days[i][j])).values()) { + for (Todo schedule : this.todos.get(Integer.parseInt(days[i][j]))) { schedules.add(schedule); } }