응원글 삭제 기능 추가
This commit is contained in:
parent
e371fd2ac2
commit
8a4ad41212
|
@ -56,14 +56,10 @@ class ExplorerRepository(
|
|||
)
|
||||
|
||||
fun modifyCheers(
|
||||
cheersId: Long,
|
||||
content: String,
|
||||
request: PutModifyCheersRequest,
|
||||
token: String
|
||||
) = api.modifyCheers(
|
||||
request = PutModifyCheersRequest(
|
||||
cheersId = cheersId,
|
||||
content = content
|
||||
),
|
||||
request = request,
|
||||
authHeader = token
|
||||
)
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ data class GetCheersResponse(
|
|||
|
||||
data class GetCheersResponseItem(
|
||||
@SerializedName("cheersId") val cheersId: Long,
|
||||
@SerializedName("memberId") val memberId: Long,
|
||||
@SerializedName("nickname") val nickname: String,
|
||||
@SerializedName("profileUrl") val profileUrl: String,
|
||||
@SerializedName("content") val content: String,
|
||||
|
|
|
@ -28,6 +28,7 @@ import kr.co.vividnext.sodalive.audio_content.AudioContentAdapter
|
|||
import kr.co.vividnext.sodalive.audio_content.detail.AudioContentDetailActivity
|
||||
import kr.co.vividnext.sodalive.audio_content.upload.AudioContentUploadActivity
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.base.SodaDialog
|
||||
import kr.co.vividnext.sodalive.common.Constants
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
|
@ -389,16 +390,35 @@ class UserProfileActivity : BaseActivity<ActivityUserProfileBinding>(
|
|||
)
|
||||
}
|
||||
},
|
||||
modifyReply = { cheersId, content ->
|
||||
modifyReply = { cheersId, content, isActive ->
|
||||
hideKeyboard {
|
||||
viewModel.modifyCheers(
|
||||
cheersId = cheersId,
|
||||
creatorId = userId,
|
||||
cheersContent = content
|
||||
cheersContent = content,
|
||||
isActive = isActive
|
||||
)
|
||||
}
|
||||
},
|
||||
onClickReport = { showCheersReportPopup(it) }
|
||||
onClickReport = { showCheersReportPopup(it) },
|
||||
onClickDelete = {
|
||||
SodaDialog(
|
||||
activity = this@UserProfileActivity,
|
||||
layoutInflater = layoutInflater,
|
||||
title = "응원글 삭제",
|
||||
desc = "삭제하시겠습니까?",
|
||||
confirmButtonTitle = "삭제",
|
||||
confirmButtonClick = {
|
||||
viewModel.modifyCheers(
|
||||
cheersId = it,
|
||||
creatorId = userId,
|
||||
isActive = false
|
||||
)
|
||||
},
|
||||
cancelButtonTitle = "취소",
|
||||
cancelButtonClick = {}
|
||||
).show(screenWidth)
|
||||
}
|
||||
)
|
||||
|
||||
rvCheers.layoutManager = LinearLayoutManager(
|
||||
|
|
|
@ -15,6 +15,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers
|
|||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.explorer.ExplorerRepository
|
||||
import kr.co.vividnext.sodalive.explorer.profile.cheers.PutModifyCheersRequest
|
||||
import kr.co.vividnext.sodalive.report.ReportRepository
|
||||
import kr.co.vividnext.sodalive.report.ReportRequest
|
||||
import kr.co.vividnext.sodalive.report.ReportType
|
||||
|
@ -256,18 +257,37 @@ class UserProfileViewModel(
|
|||
)
|
||||
}
|
||||
|
||||
fun modifyCheers(cheersId: Long, creatorId: Long, cheersContent: String) {
|
||||
if (cheersContent.isBlank()) {
|
||||
fun modifyCheers(
|
||||
cheersId: Long,
|
||||
creatorId: Long,
|
||||
cheersContent: String? = null,
|
||||
isActive: Boolean? = null
|
||||
) {
|
||||
if (cheersContent == null && isActive == null) {
|
||||
_toastLiveData.postValue("변경사항이 없습니다.")
|
||||
return
|
||||
}
|
||||
|
||||
if (cheersContent != null && cheersContent.isBlank()) {
|
||||
_toastLiveData.postValue("내용을 입력하세요")
|
||||
return
|
||||
}
|
||||
|
||||
_isLoading.value = true
|
||||
|
||||
val request = PutModifyCheersRequest(cheersId = cheersId)
|
||||
|
||||
if (cheersContent != null) {
|
||||
request.content = cheersContent
|
||||
}
|
||||
|
||||
if (isActive != null) {
|
||||
request.isActive = isActive
|
||||
}
|
||||
|
||||
compositeDisposable.add(
|
||||
repository.modifyCheers(
|
||||
cheersId = cheersId,
|
||||
content = cheersContent,
|
||||
request = request,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
|
|
@ -4,5 +4,6 @@ import com.google.gson.annotations.SerializedName
|
|||
|
||||
data class PutModifyCheersRequest(
|
||||
@SerializedName("cheersId") val cheersId: Long,
|
||||
@SerializedName("content") val content: String
|
||||
@SerializedName("content") var content: String? = null,
|
||||
@SerializedName("isActive") var isActive: Boolean? = null,
|
||||
)
|
||||
|
|
|
@ -17,8 +17,9 @@ import kr.co.vividnext.sodalive.extensions.dpToPx
|
|||
class UserProfileCheersAdapter(
|
||||
private val userId: Long,
|
||||
private val enterReply: (Long, String) -> Unit,
|
||||
private val modifyReply: (Long, String) -> Unit,
|
||||
private val onClickReport: (Long) -> Unit
|
||||
private val modifyReply: (Long, String?, Boolean?) -> Unit,
|
||||
private val onClickReport: (Long) -> Unit,
|
||||
private val onClickDelete: (Long) -> Unit
|
||||
) : RecyclerView.Adapter<UserProfileCheersAdapter.ViewHolder>() {
|
||||
|
||||
val items = mutableListOf<GetCheersResponseItem>()
|
||||
|
@ -46,7 +47,9 @@ class UserProfileCheersAdapter(
|
|||
showOptionMenu(
|
||||
context,
|
||||
binding.ivMenu,
|
||||
cheersId = cheers.cheersId
|
||||
cheersId = cheers.cheersId,
|
||||
memberId = cheers.memberId,
|
||||
creatorId = userId
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -63,7 +66,7 @@ class UserProfileCheersAdapter(
|
|||
binding.rlCheerReply.visibility = View.VISIBLE
|
||||
binding.tvSend.setOnClickListener {
|
||||
val content = binding.etCheerReply.text.toString()
|
||||
modifyReply(reply.cheersId, content)
|
||||
modifyReply(reply.cheersId, content, null)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -106,16 +109,34 @@ class UserProfileCheersAdapter(
|
|||
|
||||
override fun getItemCount() = items.count()
|
||||
|
||||
private fun showOptionMenu(context: Context, v: View, cheersId: Long) {
|
||||
private fun showOptionMenu(
|
||||
context: Context,
|
||||
v: View,
|
||||
cheersId: Long,
|
||||
memberId: Long,
|
||||
creatorId: Long
|
||||
) {
|
||||
val popup = PopupMenu(context, v)
|
||||
val inflater = popup.menuInflater
|
||||
inflater.inflate(R.menu.review_option_menu, popup.menu)
|
||||
|
||||
if (
|
||||
memberId == SharedPreferenceManager.userId ||
|
||||
creatorId == SharedPreferenceManager.userId
|
||||
) {
|
||||
inflater.inflate(R.menu.review_option_menu2, popup.menu)
|
||||
} else {
|
||||
inflater.inflate(R.menu.review_option_menu, popup.menu)
|
||||
}
|
||||
|
||||
popup.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.menu_review_report -> {
|
||||
onClickReport(cheersId)
|
||||
}
|
||||
|
||||
R.id.menu_review_delete -> {
|
||||
onClickDelete(cheersId)
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.Toast
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.base.SodaDialog
|
||||
import kr.co.vividnext.sodalive.common.Constants
|
||||
import kr.co.vividnext.sodalive.common.LoadingDialog
|
||||
import kr.co.vividnext.sodalive.databinding.ActivityUserProfileFantalkAllBinding
|
||||
|
@ -79,16 +80,35 @@ class UserProfileFantalkAllViewActivity : BaseActivity<ActivityUserProfileFantal
|
|||
)
|
||||
}
|
||||
},
|
||||
modifyReply = { cheersId, content ->
|
||||
modifyReply = { cheersId, content, isActive ->
|
||||
hideKeyboard {
|
||||
viewModel.modifyCheers(
|
||||
cheersId = cheersId,
|
||||
creatorId = userId,
|
||||
cheersContent = content
|
||||
cheersContent = content,
|
||||
isActive = isActive
|
||||
)
|
||||
}
|
||||
},
|
||||
onClickReport = { showCheersReportPopup(it) }
|
||||
onClickReport = { showCheersReportPopup(it) },
|
||||
onClickDelete = {
|
||||
SodaDialog(
|
||||
activity = this@UserProfileFantalkAllViewActivity,
|
||||
layoutInflater = layoutInflater,
|
||||
title = "응원글 삭제",
|
||||
desc = "삭제하시겠습니까?",
|
||||
confirmButtonTitle = "삭제",
|
||||
confirmButtonClick = {
|
||||
viewModel.modifyCheers(
|
||||
cheersId = it,
|
||||
creatorId = userId,
|
||||
isActive = false
|
||||
)
|
||||
},
|
||||
cancelButtonTitle = "취소",
|
||||
cancelButtonClick = {}
|
||||
).show(screenWidth)
|
||||
}
|
||||
)
|
||||
|
||||
rvCheers.layoutManager = LinearLayoutManager(
|
||||
|
|
|
@ -9,6 +9,7 @@ import kr.co.vividnext.sodalive.base.BaseViewModel
|
|||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.explorer.ExplorerRepository
|
||||
import kr.co.vividnext.sodalive.explorer.profile.GetCheersResponse
|
||||
import kr.co.vividnext.sodalive.explorer.profile.cheers.PutModifyCheersRequest
|
||||
import kr.co.vividnext.sodalive.report.ReportRepository
|
||||
import kr.co.vividnext.sodalive.report.ReportRequest
|
||||
import kr.co.vividnext.sodalive.report.ReportType
|
||||
|
@ -146,18 +147,37 @@ class UserProfileFantalkAllViewModel(
|
|||
)
|
||||
}
|
||||
|
||||
fun modifyCheers(cheersId: Long, creatorId: Long, cheersContent: String) {
|
||||
if (cheersContent.isBlank()) {
|
||||
fun modifyCheers(
|
||||
cheersId: Long,
|
||||
creatorId: Long,
|
||||
cheersContent: String? = null,
|
||||
isActive: Boolean? = null
|
||||
) {
|
||||
if (cheersContent == null && isActive == null) {
|
||||
_toastLiveData.postValue("변경사항이 없습니다.")
|
||||
return
|
||||
}
|
||||
|
||||
if (cheersContent != null && cheersContent.isBlank()) {
|
||||
_toastLiveData.postValue("내용을 입력하세요")
|
||||
return
|
||||
}
|
||||
|
||||
_isLoading.value = true
|
||||
|
||||
val request = PutModifyCheersRequest(cheersId = cheersId)
|
||||
|
||||
if (cheersContent != null) {
|
||||
request.content = cheersContent
|
||||
}
|
||||
|
||||
if (isActive != null) {
|
||||
request.isActive = isActive
|
||||
}
|
||||
|
||||
compositeDisposable.add(
|
||||
repository.modifyCheers(
|
||||
cheersId = cheersId,
|
||||
content = cheersContent,
|
||||
request = request,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
|
|
@ -119,7 +119,6 @@
|
|||
android:visibility="gone"
|
||||
tools:ignore="SmallSp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/menu_review_report"
|
||||
android:title="신고하기"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_review_delete"
|
||||
android:title="삭제"
|
||||
app:showAsAction="ifRoom" />
|
||||
</menu>
|
Loading…
Reference in New Issue