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 2cb1e01..aa273f6 100644 --- a/app/src/main/java/com/example/citrusclient/views/CalendarFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/CalendarFragment.java @@ -173,6 +173,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + tableLayout = view.findViewById(R.id.calendarlayout); Calendar calendar = Calendar.getInstance(); year = calendar.get(Calendar.YEAR); //現在の年 @@ -197,7 +198,7 @@ Button prevMonth = view.findViewById(R.id.prevMonth); FloatingActionButton createBook = view.findViewById(R.id.floatingActionButton); TextView curMonth = view.findViewById(R.id.month); - curMonth.setText("" + month + "月"); + curMonth.setText(year + "年" + month + "月"); createBook.setOnClickListener(new View.OnClickListener() { @Override @@ -212,8 +213,9 @@ month++; if(month > 12){ month = 1; + year++; } - curMonth.setText("" + month + "月"); + curMonth.setText(year + "年" + month + "月"); //指定した年月の一日の曜日を取得 LocalDate firstDay = LocalDate.of(year, month, 1); DayOfWeek dayOfWeek = firstDay.getDayOfWeek(); @@ -239,7 +241,7 @@ if(i==2&&j==1)schedules.add(new Schedule("cat", "3232", "yyyy", 0, 5)); if(i==2&&j==1)schedules.add(new Schedule("cat", "3232", "yyyy", 0, 5)); if(i==2&&j==1)schedules.add(new Schedule("cat", "3232", "yyyy", 0, 5)); - ((MyScheduleAdapter) recyclerView.getAdapter()).setSchedules(schedules); + ((MyScheduleAdapter) recyclerView.getAdapter()).setSchedules(schedules, integerBookHashMap); ((TextView) layout.getChildAt(0)).setText(days[i][j]); if(i == 2 && j == 1) Log.i("kjda", layout.getLayoutParams().height + ""); } @@ -253,8 +255,9 @@ month--; if(month < 1) { month = 12; + year--; } - curMonth.setText("" + month + "月"); + curMonth.setText(year + "年" + month + "月"); //指定した年月の一日の曜日を取得 LocalDate firstDay = LocalDate.of(year, month, 1); DayOfWeek dayOfWeek = firstDay.getDayOfWeek(); @@ -279,7 +282,7 @@ schedules.add(new Schedule("abc", "3232", "yyyy", 0, 1)); schedules.add(new Schedule("123", "3232", "yyyy", 0, 2)); if(i==2&&j==1)schedules.add(new Schedule("cat", "3232", "yyyy", 0, 5)); - ((MyScheduleAdapter) recyclerView.getAdapter()).setSchedules(schedules); + ((MyScheduleAdapter) recyclerView.getAdapter()).setSchedules(schedules, integerBookHashMap); ((TextView) layout.getChildAt(0)).setText(days[i][j]); } } @@ -305,7 +308,7 @@ List schedules = new ArrayList<>(); schedules.add(new Schedule("abc", "3232", "yyyy", 0, 1)); schedules.add(new Schedule("123", "3232", "yyyy", 0, 2)); - recyclerView.setAdapter(new MyScheduleAdapter(schedules)); + recyclerView.setAdapter(new MyScheduleAdapter(schedules, integerBookHashMap)); layout.addView(recyclerView); layout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override @@ -329,7 +332,7 @@ private List scheduleList; private HashMap integerBookHashMap; - MyScheduleAdapter(List schedules) { + MyScheduleAdapter(List schedules, HashMap integerBookHashMap) { this.scheduleList = schedules; if(integerBookHashMap != null) { this.integerBookHashMap = new HashMap<>(integerBookHashMap); @@ -338,7 +341,7 @@ } } - public void setSchedules(List schedules) { + public void setSchedules(List schedules, HashMap integerBookHashMap) { scheduleList = schedules; if(integerBookHashMap != null) { this.integerBookHashMap = new HashMap<>(integerBookHashMap);