Skip to content

Commit

Permalink
[FIX] - 스크롤 Reload 자연스럽게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jung0115 committed Aug 23, 2024
1 parent 991a7d3 commit 75f6328
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PostImagesAdapter(
binding.relativePostImage.layoutParams.height = binding.relativePostImage.width
binding.relativePostImage.requestLayout()

notifyItemChanged(position)
// notifyItemChanged(position)
}
else {
notifyItemChanged(position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home),
override fun onResume() {
super.onResume()

binding.includeListLoading.visibility = View.VISIBLE
setHomeBanner() // 배너
setPostList() // 포스트
}
Expand All @@ -52,7 +53,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home),

navController = view.findNavController()
binding.includeListLoading.visibility = View.VISIBLE
binding.emptyPostList.visibility = View.GONE

binding.scrollHomeBannerNPost.isSmoothScrollingEnabled = true
binding.scrollHomeBannerNPost.post {
Expand Down Expand Up @@ -82,12 +82,12 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home),
postListAdapter.notifyItemRangeInserted(rangeEnd - count, rangeEnd)
}

binding.emptyPostList.visibility = View.GONE
}
else if(viewModel.bannerListUiState.value.isNullOrEmpty()) {
binding.includeListLoading.visibility = View.GONE
binding.emptyPostList.visibility = View.VISIBLE
// binding.emptyPostList.visibility = View.GONE
}
// else if(viewModel.bannerListUiState.value.isNullOrEmpty()) {
// binding.includeListLoading.visibility = View.GONE
// binding.emptyPostList.visibility = View.VISIBLE
// }
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ class HomeViewModel @Inject constructor(
viewModelScope.launch {
try {
_isPostListLoading.emit(true) // 스크롤 이벤트가 연속적으로 호출되는 것을 방지
if(!isCursor) _postCursor.setValue(null)

val homePostList = withContext(Dispatchers.IO) {
getHomePostListUseCase(postCursor.value, postLimit.value)
if(!isCursor) {
_postCursor.setValue(null)
_postListUiState.emit(mutableListOf())
}

val homePostList = getHomePostListUseCase(postCursor.value, postLimit.value)

if (isCursor) _postListUiState.value.addAll(homePostList.posts)
else _postListUiState.emit(homePostList.posts.toMutableList())

Expand Down

0 comments on commit 75f6328

Please sign in to comment.