콘텐츠 댓글 수정 기능 추가
This commit is contained in:
@@ -17,6 +17,7 @@ import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
|
||||
class AudioContentCommentAdapter(
|
||||
private val creatorId: Long,
|
||||
private val modifyComment: (Long, String) -> Unit,
|
||||
private val onClickDelete: (Long) -> Unit,
|
||||
private val onItemClick: (GetAudioContentCommentListItem) -> Unit
|
||||
) : RecyclerView.Adapter<AudioContentCommentAdapter.ViewHolder>() {
|
||||
@@ -92,6 +93,7 @@ class AudioContentCommentAdapter(
|
||||
item.writerId == SharedPreferenceManager.userId ||
|
||||
creatorId == SharedPreferenceManager.userId
|
||||
) {
|
||||
binding.etCommentModify.setText(item.comment)
|
||||
binding.ivMenu.visibility = View.VISIBLE
|
||||
binding.ivMenu.setOnClickListener {
|
||||
showOptionMenu(
|
||||
@@ -99,9 +101,19 @@ class AudioContentCommentAdapter(
|
||||
binding.ivMenu,
|
||||
commentId = item.id,
|
||||
writerId = item.writerId,
|
||||
creatorId = creatorId
|
||||
creatorId = creatorId,
|
||||
onClickModify = {
|
||||
binding.rlCommentModify.visibility = View.VISIBLE
|
||||
binding.tvComment.visibility = View.GONE
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
binding.tvModify.setOnClickListener {
|
||||
binding.rlCommentModify.visibility = View.GONE
|
||||
binding.tvComment.visibility = View.VISIBLE
|
||||
modifyComment(item.id, binding.etCommentModify.text.toString())
|
||||
}
|
||||
} else {
|
||||
binding.ivMenu.visibility = View.GONE
|
||||
}
|
||||
@@ -131,20 +143,24 @@ class AudioContentCommentAdapter(
|
||||
v: View,
|
||||
commentId: Long,
|
||||
writerId: Long,
|
||||
creatorId: Long
|
||||
creatorId: Long,
|
||||
onClickModify: () -> Unit
|
||||
) {
|
||||
val popup = PopupMenu(context, v)
|
||||
val inflater = popup.menuInflater
|
||||
|
||||
if (
|
||||
writerId == SharedPreferenceManager.userId ||
|
||||
creatorId == SharedPreferenceManager.userId
|
||||
) {
|
||||
if (writerId == SharedPreferenceManager.userId) {
|
||||
inflater.inflate(R.menu.content_comment_option_menu, popup.menu)
|
||||
} else if (creatorId == SharedPreferenceManager.userId) {
|
||||
inflater.inflate(R.menu.content_comment_option_menu2, popup.menu)
|
||||
}
|
||||
|
||||
popup.setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.menu_review_modify -> {
|
||||
onClickModify()
|
||||
}
|
||||
|
||||
R.id.menu_review_delete -> {
|
||||
onClickDelete(commentId)
|
||||
}
|
||||
|
@@ -12,7 +12,10 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.databinding.DialogAudioContentCommentBinding
|
||||
|
||||
class AudioContentCommentFragment(private val audioContentId: Long) : BottomSheetDialogFragment() {
|
||||
class AudioContentCommentFragment(
|
||||
private val creatorId: Long,
|
||||
private val audioContentId: Long
|
||||
) : BottomSheetDialogFragment() {
|
||||
|
||||
private lateinit var binding: DialogAudioContentCommentBinding
|
||||
|
||||
@@ -46,6 +49,7 @@ class AudioContentCommentFragment(private val audioContentId: Long) : BottomShee
|
||||
|
||||
val commentListFragmentTag = "COMMENT_LIST_FRAGMENT"
|
||||
val commentListFragment = AudioContentCommentListFragment.newInstance(
|
||||
creatorId = creatorId,
|
||||
audioContentId = audioContentId
|
||||
)
|
||||
val fragmentTransaction = childFragmentManager.beginTransaction()
|
||||
|
@@ -33,6 +33,7 @@ class AudioContentCommentListFragment : BaseFragment<FragmentAudioContentComment
|
||||
private lateinit var loadingDialog: LoadingDialog
|
||||
private lateinit var adapter: AudioContentCommentAdapter
|
||||
|
||||
private var creatorId: Long = 0
|
||||
private var audioContentId: Long = 0
|
||||
|
||||
override fun onCreateView(
|
||||
@@ -40,6 +41,7 @@ class AudioContentCommentListFragment : BaseFragment<FragmentAudioContentComment
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
creatorId = arguments?.getLong(Constants.EXTRA_AUDIO_CONTENT_CREATOR_ID) ?: 0
|
||||
audioContentId = arguments?.getLong(Constants.EXTRA_AUDIO_CONTENT_ID) ?: 0
|
||||
return super.onCreateView(inflater, container, savedInstanceState)
|
||||
}
|
||||
@@ -76,7 +78,15 @@ class AudioContentCommentListFragment : BaseFragment<FragmentAudioContentComment
|
||||
}
|
||||
|
||||
adapter = AudioContentCommentAdapter(
|
||||
creatorId = 0,
|
||||
creatorId = creatorId,
|
||||
modifyComment = { commentId, comment ->
|
||||
hideKeyboard()
|
||||
viewModel.modifyComment(
|
||||
commentId = commentId,
|
||||
audioContentId = audioContentId,
|
||||
comment = comment
|
||||
)
|
||||
},
|
||||
onClickDelete = {
|
||||
SodaDialog(
|
||||
activity = requireActivity(),
|
||||
@@ -192,8 +202,9 @@ class AudioContentCommentListFragment : BaseFragment<FragmentAudioContentComment
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(audioContentId: Long): AudioContentCommentListFragment {
|
||||
fun newInstance(creatorId: Long, audioContentId: Long): AudioContentCommentListFragment {
|
||||
val args = Bundle()
|
||||
args.putLong(Constants.EXTRA_AUDIO_CONTENT_CREATOR_ID, creatorId)
|
||||
args.putLong(Constants.EXTRA_AUDIO_CONTENT_ID, audioContentId)
|
||||
|
||||
val fragment = AudioContentCommentListFragment()
|
||||
|
@@ -56,6 +56,8 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||
private var isAlertPreview = false
|
||||
private val audioContentReceiver = AudioContentReceiver()
|
||||
|
||||
private var creatorId: Long = 0
|
||||
|
||||
private var refresh = false
|
||||
set(value) {
|
||||
field = value
|
||||
@@ -474,7 +476,10 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||
}
|
||||
|
||||
private fun showCommentBottomSheetDialog() {
|
||||
val dialog = AudioContentCommentFragment(audioContentId = audioContentId)
|
||||
val dialog = AudioContentCommentFragment(
|
||||
creatorId = creatorId,
|
||||
audioContentId = audioContentId
|
||||
)
|
||||
dialog.show(
|
||||
supportFragmentManager,
|
||||
dialog.tag
|
||||
@@ -629,6 +634,7 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||
}
|
||||
|
||||
private fun setupCreatorArea(creator: AudioContentCreator) {
|
||||
this.creatorId = creator.creatorId
|
||||
binding.rlProfile.setOnClickListener {
|
||||
startActivity(
|
||||
Intent(applicationContext, UserProfileActivity::class.java).apply {
|
||||
|
Reference in New Issue
Block a user