diff --git a/domain/src/main/java/com/teamdontbe/domain/entity/CommentEntity.kt b/domain/src/main/java/com/teamdontbe/domain/entity/CommentEntity.kt index c991bb2a3..a0dd75f27 100644 --- a/domain/src/main/java/com/teamdontbe/domain/entity/CommentEntity.kt +++ b/domain/src/main/java/com/teamdontbe/domain/entity/CommentEntity.kt @@ -6,8 +6,8 @@ data class CommentEntity( val memberNickname: String, val isGhost: Boolean, val memberGhost: Int, - val isLiked: Boolean, - val commentLikedNumber: Int, + var isLiked: Boolean, + var commentLikedNumber: Int, val contentText: String, val time: String, val commentId: Int, diff --git a/domain/src/main/java/com/teamdontbe/domain/entity/FeedEntity.kt b/domain/src/main/java/com/teamdontbe/domain/entity/FeedEntity.kt index a37648645..3d9c415bf 100644 --- a/domain/src/main/java/com/teamdontbe/domain/entity/FeedEntity.kt +++ b/domain/src/main/java/com/teamdontbe/domain/entity/FeedEntity.kt @@ -4,10 +4,10 @@ data class FeedEntity( val memberId: Int, val memberProfileUrl: String, val memberNickname: String, - val isLiked: Boolean, + var isLiked: Boolean, val isGhost: Boolean, val memberGhost: Int, - val contentLikedNumber: Int, + var contentLikedNumber: Int, val commentNumber: Int, val contentText: String, val time: String, diff --git a/feature/src/main/java/com/teamdontbe/feature/home/HomeFragment.kt b/feature/src/main/java/com/teamdontbe/feature/home/HomeFragment.kt index 3511b5896..205bbe4fa 100644 --- a/feature/src/main/java/com/teamdontbe/feature/home/HomeFragment.kt +++ b/feature/src/main/java/com/teamdontbe/feature/home/HomeFragment.kt @@ -29,14 +29,12 @@ import com.teamdontbe.feature.util.pagingSubmitData import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import timber.log.Timber @AndroidEntryPoint class HomeFragment : BindingFragment(R.layout.fragment_home) { private val homeViewModel by activityViewModels() private lateinit var homeFeedAdapter: HomePagingFeedAdapter - private var deleteFeedPosition: Int = -1 override fun initView() { statusBarColorOf(R.color.gray_1) @@ -81,7 +79,6 @@ class HomeFragment : BindingFragment(R.layout.fragment_home feedData.memberId == homeViewModel.getMemberId(), it, ) - deleteFeedPosition = position } } @@ -179,10 +176,7 @@ class HomeFragment : BindingFragment(R.layout.fragment_home } private fun handleDeleteFeedSuccess() { - if (deleteFeedPosition != -1) { - homeFeedAdapter.deleteItem(deleteFeedPosition) - deleteFeedPosition = -1 - } + homeFeedAdapter.refresh() val dialog = DeleteCompleteDialogFragment() dialog.show(childFragmentManager, DELETE_POSTING) } @@ -217,7 +211,7 @@ class HomeFragment : BindingFragment(R.layout.fragment_home homeFeedAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { super.onItemRangeInserted(positionStart, itemCount) - binding.rvHome.smoothScrollToPosition(0) + if (positionStart == 0) scrollRecyclerViewToTop() homeFeedAdapter.unregisterAdapterDataObserver(this) } }) diff --git a/feature/src/main/java/com/teamdontbe/feature/home/viewholder/HomeFeedViewHolder.kt b/feature/src/main/java/com/teamdontbe/feature/home/viewholder/HomeFeedViewHolder.kt index 50c91fb0c..654e9b2e3 100644 --- a/feature/src/main/java/com/teamdontbe/feature/home/viewholder/HomeFeedViewHolder.kt +++ b/feature/src/main/java/com/teamdontbe/feature/home/viewholder/HomeFeedViewHolder.kt @@ -69,8 +69,10 @@ class HomeFeedViewHolder( onClickLikedBtn(contentId, btnHomeHeart.isSelected) } val likeNumber = tvHomeHeartNum.text.toString() - tvHomeHeartNum.text = - if (btnHomeHeart.isSelected) (likeNumber.toInt() - 1).toString() else (likeNumber.toInt() + 1).toString() + val likeNumberChanged = if (btnHomeHeart.isSelected) (likeNumber.toInt() - 1) else (likeNumber.toInt() + 1) + tvHomeHeartNum.text = likeNumberChanged.toString() + data.isLiked = !btnHomeHeart.isSelected + data.contentLikedNumber = likeNumberChanged btnHomeHeart.isSelected = !btnHomeHeart.isSelected } } diff --git a/feature/src/main/java/com/teamdontbe/feature/homedetail/HomeDetailFragment.kt b/feature/src/main/java/com/teamdontbe/feature/homedetail/HomeDetailFragment.kt index 36f733899..05230654e 100644 --- a/feature/src/main/java/com/teamdontbe/feature/homedetail/HomeDetailFragment.kt +++ b/feature/src/main/java/com/teamdontbe/feature/homedetail/HomeDetailFragment.kt @@ -295,6 +295,9 @@ class HomeDetailFragment : private fun handleCommentPostingSuccess() { homeDetailCommentAdapter.refresh() + binding.rvHomeDetail.post { + binding.rvHomeDetail.smoothScrollToPosition(homeDetailCommentAdapter.itemCount + 1) + } requireContext().hideKeyboard(binding.root) (requireActivity() as MainActivity).findViewById(R.id.bnv_main).visibility = View.VISIBLE diff --git a/feature/src/main/java/com/teamdontbe/feature/homedetail/viewholder/HomeDetailCommentViewHolder.kt b/feature/src/main/java/com/teamdontbe/feature/homedetail/viewholder/HomeDetailCommentViewHolder.kt index 4a071a23b..2dedc5209 100644 --- a/feature/src/main/java/com/teamdontbe/feature/homedetail/viewholder/HomeDetailCommentViewHolder.kt +++ b/feature/src/main/java/com/teamdontbe/feature/homedetail/viewholder/HomeDetailCommentViewHolder.kt @@ -31,8 +31,7 @@ class HomeDetailCommentViewHolder( ivCommentGhostFillGreen.isVisible = data.memberId !== userId dividerComment.isVisible = data.memberId !== userId btnCommentHeart.isSelected = data.isLiked - - dividerCommentDivideBottom.isVisible = (lastPosition !== position) + dividerCommentDivideBottom.isVisible = (lastPosition !== absoluteAdapterPosition) if (data.isGhost) { setFeedTransparent(-85) binding.tvCommentTransparency.text = context.getString( @@ -63,8 +62,11 @@ class HomeDetailCommentViewHolder( btnCommentHeart.setOnDuplicateBlockClick { onClickLikedBtn(data.commentId, btnCommentHeart.isSelected) val likeNumber = tvCommentLikeNum.text.toString() - tvCommentLikeNum.text = - if (btnCommentHeart.isSelected) (likeNumber.toInt() - 1).toString() else (likeNumber.toInt() + 1).toString() + val likeNumberChanged = + if (btnCommentHeart.isSelected) (likeNumber.toInt() - 1) else (likeNumber.toInt() + 1) + tvCommentLikeNum.text = likeNumberChanged.toString() + data.isLiked = !btnCommentHeart.isSelected + data.commentLikedNumber = likeNumberChanged btnCommentHeart.isSelected = !btnCommentHeart.isSelected } } diff --git a/feature/src/main/java/com/teamdontbe/feature/mypage/comment/MyPageCommentFragment.kt b/feature/src/main/java/com/teamdontbe/feature/mypage/comment/MyPageCommentFragment.kt index 904d56baa..5491005b9 100644 --- a/feature/src/main/java/com/teamdontbe/feature/mypage/comment/MyPageCommentFragment.kt +++ b/feature/src/main/java/com/teamdontbe/feature/mypage/comment/MyPageCommentFragment.kt @@ -55,7 +55,7 @@ class MyPageCommentFragment : initDeleteObserve() initTransparentObserve() stateCommentItemNull() - scrollRecyclerViewToTop() + //scrollRecyclerViewToTop() } private fun initMemberProfile() { diff --git a/feature/src/main/java/com/teamdontbe/feature/mypage/comment/MyPageCommentViewHolder.kt b/feature/src/main/java/com/teamdontbe/feature/mypage/comment/MyPageCommentViewHolder.kt index 0377612bf..e21a7abdf 100644 --- a/feature/src/main/java/com/teamdontbe/feature/mypage/comment/MyPageCommentViewHolder.kt +++ b/feature/src/main/java/com/teamdontbe/feature/mypage/comment/MyPageCommentViewHolder.kt @@ -56,8 +56,11 @@ class MyPageCommentViewHolder( btnCommentHeart.setOnClickListener { onClickLikedBtn(data.commentId, btnCommentHeart.isSelected) val likeNumber = tvCommentLikeNum.text.toString() - tvCommentLikeNum.text = - if (btnCommentHeart.isSelected) (likeNumber.toInt() - 1).toString() else (likeNumber.toInt() + 1).toString() + val likeNumberChanged = + if (btnCommentHeart.isSelected) (likeNumber.toInt() - 1) else (likeNumber.toInt() + 1) + tvCommentLikeNum.text = likeNumberChanged.toString() + data.isLiked = !btnCommentHeart.isSelected + data.commentLikedNumber = likeNumberChanged btnCommentHeart.isSelected = !btnCommentHeart.isSelected } } diff --git a/feature/src/main/java/com/teamdontbe/feature/mypage/feed/MyPageFeedFragment.kt b/feature/src/main/java/com/teamdontbe/feature/mypage/feed/MyPageFeedFragment.kt index 33d3a169f..2dbf6042f 100644 --- a/feature/src/main/java/com/teamdontbe/feature/mypage/feed/MyPageFeedFragment.kt +++ b/feature/src/main/java/com/teamdontbe/feature/mypage/feed/MyPageFeedFragment.kt @@ -56,7 +56,7 @@ class MyPageFeedFragment : initDeleteObserve() initTransparentObserve() stateFeedItemNull() - scrollRecyclerViewToTop() + //scrollRecyclerViewToTop() } private fun initMemberProfile() { diff --git a/feature/src/main/java/com/teamdontbe/feature/mypage/feed/MyPageFeedViewHolder.kt b/feature/src/main/java/com/teamdontbe/feature/mypage/feed/MyPageFeedViewHolder.kt index 69d3f5961..590665809 100644 --- a/feature/src/main/java/com/teamdontbe/feature/mypage/feed/MyPageFeedViewHolder.kt +++ b/feature/src/main/java/com/teamdontbe/feature/mypage/feed/MyPageFeedViewHolder.kt @@ -59,8 +59,11 @@ class MyPageFeedViewHolder( onClickLikedBtn(contentId, btnHomeHeart.isSelected) } val likeNumber = tvHomeHeartNum.text.toString() - tvHomeHeartNum.text = - if (btnHomeHeart.isSelected) (likeNumber.toInt() - 1).toString() else (likeNumber.toInt() + 1).toString() + val likeNumberChanged = + if (btnHomeHeart.isSelected) (likeNumber.toInt() - 1) else (likeNumber.toInt() + 1) + tvHomeHeartNum.text = likeNumberChanged.toString() + data.isLiked = !btnHomeHeart.isSelected + data.contentLikedNumber = likeNumberChanged btnHomeHeart.isSelected = !btnHomeHeart.isSelected } } diff --git a/feature/src/main/res/layout/activity_login.xml b/feature/src/main/res/layout/activity_login.xml index 07df4a1d5..605ba09bd 100644 --- a/feature/src/main/res/layout/activity_login.xml +++ b/feature/src/main/res/layout/activity_login.xml @@ -33,12 +33,13 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/iv_login_symbol" /> - diff --git a/feature/src/main/res/layout/item_home_comment.xml b/feature/src/main/res/layout/item_home_comment.xml index 6c5d0e369..725d7bdf2 100644 --- a/feature/src/main/res/layout/item_home_comment.xml +++ b/feature/src/main/res/layout/item_home_comment.xml @@ -163,27 +163,29 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="8dp" + android:layout_marginEnd="28dp" android:layout_marginBottom="14dp" android:background="@drawable/sel_home_heart" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintDimensionRatio="1" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintEnd_toStartOf="@id/tv_comment_like_num" app:layout_constraintTop_toBottomOf="@id/tv_comment_content" /> + tools:text="544" /> diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index d562082ba..57181623b 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - DontBe + Don\'t be 글쓰기 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7c8b5c568..cc6d91a8c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ compileSdk = "34" minSdk = "28" targetSdk = "34" appVersion = "1.0.0" -versionCode = "2" +versionCode = "3" # kotlin kotlin = "1.9.10"