Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#111 [hotfix] 데일리 루틴 추가 시 아무것도 누르지 않고 추가했을 때 앱 터짐 이슈 해결 #115

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ class DailyRoutineAddActivity :
})
}

private fun getCurrentSelectedRoutine(): Routine {
private fun getCurrentSelectedRoutine(): Routine? {
val currentItem = binding.vpDailyRoutineAddCard.currentItem
val itemId = dailyRoutineAddCardPagerAdapter.getItemId(currentItem)
val itemContent = dailyRoutineAddCardPagerAdapter.content
return Routine(itemId.toInt(), itemContent)
?: dailyRoutineAddViewModel.dailyRoutineCardThemeList.value?.routine?.get(0)?.content
return itemContent?.let { content -> Routine(itemId.toInt(), content) }
}

private fun getCurrentSelectedRoutineId(): Int {
Expand All @@ -205,9 +206,10 @@ class DailyRoutineAddActivity :
BindingBottomSheet.Builder().build(
isDrawable = false,
imageDrawable = 0,
imageUri = dailyRoutineAddThemeAdapter.clickedThemeIcon,
imageUri = dailyRoutineAddThemeAdapter.clickedThemeIcon ?: "",
title = getString(R.string.daily_routine_add_question),
content = getCurrentSelectedRoutine().content,
content = getCurrentSelectedRoutine()?.content
?: getString(R.string.daily_routine_basic_bottom_sheet_content),
isContentVisible = true,
contentColor = R.color.gray400,
backBtnContent = getString(R.string.daily_routine_add_no),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DailyRoutineAddCardPagerAdapter :
)
) {
lateinit var background: String
lateinit var content: String
var content: String? = null
fun updateBackground(backgroundImg: String) {
background = backgroundImg
}
Expand All @@ -33,6 +33,7 @@ class DailyRoutineAddCardPagerAdapter :
}

override fun onBindViewHolder(holder: DailyPagerViewHolder, position: Int) {
if (content == null) content = currentList[0].content
holder.onBind(currentList[position])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DailyRoutineAddThemeAdapter :
private var onItemClickListener: OnItemClickListener? = null
private var selectedPosition = 0
var clickedThemeId: Int = 1
lateinit var clickedThemeIcon: String
var clickedThemeIcon: String? = null

interface OnItemClickListener {
fun onItemClick(item: Theme, position: Int)
Expand Down Expand Up @@ -113,6 +113,7 @@ class DailyRoutineAddThemeAdapter :
}

override fun onBindViewHolder(holder: DailyThemeViewHolder, position: Int) {
if (clickedThemeIcon == null) clickedThemeIcon = currentList[0].iconImageUrl
holder.onBind(currentList[position])
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,6 @@
<string name="daily_routine_add_no">아니, 더 고민할게</string>
<string name="daily_routine_add_yes">추가할래</string>
<string name="daily_routine_snack_bar">데일리 루틴을 1개 추가했어요</string>
<string name="daily_routine_basic_bottom_sheet_content">언제든지 변경할 수 있어요!</string>

</resources>