Skip to content

Commit

Permalink
즐겨찾기한 학사일정 연도 전환 버튼 버그 수정 (#43)
Browse files Browse the repository at this point in the history
* 🔨 최근 즐겨찾기한 학사일정 3개 조회 연도 추가

* 🔨 즐겨찾기한 학사일정 연도 전환 버튼 버그 수정
  • Loading branch information
GyeongminKimGyeongminKim authored Oct 1, 2024
1 parent 474f16a commit 648eeb3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,20 @@ class FavoriteScheduleFragment : BaseFragment<FragmentFavoriteScheduleBinding>()
}

private fun hideArrowButton() {
LoggerUtil.d(currentIndex.toString())
if (yearList.size-1 < currentIndex!!+1) {
binding.ibRightArrow.visibility = View.GONE
} else {
binding.ibRightArrow.visibility = View.VISIBLE
}
if (yearList.size-1 > currentIndex!!-1) {
LoggerUtil.d("${yearList.size}, ${currentIndex}")
// 현재 인덱스가 0일 경우 왼쪽 화살표 숨김, 아니면 보임
if (currentIndex == 0) {
binding.ibLeftArrow.visibility = View.GONE
} else {
binding.ibLeftArrow.visibility = View.VISIBLE
}

// 현재 인덱스가 마지막 인덱스일 경우 오른쪽 화살표 숨김, 아니면 보임
if (currentIndex == yearList.size - 1) {
binding.ibRightArrow.visibility = View.GONE
} else {
binding.ibRightArrow.visibility = View.VISIBLE
}
}

override fun initListener() {
Expand All @@ -112,15 +115,16 @@ class FavoriteScheduleFragment : BaseFragment<FragmentFavoriteScheduleBinding>()
(requireActivity() as HomeActivity).binding.bottomNavigation.selectedItemId = R.id.navigation_home
}
binding.ibLeftArrow.setOnClickListener {
favoriteScheduleAdapter.setList(year = yearList.elementAt(currentIndex!!-1))
binding.tvYear.text = yearList.elementAt(currentIndex!!-1).toString()
currentIndex = currentIndex!!-1
currentIndex = currentIndex!! - 1
favoriteScheduleAdapter.setList(year = yearList.elementAt(currentIndex!!))
binding.tvYear.text = yearList.elementAt(currentIndex!!).toString()
hideArrowButton()
}

binding.ibRightArrow.setOnClickListener {
favoriteScheduleAdapter.setList(year = yearList.elementAt(currentIndex!!+1))
binding.tvYear.text = yearList.elementAt(currentIndex!!+1).toString()
currentIndex = currentIndex!!+1
currentIndex = currentIndex!! + 1
favoriteScheduleAdapter.setList(year = yearList.elementAt(currentIndex!!))
binding.tvYear.text = yearList.elementAt(currentIndex!!).toString()
hideArrowButton()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class MyPageFavoriteScheduleAdapter(private val schedules: List<RecentBookmarkSc

fun bind(schedule: RecentBookmarkSchedule) {
val inputFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
val outputFormat = SimpleDateFormat("MM.dd", Locale.getDefault())
val outputFormat = SimpleDateFormat("yyyy.MM.dd", Locale.getDefault())

try {
val date = inputFormat.parse(schedule.startDate)
val formattedDate = date?.let { outputFormat.format(it) }
binding.tvScheduleDate.text = formattedDate // 월.일 형식으로 변환
binding.tvScheduleDate.text = formattedDate // 연.월.일 형식으로 변환
} catch (e: Exception) {
e.printStackTrace()
binding.tvScheduleDate.text = schedule.startDate // 파싱 실패 시 원본 날짜 표시
Expand Down

0 comments on commit 648eeb3

Please sign in to comment.