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 47a0b82..3dba52e 100644 --- a/app/src/main/java/com/example/citrusclient/views/CalendarFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/CalendarFragment.java @@ -11,7 +11,6 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -19,7 +18,6 @@ import android.widget.Button; import android.widget.LinearLayout; import android.widget.RadioGroup; -import android.widget.RatingBar; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; @@ -190,7 +188,7 @@ scheduleViewModel.getSchedulesByMonth().observe(getViewLifecycleOwner(), new Observer>>() { @Override public void onChanged(HashMap> integerHashMapHashMap) { - TextView curMonth = view.findViewById(R.id.month); + TextView curMonth = view.findViewById(R.id.Month); schedules = integerHashMapHashMap; updateCalendar(curMonth); } @@ -201,7 +199,7 @@ public void onChanged(HashMap integerBookHashMap) { books = integerBookHashMap; if(books != null) { - TextView curMonth = view.findViewById(R.id.month); + TextView curMonth = view.findViewById(R.id.Month); if(todos != null) { todos.clear(); } else { @@ -220,13 +218,15 @@ todosViewModel.getTodosByMonthLiveData().observe(getViewLifecycleOwner(), new Observer>>() { @Override public void onChanged(HashMap> integerHashMapHashMap) { - TextView curMonth = view.findViewById(R.id.month); - for (int day:integerHashMapHashMap.keySet()){ - if(todos.get(day) == null){ - todos.put(day, new HashMap<>()); - } - for(int todoId:integerHashMapHashMap.get(day).keySet()){ - todos.get(day).put(todoId, integerHashMapHashMap.get(day).get(todoId)); + TextView curMonth = view.findViewById(R.id.Month); + if(integerHashMapHashMap != null && !integerHashMapHashMap.isEmpty()) { + for (int day : integerHashMapHashMap.keySet()) { + if (todos.get(day) == null) { + todos.put(day, new HashMap<>()); + } + for (int todoId : integerHashMapHashMap.get(day).keySet()) { + todos.get(day).put(todoId, integerHashMapHashMap.get(day).get(todoId)); + } } } updateCalendar(curMonth); @@ -235,7 +235,6 @@ booksViewModel.loadBooks(accountId, token); - tableLayout = view.findViewById(R.id.calendarlayout); Calendar calendar = Calendar.getInstance(); year = calendar.get(Calendar.YEAR); //現在の年 @@ -258,10 +257,10 @@ DayOfWeek dayOfWeek = firstDay.getDayOfWeek(); int firstDayOfWeek = dayOfWeek.getValue(); - Button nextMonth = view.findViewById(R.id.nextMonth); - Button prevMonth = view.findViewById(R.id.prevMonth); + Button nextMonth = view.findViewById(R.id.NextMonth); + Button prevMonth = view.findViewById(R.id.PrevMonth); FloatingActionButton createBook = view.findViewById(R.id.floatingActionButton); - TextView curMonth = view.findViewById(R.id.month); + TextView curMonth = view.findViewById(R.id.Month); curMonth.setText(year + "年" + month + "月"); createBook.setOnClickListener(new View.OnClickListener() { @@ -374,7 +373,7 @@ String[][] days = calendarString(firstDayOfWeek, prevMonthDay, lastDay); int one = 0; - RadioGroup selectButton = getView().findViewById(R.id.selectButton); + RadioGroup selectButton = getView().findViewById(R.id.SelectButton); for(int i = 0; i < 6; i++) { TableRow tableRow = (TableRow) tableLayout.getChildAt(i);