Skip to content

Commit

Permalink
Merge branch 'develop' into feature/fix-get-notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook123 committed Aug 23, 2023
2 parents 27e59d0 + 9368b13 commit 673057c
Show file tree
Hide file tree
Showing 15 changed files with 277 additions and 146 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.android.go.sopt.winey.data.model.remote.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ResponseDeleteCommentDto(
@SerialName("commentId")
val commentId: Long
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.android.go.sopt.winey.data.model.remote.request.RequestPostCommentDto
import com.android.go.sopt.winey.data.model.remote.request.RequestPostLikeDto
import com.android.go.sopt.winey.data.model.remote.response.ResponseDeleteCommentDto
import com.android.go.sopt.winey.data.model.remote.response.ResponsePostWineyFeedDto
import com.android.go.sopt.winey.data.service.FeedService
import com.android.go.sopt.winey.data.source.FeedDataSource
Expand Down Expand Up @@ -68,6 +69,11 @@ class FeedRepositoryImpl @Inject constructor(
feedDataSource.postComment(feedId, requestPostCommentDto).data?.toComment()
}

override suspend fun deleteComment(commentId: Long): Result<ResponseDeleteCommentDto?> =
runCatching {
feedDataSource.deleteComment(commentId).data
}

companion object {
const val WINEYFEED_PAGE_SIZE = 20
const val MYFEED_PAGE_SIZE = 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.android.go.sopt.winey.data.service

import com.android.go.sopt.winey.data.model.remote.request.RequestPostCommentDto
import com.android.go.sopt.winey.data.model.remote.request.RequestPostLikeDto
import com.android.go.sopt.winey.data.model.remote.response.ResponseDeleteCommentDto
import com.android.go.sopt.winey.data.model.remote.response.ResponseGetFeedDetailDto
import com.android.go.sopt.winey.data.model.remote.response.ResponseGetWineyFeedListDto
import com.android.go.sopt.winey.data.model.remote.response.ResponsePostCommentDto
Expand Down Expand Up @@ -59,4 +60,9 @@ interface FeedService {
@Path("feedId") feedId: Int,
@Body requestPostCommentDto: RequestPostCommentDto
): BaseResponse<ResponsePostCommentDto>

@DELETE("comment/{commentId}")
suspend fun deleteComment(
@Path("commentId") commentId: Long
): BaseResponse<ResponseDeleteCommentDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.android.go.sopt.winey.data.source

import com.android.go.sopt.winey.data.model.remote.request.RequestPostCommentDto
import com.android.go.sopt.winey.data.model.remote.request.RequestPostLikeDto
import com.android.go.sopt.winey.data.model.remote.response.ResponseDeleteCommentDto
import com.android.go.sopt.winey.data.model.remote.response.ResponseGetFeedDetailDto
import com.android.go.sopt.winey.data.model.remote.response.ResponsePostCommentDto
import com.android.go.sopt.winey.data.model.remote.response.ResponsePostLikeDto
Expand Down Expand Up @@ -40,4 +41,7 @@ class FeedDataSource @Inject constructor(
requestPostCommentDto: RequestPostCommentDto
): BaseResponse<ResponsePostCommentDto> =
feedService.postComment(feedId, requestPostCommentDto)

suspend fun deleteComment(commentId: Long): BaseResponse<ResponseDeleteCommentDto> =
feedService.deleteComment(commentId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.android.go.sopt.winey.domain.repository
import androidx.paging.PagingData
import com.android.go.sopt.winey.data.model.remote.request.RequestPostCommentDto
import com.android.go.sopt.winey.data.model.remote.request.RequestPostLikeDto
import com.android.go.sopt.winey.data.model.remote.response.ResponseDeleteCommentDto
import com.android.go.sopt.winey.data.model.remote.response.ResponsePostWineyFeedDto
import com.android.go.sopt.winey.domain.entity.Comment
import com.android.go.sopt.winey.domain.entity.DetailFeed
Expand Down Expand Up @@ -32,4 +33,6 @@ interface FeedRepository {
feedId: Int,
requestPostCommentDto: RequestPostCommentDto
): Result<Comment?>

suspend fun deleteComment(commentId: Long): Result<ResponseDeleteCommentDto?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
private val isUploadSuccess by lazy { intent.extras?.getBoolean(EXTRA_UPLOAD_KEY, false) }
private val isDeleteSuccess by lazy { intent.extras?.getBoolean(EXTRA_DELETE_KEY, false) }
private val isReportSuccess by lazy { intent.extras?.getBoolean(EXTRA_REPORT_KEY, false) }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.android.go.sopt.winey.presentation.main.feed

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
Expand All @@ -19,6 +18,7 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.ConcatAdapter
import androidx.recyclerview.widget.SimpleItemAnimator
import com.android.go.sopt.winey.R
import com.android.go.sopt.winey.databinding.FragmentWineyFeedBinding
import com.android.go.sopt.winey.domain.entity.User
Expand Down Expand Up @@ -63,14 +63,15 @@ class WineyFeedFragment :

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Log.d("Fragment Lifecycle", "onViewCreated ํ˜ธ์ถœ๋จ")
removeRecyclerviewItemChangeAnimation()
binding.vm = mainViewModel
mainViewModel.getHasNewNoti()

initAdapter()
setSwipeRefreshListener()
initFabClickListener()
initPostLikeStateObserver()
initGetFeedStateObserver()
binding.vm = mainViewModel
mainViewModel.getHasNewNoti()
initNotificationButtonClickListener()
}

Expand All @@ -80,6 +81,13 @@ class WineyFeedFragment :
viewModel.getWineyFeed()
}

private fun removeRecyclerviewItemChangeAnimation() {
val animator = binding.rvWineyfeedPost.itemAnimator
if (animator is SimpleItemAnimator) {
animator.supportsChangeAnimations = false
}
}

private fun initAdapter() {
wineyFeedHeaderAdapter = WineyFeedHeaderAdapter()
wineyFeedLoadAdapter = WineyFeedLoadAdapter()
Expand Down Expand Up @@ -289,5 +297,6 @@ class WineyFeedFragment :

private const val KEY_FEED_ID = "feedId"
private const val KEY_FEED_WRITER_ID = "feedWriterId"
private const val KEY_SCROLL_POS = "KEY_SCROLL_POS"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import com.android.go.sopt.winey.domain.entity.Comment
import com.android.go.sopt.winey.util.view.ItemDiffCallback

class CommentAdapter(
private val onPopupMenuClicked: (View, Int) -> Unit
private val onPopupMenuClicked: (View, Int, Long) -> Unit
) : ListAdapter<Comment, CommentAdapter.CommentViewHolder>(diffUtil) {

inner class CommentViewHolder(
private val binding: ItemDetailCommentBinding
) : RecyclerView.ViewHolder(binding.root) {
fun onBind(comment: Comment) {
binding.apply {
this.data = comment

// ํŒ์—… ๋ฉ”๋‰ด ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด, ํ•ด๋‹น ๋ฒ„ํŠผ์˜ ๋ทฐ์™€ ๋Œ“๊ธ€ ์ž‘์„ฑ์ž์˜ ์•„์ด๋””๋ฅผ ์ „๋‹ฌํ•œ๋‹ค.
ivCommentMore.setOnClickListener { view ->
onPopupMenuClicked(view, comment.authorId)
onPopupMenuClicked(view, comment.authorId, comment.commentId)
}
}
}
Expand All @@ -45,10 +45,12 @@ class CommentAdapter(
return newList.size
}

fun deleteItem(position: Int) {
fun deleteItem(commentId: Long): Int {
val comment = currentList.find { it.commentId == commentId }
val newList = currentList.toMutableList()
newList.removeAt(position)
newList.remove(comment)
submitList(newList)
return newList.size
}

companion object {
Expand Down
Loading

0 comments on commit 673057c

Please sign in to comment.