feat(creator): 커뮤니티 구매와 메뉴 동작을 정리한다

This commit is contained in:
2026-08-11 00:10:46 +09:00
parent 02cd583f56
commit 8b8b384b29
31 changed files with 1055 additions and 410 deletions
@@ -6,12 +6,4 @@ sealed interface CommunityChange {
data object Created : CommunityChange
data object Updated : CommunityChange
data class Deleted(
val postId: Long
) : CommunityChange
data class PinChanged(
val postId: Long
) : CommunityChange
}
@@ -33,6 +33,7 @@ import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.databinding.ActivityCreatorChannelBinding
import kr.co.vividnext.sodalive.explorer.profile.creator_community.CreatorCommunityRepository
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.CreatorCommunityPostMenuBottomSheetDialog
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.CreatorCommunityReportDialog
import kr.co.vividnext.sodalive.explorer.profile.creator_community.modify.CreatorCommunityModifyActivity
import kr.co.vividnext.sodalive.explorer.profile.creator_community.modify.ModifyCommunityPostRequest
import kr.co.vividnext.sodalive.explorer.profile.creator_community.write.CreatorCommunityWriteActivity
@@ -60,8 +61,9 @@ import kr.co.vividnext.sodalive.v2.components.modal.V2ModalDialog
import kr.co.vividnext.sodalive.v2.common.CreatorActivityType
import kr.co.vividnext.sodalive.v2.creator.channel.audio.CreatorChannelAudioFragment
import kr.co.vividnext.sodalive.v2.creator.channel.community.CreatorChannelCommunityFragment
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityPostUiModel
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityMenuItem
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelAudioContentResponse
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelLiveResponse
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelScheduleResponse
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelSeriesResponse
@@ -96,6 +98,7 @@ class CreatorChannelActivity :
private val liveViewModel: LiveViewModel by inject()
private val creatorCommunityRepository: CreatorCommunityRepository by inject()
private val creatorChannelRepository: CreatorChannelRepository by inject()
private var creatorId: Long = 0L
private var currentHeader: CreatorChannelHeaderUiModel? = null
private var homeActionDelegate: CreatorChannelHomeFragment.HomeActionDelegate? = null
@@ -107,6 +110,7 @@ class CreatorChannelActivity :
private var isOwnerFabAnimating: Boolean = false
private var isDonationFloatingButtonVisible: Boolean = false
private var isFanTalkFixedPlusVisible: Boolean = false
private var isCommunityPostMutating: Boolean = false
private lateinit var loadingDialog: LoadingDialog
private val baseTitleBarHeight: Int by lazy { 60.dpToPx().toInt() }
private val liveActionCoordinator: LiveActionCoordinator by lazy {
@@ -126,13 +130,6 @@ class CreatorChannelActivity :
resolveCommunityActivityResult(CommunityActivityResultSource.Write, result.resultCode)
)
}
private val communityPostModifyLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
handleCommunityChange(
resolveCommunityActivityResult(CommunityActivityResultSource.Modify, result.resultCode)
)
}
private val communityDetailLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
@@ -140,6 +137,13 @@ class CreatorChannelActivity :
resolveCommunityActivityResult(CommunityActivityResultSource.Detail, result.resultCode)
)
}
private val communityModifyLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
handleCommunityChange(
resolveCommunityActivityResult(CommunityActivityResultSource.Modify, result.resultCode)
)
}
private val fanTalkWriteLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
@@ -627,6 +631,142 @@ class CreatorChannelActivity :
handleCommunityAction(CommunityActionCommand.PostDetail(postId), communityDetailLauncher::launch)
}
override fun onCreatorChannelCommunityMoreClicked(item: CreatorChannelCommunityMenuItem) {
if (!item.showMore) return
CreatorCommunityPostMenuBottomSheetDialog(
isFixed = item.isPinned,
isCreator = item.isOwner,
onClickPin = { updateCreatorChannelCommunityPostFixed(item) },
onClickModify = {
if (item.isOwner) {
communityModifyLauncher.launch(
Intent(this, CreatorCommunityModifyActivity::class.java).apply {
putExtra(Constants.EXTRA_COMMUNITY_POST_ID, item.postId)
}
)
}
},
onClickDelete = { showDeleteCreatorChannelCommunityPostDialog(item) },
onClickReport = {
CreatorCommunityReportDialog(
this,
layoutInflater
) { reason -> reportCreatorChannelCommunityPost(item, reason) }.show(screenWidth)
}
).show(supportFragmentManager, CreatorCommunityPostMenuBottomSheetDialog::class.java.simpleName)
}
private fun updateCreatorChannelCommunityPostFixed(item: CreatorChannelCommunityMenuItem) {
if (!item.isOwner || isCommunityPostMutating) return
isCommunityPostMutating = true
compositeDisposable.add(
creatorCommunityRepository.updateCommunityPostFixed(item.postId, !item.isPinned, authToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ response ->
isCommunityPostMutating = false
if (response.success) {
handleCommunityChange(CommunityChange.Updated)
} else {
showCommunityMutationFailureToast(response.message)
}
},
{
isCommunityPostMutating = false
showCommunityMutationFailureToast()
}
)
)
}
private fun showDeleteCreatorChannelCommunityPostDialog(item: CreatorChannelCommunityMenuItem) {
if (!item.isOwner) return
V2ModalDialog(
activity = this,
layoutInflater = layoutInflater,
title = getString(R.string.screen_creator_community_delete_title),
desc = getString(R.string.screen_creator_community_delete_desc),
confirmButtonTitle = getString(R.string.confirm_delete_title),
confirmButtonClick = { deleteCreatorChannelCommunityPost(item) },
cancelButtonTitle = getString(R.string.cancel)
).show(screenWidth)
}
private fun deleteCreatorChannelCommunityPost(item: CreatorChannelCommunityMenuItem) {
if (!item.isOwner || isCommunityPostMutating) return
val request = Gson().toJson(
ModifyCommunityPostRequest(
creatorCommunityId = item.postId,
isActive = false
)
).toRequestBody("text/plain".toMediaType())
isCommunityPostMutating = true
compositeDisposable.add(
creatorCommunityRepository.modifyCommunityPost(postImage = null, request = request, token = authToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ response ->
isCommunityPostMutating = false
if (response.success) {
handleCommunityChange(CommunityChange.Updated)
} else {
showCommunityMutationFailureToast(response.message)
}
},
{
isCommunityPostMutating = false
showCommunityMutationFailureToast()
}
)
)
}
private fun reportCreatorChannelCommunityPost(
item: CreatorChannelCommunityMenuItem,
reason: String
) {
if (item.isOwner || !item.showMore || reason.isBlank() || isCommunityPostMutating) return
isCommunityPostMutating = true
compositeDisposable.add(
creatorChannelRepository.reportCommunityPost(item.postId, reason, authToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ response ->
isCommunityPostMutating = false
if (response.success) {
showToast(
if (response.message.isNullOrBlank()) {
getString(R.string.character_comment_report_submitted)
} else {
response.message
}
)
} else {
showCommunityMutationFailureToast(response.message)
}
},
{
isCommunityPostMutating = false
showCommunityMutationFailureToast()
}
)
)
}
private fun showCommunityMutationFailureToast(message: String? = null) {
showToast(message.takeUnless { it.isNullOrBlank() } ?: getString(R.string.common_error_unknown))
}
private fun authToken(): String = "Bearer ${SharedPreferenceManager.token}"
override fun onCreatorChannelFanTalkContentChanged() {
updateViewPagerHeight {
postCheckCreatorChannelCurrentTabNeedsMore()
@@ -697,93 +837,6 @@ class CreatorChannelActivity :
).show(screenWidth)
}
override fun onCreatorChannelCommunityOwnerMoreClicked(item: CreatorChannelCommunityPostUiModel) {
CreatorCommunityPostMenuBottomSheetDialog(
isFixed = item.isPinned,
isCreator = true,
onClickPin = {
updateCreatorChannelCommunityPostFixed(item)
},
onClickModify = {
communityPostModifyLauncher.launch(
Intent(this, CreatorCommunityModifyActivity::class.java).apply {
putExtra(Constants.EXTRA_COMMUNITY_POST_ID, item.postId)
}
)
},
onClickDelete = {
showCreatorChannelCommunityDeleteDialog(item)
},
onClickReport = {}
).show(supportFragmentManager, CreatorCommunityPostMenuBottomSheetDialog::class.java.simpleName)
}
private fun showCreatorChannelCommunityDeleteDialog(item: CreatorChannelCommunityPostUiModel) {
V2ModalDialog(
activity = this,
layoutInflater = layoutInflater,
title = getString(R.string.screen_creator_community_delete_title),
desc = getString(R.string.screen_creator_community_delete_desc),
confirmButtonTitle = getString(R.string.confirm_delete_title),
confirmButtonClick = {
deleteCreatorChannelCommunityPost(item)
},
cancelButtonTitle = getString(R.string.cancel),
cancelButtonClick = {}
).show(screenWidth)
}
private fun updateCreatorChannelCommunityPostFixed(item: CreatorChannelCommunityPostUiModel) {
compositeDisposable.add(
creatorCommunityRepository.updateCommunityPostFixed(
postId = item.postId,
isFixed = !item.isPinned,
token = authToken()
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ response ->
if (response.success) {
handleCommunityChange(CommunityChange.PinChanged(item.postId))
} else {
response.message?.let(::showToast)
}
},
{ error -> error.message?.let(::showToast) }
)
)
}
private fun deleteCreatorChannelCommunityPost(item: CreatorChannelCommunityPostUiModel) {
val request = ModifyCommunityPostRequest(
creatorCommunityId = item.postId,
isActive = false
)
val requestJson = Gson().toJson(request)
compositeDisposable.add(
creatorCommunityRepository.modifyCommunityPost(
postImage = null,
request = requestJson.toRequestBody("text/plain".toMediaType()),
token = authToken()
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ response ->
if (response.success) {
handleCommunityChange(CommunityChange.Deleted(item.postId))
} else {
response.message?.let(::showToast)
}
},
{ error -> error.message?.let(::showToast) }
)
)
}
private fun authToken(): String = "Bearer ${SharedPreferenceManager.token}"
private fun refreshCreatorChannelCommunity() {
findCommunityFragment()?.onCreatorChannelCommunityRefreshRequested()
}
@@ -795,9 +848,10 @@ class CreatorChannelActivity :
homeActionDelegate?.refreshHome()
refreshCreatorChannelCommunity()
}
CommunityChange.Updated,
is CommunityChange.Deleted,
is CommunityChange.PinChanged -> refreshCreatorChannelCommunity()
CommunityChange.Updated -> {
homeActionDelegate?.refreshHome()
refreshCreatorChannelCommunity()
}
}
}
@@ -10,6 +10,7 @@ import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelAudioConte
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelLiveResponse
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelScheduleResponse
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelSeriesResponse
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityMenuItem
import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelHeaderUiModel
import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelHomeUiState
import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelTab
@@ -28,7 +29,8 @@ class CreatorChannelHomeFragment : BaseFragment<FragmentCreatorChannelHomeBindin
onSeriesClick = ::onSeriesClicked,
onDonationClick = ::onDonationClicked,
onSectionChevronClick = ::onSectionChevronClicked,
onCommunityClick = ::onCommunityClicked
onCommunityClick = ::onCommunityClicked,
onCommunityMoreClick = ::onCommunityMoreClicked
)
private val creatorId: Long by lazy { arguments?.getLong(ARG_CREATOR_ID) ?: 0L }
private val host: Host
@@ -134,6 +136,10 @@ class CreatorChannelHomeFragment : BaseFragment<FragmentCreatorChannelHomeBindin
host.onCreatorChannelCommunityPostClicked(postId)
}
private fun onCommunityMoreClicked(item: CreatorChannelCommunityMenuItem) {
host.onCreatorChannelCommunityMoreClicked(item)
}
private fun onCurrentLiveClicked(live: CreatorChannelLiveResponse) {
host.onCreatorChannelCurrentLiveClicked(live)
}
@@ -150,6 +156,7 @@ class CreatorChannelHomeFragment : BaseFragment<FragmentCreatorChannelHomeBindin
fun onCreatorChannelDonationClicked()
fun onCreatorChannelHomeTabRequested(tab: CreatorChannelTab)
fun onCreatorChannelCommunityPostClicked(postId: Long)
fun onCreatorChannelCommunityMoreClicked(item: CreatorChannelCommunityMenuItem)
fun onCreatorChannelCurrentLiveClicked(live: CreatorChannelLiveResponse)
}
@@ -11,11 +11,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseFragment
import kr.co.vividnext.sodalive.databinding.FragmentCreatorChannelCommunityBinding
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.player.CreatorCommunityContentItem
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.player.CreatorCommunityMediaPlayerManager
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.extensions.moneyFormat
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityPostUiModel
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityMenuItem
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityViewMode
import kr.co.vividnext.sodalive.v2.creator.channel.community.ui.CreatorChannelCommunityGridAdapter
import kr.co.vividnext.sodalive.v2.creator.channel.community.ui.calculateCreatorChannelCommunityGridItemSize
@@ -29,14 +27,11 @@ class CreatorChannelCommunityFragment : BaseFragment<FragmentCreatorChannelCommu
private val viewModel: CreatorChannelCommunityViewModel by viewModel()
private val listAdapter = CreatorChannelCommunityListAdapter(
onPostClick = { item -> host.onCreatorChannelCommunityPostClicked(item.postId) },
onPlayClick = { item -> toggleCommunityAudio(item) },
onOwnerMoreClick = { item -> host.onCreatorChannelCommunityOwnerMoreClicked(item) },
isPlayingContent = { postId -> mediaPlayerManager?.isPlayingContent(postId) == true }
onMoreClick = { item -> host.onCreatorChannelCommunityMoreClicked(item) }
)
private val gridAdapter = CreatorChannelCommunityGridAdapter(
onPostClick = { item -> host.onCreatorChannelCommunityPostClicked(item.postId) }
)
private var mediaPlayerManager: CreatorCommunityMediaPlayerManager? = null
private var currentContentState: CreatorChannelCommunityUiState.Content? = null
private var lastContentLayoutKey: CreatorChannelCommunityContentLayoutKey? = null
private val creatorId: Long by lazy { arguments?.getLong(ARG_CREATOR_ID) ?: 0L }
@@ -45,7 +40,6 @@ class CreatorChannelCommunityFragment : BaseFragment<FragmentCreatorChannelCommu
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mediaPlayerManager = CreatorCommunityMediaPlayerManager(requireContext()) { listAdapter.notifyDataSetChanged() }
bindLoading()
setupCommunityList()
setupClickListeners()
@@ -53,19 +47,12 @@ class CreatorChannelCommunityFragment : BaseFragment<FragmentCreatorChannelCommu
}
override fun onDestroyView() {
mediaPlayerManager?.stopContent()
mediaPlayerManager = null
currentContentState = null
lastContentLayoutKey = null
binding.rvCreatorChannelCommunity.adapter = null
super.onDestroyView()
}
override fun onPause() {
mediaPlayerManager?.pauseContent()
super.onPause()
}
private fun setupCommunityList() = with(binding.rvCreatorChannelCommunity) {
layoutManager = LinearLayoutManager(requireContext())
adapter = listAdapter
@@ -220,16 +207,11 @@ class CreatorChannelCommunityFragment : BaseFragment<FragmentCreatorChannelCommu
layoutCreatorChannelCommunityEmpty.updatePadding(bottom = bottomPadding)
}
private fun toggleCommunityAudio(item: CreatorChannelCommunityPostUiModel) {
val audioUrl = item.audioUrl ?: return
mediaPlayerManager?.toggleContent(CreatorCommunityContentItem(item.postId, audioUrl))
}
interface Host {
fun isCreatorChannelOwner(): Boolean
fun onCreatorChannelCommunityContentChanged()
fun onCreatorChannelCommunityPostClicked(postId: Long)
fun onCreatorChannelCommunityOwnerMoreClicked(item: CreatorChannelCommunityPostUiModel)
fun onCreatorChannelCommunityMoreClicked(item: CreatorChannelCommunityMenuItem)
}
companion object {
@@ -23,10 +23,14 @@ import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.common.Constants
import kr.co.vividnext.sodalive.databinding.ActivityCreatorChannelCommunityDetailBinding
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.CreatorCommunityPostMenuBottomSheetDialog
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.CreatorCommunityReportDialog
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.PurchaseCommunityPostDialog
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.player.CreatorCommunityContentItem
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.player.CreatorCommunityMediaPlayerManager
import kr.co.vividnext.sodalive.explorer.profile.creator_community.modify.CreatorCommunityModifyActivity
import kr.co.vividnext.sodalive.extensions.loadUrl
import kr.co.vividnext.sodalive.extensions.moneyFormat
import kr.co.vividnext.sodalive.v2.components.modal.V2ModalDialog
@@ -40,6 +44,12 @@ class CreatorChannelCommunityDetailActivity : BaseActivity<ActivityCreatorChanne
) {
private val viewModel: CreatorChannelCommunityDetailViewModel by viewModel()
private val modifyLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK && postId > 0L) {
setResult(Activity.RESULT_OK)
viewModel.loadDetail(postId)
}
}
private val replyLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK && postId > 0L) {
setResult(Activity.RESULT_OK)
@@ -65,6 +75,11 @@ class CreatorChannelCommunityDetailActivity : BaseActivity<ActivityCreatorChanne
}
binding.btnCreatorChannelCommunityDetailBack.setOnClickListener { finish() }
binding.btnCreatorChannelCommunityDetailMore.setOnClickListener {
val content = viewModel.detailStateLiveData.value as? CreatorChannelCommunityDetailUiState.Content
?: return@setOnClickListener
showPostMenu(content.post)
}
binding.layoutCreatorChannelCommunityDetailImageContainer.clipToOutline = true
binding.layoutCreatorChannelCommunityDetailImageContainer.outlineProvider = roundedOutlineProvider()
binding.rvCreatorChannelCommunityDetailComments.layoutManager = LinearLayoutManager(this)
@@ -103,6 +118,13 @@ class CreatorChannelCommunityDetailActivity : BaseActivity<ActivityCreatorChanne
viewModel.consumePostChangedEvent()
}
}
viewModel.postDeletedEventLiveData.observe(this) { deleted ->
if (deleted == true) {
setResult(Activity.RESULT_OK)
viewModel.consumePostDeletedEvent()
finish()
}
}
viewModel.toastLiveData.observe(this) { event ->
event.consume()?.let { toast ->
val message = toast.message ?: toast.resId?.let(::getString)
@@ -150,6 +172,7 @@ class CreatorChannelCommunityDetailActivity : BaseActivity<ActivityCreatorChanne
}
tvCreatorChannelCommunityDetailNickname.text = post.creatorNickname
tvCreatorChannelCommunityDetailTime.text = post.createdAtText
btnCreatorChannelCommunityDetailMore.isVisible = post.showMore
tvCreatorChannelCommunityDetailBody.text = post.content
layoutCreatorChannelCommunityDetailReaction.isVisible = post.showReaction || content.isCommentAvailable
tvCreatorChannelCommunityDetailLikeCount.text = post.likeCount.moneyFormat()
@@ -163,9 +186,6 @@ class CreatorChannelCommunityDetailActivity : BaseActivity<ActivityCreatorChanne
ivCreatorChannelCommunityDetailHeart.setImageResource(
if (post.isLiked) R.drawable.ic_feed_community_heart_fill else R.drawable.ic_feed_community_heart
)
layoutCreatorChannelCommunityDetailPrice.isVisible = post.isLocked
tvCreatorChannelCommunityDetailPrice.text = post.price.moneyFormat()
tvCreatorChannelCommunityDetailPurchased.isVisible = post.existOrdered && post.price > 0
layoutCreatorChannelCommunityDetailImageContainer.isVisible = post.imageUrl != null || post.showPaywall
layoutCreatorChannelCommunityDetailImageContainer.layoutParams =
layoutCreatorChannelCommunityDetailImageContainer.layoutParams.apply {
@@ -296,6 +316,37 @@ class CreatorChannelCommunityDetailActivity : BaseActivity<ActivityCreatorChanne
).show(screenWidth)
}
private fun showPostMenu(post: CreatorChannelCommunityPostDetailUiModel) {
CreatorCommunityPostMenuBottomSheetDialog(
isFixed = post.isPinned,
isCreator = post.isOwner,
onClickPin = viewModel::updateCommunityPostFixed,
onClickModify = {
modifyLauncher.launch(
Intent(this, CreatorCommunityModifyActivity::class.java).apply {
putExtra(Constants.EXTRA_COMMUNITY_POST_ID, post.postId)
}
)
},
onClickDelete = ::showDeletePostDialog,
onClickReport = {
CreatorCommunityReportDialog(this, layoutInflater, viewModel::reportCommunityPost).show(screenWidth)
}
).show(supportFragmentManager, CreatorCommunityPostMenuBottomSheetDialog::class.java.simpleName)
}
private fun showDeletePostDialog() {
V2ModalDialog(
activity = this,
layoutInflater = layoutInflater,
title = getString(R.string.screen_creator_community_delete_title),
desc = getString(R.string.screen_creator_community_delete_desc),
confirmButtonTitle = getString(R.string.confirm_delete_title),
confirmButtonClick = viewModel::deleteCommunityPost,
cancelButtonTitle = getString(R.string.cancel)
).show(screenWidth)
}
private fun showDeleteCommentDialog(commentId: Long) {
V2ModalDialog(
activity = this,
@@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.v2.creator.channel.community.detail
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
import kr.co.vividnext.sodalive.R
@@ -12,12 +13,15 @@ import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.common.ToastMessage
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.explorer.profile.creator_community.CreatorCommunityRepository
import kr.co.vividnext.sodalive.explorer.profile.creator_community.modify.ModifyCommunityPostRequest
import kr.co.vividnext.sodalive.v2.creator.channel.CreatorChannelEvent
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.data.CreatorChannelCommunityCommentResponse
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.data.CreatorChannelCommunityCommentsResponse
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.data.CreatorChannelCommunityPostDetailResponse
import kr.co.vividnext.sodalive.v2.creator.channel.community.detail.data.CreatorChannelCommunityReplyResponse
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody
class CreatorChannelCommunityDetailViewModel(
private val repository: CreatorChannelRepository,
@@ -37,6 +41,10 @@ class CreatorChannelCommunityDetailViewModel(
val postChangedEventLiveData: LiveData<Boolean>
get() = _postChangedEventLiveData
private val _postDeletedEventLiveData = MutableLiveData<Boolean>()
val postDeletedEventLiveData: LiveData<Boolean>
get() = _postDeletedEventLiveData
private val _toastLiveData = MutableLiveData<CreatorChannelEvent<ToastMessage>>()
val toastLiveData: LiveData<CreatorChannelEvent<ToastMessage>>
get() = _toastLiveData
@@ -49,6 +57,7 @@ class CreatorChannelCommunityDetailViewModel(
private var isSendingComment = false
private var isModifyingComment = false
private var isPurchasingPost = false
private var isMutatingPost = false
fun loadDetail(postId: Long) {
if (postId <= 0) return
@@ -181,6 +190,10 @@ class CreatorChannelCommunityDetailViewModel(
_postChangedEventLiveData.value = false
}
fun consumePostDeletedEvent() {
_postDeletedEventLiveData.value = false
}
fun startCommentEdit(commentId: Long, comment: String) {
val content = _detailStateLiveData.value as? CreatorChannelCommunityDetailUiState.Content ?: return
if (commentId <= 0) return
@@ -245,6 +258,97 @@ class CreatorChannelCommunityDetailViewModel(
)
}
fun updateCommunityPostFixed() {
val content = _detailStateLiveData.value as? CreatorChannelCommunityDetailUiState.Content ?: return
if (!content.post.isOwner || isMutatingPost) return
isMutatingPost = true
compositeDisposable.add(
legacyRepository.updateCommunityPostFixed(postId, !content.post.isPinned, authToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ response ->
isMutatingPost = false
if (response.success) {
_postChangedEventLiveData.value = true
loadDetail(postId)
} else {
showMutationFailureToast(response.message)
}
},
{
isMutatingPost = false
showMutationFailureToast()
}
)
)
}
fun deleteCommunityPost() {
val content = _detailStateLiveData.value as? CreatorChannelCommunityDetailUiState.Content ?: return
if (!content.post.isOwner || isMutatingPost) return
val request = Gson().toJson(
ModifyCommunityPostRequest(
creatorCommunityId = postId,
isActive = false
)
).toRequestBody("text/plain".toMediaType())
isMutatingPost = true
compositeDisposable.add(
legacyRepository.modifyCommunityPost(postImage = null, request = request, token = authToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ response ->
isMutatingPost = false
if (response.success) {
_postDeletedEventLiveData.value = true
} else {
showMutationFailureToast(response.message)
}
},
{
isMutatingPost = false
showMutationFailureToast()
}
)
)
}
fun reportCommunityPost(reason: String) {
val content = _detailStateLiveData.value as? CreatorChannelCommunityDetailUiState.Content ?: return
if (reason.isBlank() || content.post.isOwner || !content.post.showMore || isMutatingPost) return
isMutatingPost = true
compositeDisposable.add(
repository.reportCommunityPost(postId, reason, authToken())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ response ->
isMutatingPost = false
if (response.success) {
_toastLiveData.value = CreatorChannelEvent(
if (response.message.isNullOrBlank()) {
ToastMessage(resId = R.string.character_comment_report_submitted)
} else {
ToastMessage(message = response.message)
}
)
} else {
showMutationFailureToast(response.message)
}
},
{
isMutatingPost = false
showMutationFailureToast()
}
)
)
}
private fun submitCommentEdit(
content: CreatorChannelCommunityDetailUiState.Content,
commentId: Long,
@@ -425,25 +529,30 @@ class CreatorChannelCommunityDetailViewModel(
)
}
private fun CreatorChannelCommunityPostDetailResponse.toUiModel() = CreatorChannelCommunityPostDetailUiModel(
postId = postId,
creatorId = creatorId,
creatorNickname = creatorNickname,
creatorProfileUrl = creatorProfileUrl,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
content = content,
imageUrl = imageUrl.takeUnless { isLocked() },
audioUrl = audioUrl.takeUnless { isLocked() },
price = price,
existOrdered = existOrdered,
likeCount = likeCount,
commentCount = commentCount,
isLiked = isLiked,
isPinned = isPinned,
isLocked = isLocked(),
showPaywall = isLocked(),
showReaction = !isLocked()
)
private fun CreatorChannelCommunityPostDetailResponse.toUiModel(): CreatorChannelCommunityPostDetailUiModel {
val isOwner = creatorId == SharedPreferenceManager.userId
return CreatorChannelCommunityPostDetailUiModel(
postId = postId,
creatorId = creatorId,
creatorNickname = creatorNickname,
creatorProfileUrl = creatorProfileUrl,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
content = content,
imageUrl = imageUrl.takeUnless { isLocked() },
audioUrl = audioUrl.takeUnless { isLocked() },
price = price,
existOrdered = existOrdered,
likeCount = likeCount,
commentCount = commentCount,
isLiked = isLiked,
isPinned = isPinned,
isOwner = isOwner,
showMore = isOwner || price == 0 || existOrdered,
isLocked = isLocked(),
showPaywall = isLocked(),
showReaction = !isLocked()
)
}
private fun CreatorChannelCommunityPostDetailResponse.isLocked(): Boolean {
return price > 0 && !existOrdered && creatorId != SharedPreferenceManager.userId
@@ -526,6 +635,8 @@ data class CreatorChannelCommunityPostDetailUiModel(
val commentCount: Int,
val isLiked: Boolean,
val isPinned: Boolean,
val isOwner: Boolean,
val showMore: Boolean,
val isLocked: Boolean,
val showPaywall: Boolean,
val showReaction: Boolean
@@ -21,7 +21,6 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
val isLocked = price > 0 && !existOrdered && !isOwner
val showOwnerActions = isOwner && creatorId == currentUserId
val visibleImageUrl = imageUrl.takeUnless { isLocked }
val showPlayButton = !isLocked && !audioUrl.isNullOrBlank() && !visibleImageUrl.isNullOrBlank()
return CreatorChannelCommunityPostUiModel(
postId = postId,
creatorId = creatorId,
@@ -30,7 +29,6 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
content = content,
imageUrl = visibleImageUrl,
audioUrl = audioUrl,
price = price,
existOrdered = existOrdered,
likeCount = likeCount,
@@ -40,11 +38,17 @@ private fun CreatorChannelCommunityPostResponse.toCommunityPostUiModel(
showNotice = isPinned,
isPinned = isPinned,
isLocked = isLocked,
showOwnerMore = showOwnerActions,
showOwnerTopPrice = showOwnerActions && price > 0,
showPlayButton = showPlayButton,
gridPreviewText = content.toGridPreviewText(),
imageMode = toImageMode(isLocked, visibleImageUrl)
imageMode = toImageMode(isLocked, visibleImageUrl),
menuItem = CreatorChannelCommunityMenuItem(
postId = postId,
creatorId = creatorId,
currentUserId = currentUserId,
price = price,
existOrdered = existOrdered,
isPinned = isPinned
)
)
}
@@ -0,0 +1,16 @@
package kr.co.vividnext.sodalive.v2.creator.channel.community.model
data class CreatorChannelCommunityMenuItem(
val postId: Long,
val creatorId: Long,
val currentUserId: Long,
val price: Int,
val existOrdered: Boolean,
val isPinned: Boolean
) {
val isOwner: Boolean
get() = creatorId == currentUserId
val showMore: Boolean
get() = isOwner || price == 0 || existOrdered
}
@@ -32,7 +32,6 @@ data class CreatorChannelCommunityPostUiModel(
val createdAtText: String,
val content: String,
val imageUrl: String?,
val audioUrl: String?,
val price: Int,
val existOrdered: Boolean,
val likeCount: Int,
@@ -42,9 +41,8 @@ data class CreatorChannelCommunityPostUiModel(
val showNotice: Boolean,
val isPinned: Boolean,
val isLocked: Boolean,
val showOwnerMore: Boolean,
val showOwnerTopPrice: Boolean,
val showPlayButton: Boolean,
val gridPreviewText: String,
val imageMode: CreatorChannelCommunityImageMode
val imageMode: CreatorChannelCommunityImageMode,
val menuItem: CreatorChannelCommunityMenuItem
)
@@ -19,14 +19,13 @@ import kr.co.vividnext.sodalive.databinding.ItemCreatorChannelCommunityListBindi
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.extensions.loadUrl
import kr.co.vividnext.sodalive.extensions.moneyFormat
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityMenuItem
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityPostUiModel
import kr.co.vividnext.sodalive.v2.widget.feed.calculateFeedCommunityImageHeight
class CreatorChannelCommunityListAdapter(
private val onPostClick: (CreatorChannelCommunityPostUiModel) -> Unit = {},
private val onPlayClick: (CreatorChannelCommunityPostUiModel) -> Unit = {},
private val onOwnerMoreClick: (CreatorChannelCommunityPostUiModel) -> Unit = {},
private val isPlayingContent: (Long) -> Boolean = { false }
private val onMoreClick: (CreatorChannelCommunityMenuItem) -> Unit = {}
) : RecyclerView.Adapter<CreatorChannelCommunityListAdapter.ViewHolder>() {
private var items: List<CreatorChannelCommunityPostUiModel> = emptyList()
@@ -40,9 +39,7 @@ class CreatorChannelCommunityListAdapter(
return ViewHolder(
ItemCreatorChannelCommunityListBinding.inflate(LayoutInflater.from(parent.context), parent, false),
onPostClick,
onPlayClick,
onOwnerMoreClick,
isPlayingContent
onMoreClick
)
}
@@ -55,9 +52,7 @@ class CreatorChannelCommunityListAdapter(
class ViewHolder(
private val binding: ItemCreatorChannelCommunityListBinding,
private val onPostClick: (CreatorChannelCommunityPostUiModel) -> Unit,
private val onPlayClick: (CreatorChannelCommunityPostUiModel) -> Unit,
private val onOwnerMoreClick: (CreatorChannelCommunityPostUiModel) -> Unit,
private val isPlayingContent: (Long) -> Boolean
private val onMoreClick: (CreatorChannelCommunityMenuItem) -> Unit
) : RecyclerView.ViewHolder(binding.root) {
init {
@@ -86,7 +81,7 @@ class CreatorChannelCommunityListAdapter(
val visibleImageUrl = item.imageUrl.takeUnless { item.isLocked }
layoutCreatorChannelCommunityListImageContainer.isVisible =
visibleImageUrl != null || item.isLocked || item.showPlayButton
visibleImageUrl != null || item.isLocked
ivCreatorChannelCommunityListImage.isVisible = visibleImageUrl != null
resetCommunityImageHeight()
if (visibleImageUrl != null) {
@@ -119,19 +114,14 @@ class CreatorChannelCommunityListAdapter(
}
layoutCreatorChannelCommunityListLockedOverlay.isVisible = item.isLocked
ivCreatorChannelCommunityListLock.isVisible = item.isLocked
tvCreatorChannelCommunityListLockedPrice.isVisible = item.isLocked
layoutCreatorChannelCommunityListLockedPrice.isVisible = item.isLocked
tvCreatorChannelCommunityListLockedPrice.text = item.price.moneyFormat()
ivCreatorChannelCommunityListPlay.isVisible = item.showPlayButton
ivCreatorChannelCommunityListPlay.setImageResource(
if (isPlayingContent(item.postId)) R.drawable.ic_player_pause else R.drawable.ic_new_player_play
)
ivCreatorChannelCommunityListPlay.setOnClickListener { onPlayClick(item) }
layoutCreatorChannelCommunityListTopActions.isVisible = item.showOwnerMore || item.showOwnerTopPrice
layoutCreatorChannelCommunityListTopActions.isVisible = item.showOwnerTopPrice || item.menuItem.showMore
layoutCreatorChannelCommunityListTopPrice.isVisible = item.showOwnerTopPrice
tvCreatorChannelCommunityListTopPrice.text = item.price.moneyFormat()
ivCreatorChannelCommunityListOwnerMore.isVisible = item.showOwnerMore
ivCreatorChannelCommunityListOwnerMore.setOnClickListener { onOwnerMoreClick(item) }
btnCreatorChannelCommunityListMore.isVisible = item.menuItem.showMore
btnCreatorChannelCommunityListMore.setOnClickListener { onMoreClick(item.menuItem) }
}
private fun resetCommunityImageHeight() {
@@ -103,7 +103,9 @@ data class CreatorChannelCommunityPostResponse(
@SerializedName("dateUtc") val dateUtc: String,
@SerializedName("existOrdered") val existOrdered: Boolean,
@SerializedName("likeCount") val likeCount: Int,
@SerializedName("commentCount") val commentCount: Int
@SerializedName("commentCount") val commentCount: Int,
@SerializedName("isPinned") val isPinned: Boolean,
@SerializedName("isCommentAvailable") val isCommentAvailable: Boolean
)
@Keep
@@ -185,6 +185,11 @@ class CreatorChannelRepository(
token = token
)
fun reportCommunityPost(postId: Long, reason: String, token: String) = reportRepository.report(
request = ReportRequest(ReportType.COMMUNITY_POST, reason, communityPostId = postId),
token = token
)
fun deleteFanTalk(fanTalkId: Long, token: String) = explorerRepository.modifyCheers(
request = PutModifyCheersRequest(cheersId = fanTalkId, isActive = false),
token = token
@@ -18,7 +18,8 @@ fun CreatorChannelHomeResponse.toUiContent(currentMemberId: Long): CreatorChanne
?.let { add(CreatorChannelHomeSection.Schedules(it)) }
audioContents.takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.AudioContents(it)) }
series.takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.Series(it)) }
communities.takeIf { it.isNotEmpty() }?.let { add(CreatorChannelHomeSection.Communities(it)) }
communities.takeIf { it.isNotEmpty() }
?.let { add(CreatorChannelHomeSection.Communities(it, currentMemberId)) }
add(CreatorChannelHomeSection.FanTalk(fanTalk))
introduce.takeIf { it.isNotBlank() }?.let { add(CreatorChannelHomeSection.Introduce(it)) }
add(CreatorChannelHomeSection.Activity(activity))
@@ -57,7 +57,10 @@ sealed interface CreatorChannelHomeSection {
data class Schedules(val schedules: List<CreatorChannelScheduleResponse>) : CreatorChannelHomeSection
data class AudioContents(val audioContents: List<CreatorChannelAudioContentResponse>) : CreatorChannelHomeSection
data class Series(val series: List<CreatorChannelSeriesResponse>) : CreatorChannelHomeSection
data class Communities(val communities: List<CreatorChannelCommunityPostResponse>) : CreatorChannelHomeSection
data class Communities(
val communities: List<CreatorChannelCommunityPostResponse>,
val currentMemberId: Long
) : CreatorChannelHomeSection
data class FanTalk(val fanTalk: CreatorChannelFanTalkSummaryResponse) : CreatorChannelHomeSection
data class Introduce(val introduce: String) : CreatorChannelHomeSection
data class Activity(val activity: CreatorChannelActivityResponse) : CreatorChannelHomeSection
@@ -25,6 +25,7 @@ import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelCommunityP
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelLiveResponse
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelScheduleResponse
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelSeriesResponse
import kr.co.vividnext.sodalive.v2.creator.channel.community.model.CreatorChannelCommunityMenuItem
import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelHomeSection
import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelTab
import kr.co.vividnext.sodalive.v2.widget.feed.FeedCommunityView
@@ -43,7 +44,8 @@ class CreatorChannelHomeSectionAdapter(
private val onSeriesClick: (CreatorChannelSeriesResponse) -> Unit = {},
private val onDonationClick: () -> Unit = {},
private val onSectionChevronClick: (CreatorChannelTab) -> Unit = {},
private val onCommunityClick: (Long) -> Unit = {}
private val onCommunityClick: (Long) -> Unit = {},
private val onCommunityMoreClick: (CreatorChannelCommunityMenuItem) -> Unit = {}
) : RecyclerView.Adapter<CreatorChannelHomeSectionAdapter.SectionViewHolder>() {
private var items: List<CreatorChannelHomeSection> = emptyList()
@@ -65,7 +67,8 @@ class CreatorChannelHomeSectionAdapter(
onSeriesClick,
onDonationClick,
onSectionChevronClick,
onCommunityClick
onCommunityClick,
onCommunityMoreClick
)
}
@@ -83,7 +86,8 @@ class CreatorChannelHomeSectionAdapter(
private val onSeriesClick: (CreatorChannelSeriesResponse) -> Unit,
private val onDonationClick: () -> Unit,
private val onSectionChevronClick: (CreatorChannelTab) -> Unit,
private val onCommunityClick: (Long) -> Unit
private val onCommunityClick: (Long) -> Unit,
private val onCommunityMoreClick: (CreatorChannelCommunityMenuItem) -> Unit
) : RecyclerView.ViewHolder(view) {
private val title: TextView? = view.findViewById(R.id.tv_section_title)
private val sectionTitleChevron: ImageView? = view.findViewById(R.id.iv_section_title_chevron)
@@ -366,6 +370,14 @@ class CreatorChannelHomeSectionAdapter(
communityMoreButton?.setOnClickListener { onSectionChevronClick(CreatorChannelTab.Community) }
val visibleCommunities = item.communities.take(MAX_COMMUNITY_ITEM_COUNT)
visibleCommunities.forEachIndexed { index, community ->
val menuItem = CreatorChannelCommunityMenuItem(
postId = community.postId,
creatorId = community.creatorId,
currentUserId = item.currentMemberId,
price = community.price,
existOrdered = community.existOrdered,
isPinned = community.isPinned
)
val communityWidthDp = calculateCreatorChannelCommunityCardWidthDp(
itemView.resources.configuration.screenWidthDp
)
@@ -381,7 +393,8 @@ class CreatorChannelHomeSectionAdapter(
)
)
setHideEmptyTextRows(true)
bind(community.toFeedCommunityItem())
bind(community.toFeedCommunityItem(showMore = menuItem.showMore))
setOnMoreClick { onCommunityMoreClick(menuItem) }
}
bindCommunityImages(row, community)
row.layoutParams = LinearLayout.LayoutParams(
@@ -443,7 +456,9 @@ class CreatorChannelHomeSectionAdapter(
}
}
private fun CreatorChannelCommunityPostResponse.toFeedCommunityItem(): FeedItem.Community = FeedItem.Community(
private fun CreatorChannelCommunityPostResponse.toFeedCommunityItem(
showMore: Boolean
): FeedItem.Community = FeedItem.Community(
feedId = postId.toString(),
creatorId = creatorId.toString(),
creatorName = creatorNickname,
@@ -458,7 +473,11 @@ class CreatorChannelHomeSectionAdapter(
audioUrl = audioUrl,
price = price,
existOrdered = existOrdered,
showKeyword = false
isPinned = isPinned,
isCommentAvailable = isCommentAvailable,
hideReactionWhenLocked = true,
showKeyword = false,
showMore = showMore
)
private fun bindIntroduce(item: CreatorChannelHomeSection.Introduce) {
@@ -20,6 +20,8 @@ class FeedCommunityView @JvmOverloads constructor(
) : LinearLayout(context, attrs, defStyleAttr) {
private var profileImage: ImageView? = null
private var noticeRow: View? = null
private var moreButton: View? = null
private var creatorText: TextView? = null
private var createdAtText: TextView? = null
private var bodyText: TextView? = null
@@ -27,15 +29,21 @@ class FeedCommunityView @JvmOverloads constructor(
private var communityImage: ImageView? = null
private var paidOverlay: View? = null
private var priceText: TextView? = null
private var reactionRow: View? = null
private var commentIcon: ImageView? = null
private var commentCountText: TextView? = null
private var likeIcon: ImageView? = null
private var likeCountText: TextView? = null
private var currentItem: FeedItem.Community? = null
private var clickListener: ((FeedItem) -> Unit)? = null
private var moreClickListener: ((FeedItem.Community) -> Unit)? = null
private var hideEmptyTextRows: Boolean = false
override fun onFinishInflate() {
super.onFinishInflate()
noticeRow = findViewById(R.id.ll_feed_community_notice)
profileImage = findViewById(R.id.iv_feed_community_profile)
moreButton = findViewById(R.id.btn_feed_community_more)
creatorText = findViewById(R.id.tv_feed_community_creator)
createdAtText = findViewById(R.id.tv_feed_community_created_at)
bodyText = findViewById(R.id.tv_feed_community_body)
@@ -43,7 +51,10 @@ class FeedCommunityView @JvmOverloads constructor(
communityImage = findViewById(R.id.iv_feed_community_image)
paidOverlay = findViewById(R.id.ll_feed_community_paid_overlay)
priceText = findViewById(R.id.tv_feed_community_price)
reactionRow = findViewById(R.id.ll_feed_community_reaction)
commentIcon = findViewById(R.id.iv_feed_community_comment)
commentCountText = findViewById(R.id.tv_feed_community_comment_count)
likeIcon = findViewById(R.id.iv_feed_community_like)
likeCountText = findViewById(R.id.tv_feed_community_like_count)
clipToOutline = true
outlineProvider = roundedOutlineProvider(CARD_RADIUS_DP)
@@ -59,7 +70,8 @@ class FeedCommunityView @JvmOverloads constructor(
requireNotNull(createdAtText).text = item.createdAtText
requireNotNull(bodyText).text = item.bodyText
requireNotNull(bodyText).visibility = visibilityForText(item.bodyText)
val isLocked = item.price > 0 && !item.existOrdered
requireNotNull(noticeRow).isVisible = item.isPinned
val isLocked = item.isLocked
val hasImage = !item.imageUrl.isNullOrBlank()
requireNotNull(communityImageContainer).isVisible = hasImage || isLocked
resetCommunityImageHeight()
@@ -69,9 +81,15 @@ class FeedCommunityView @JvmOverloads constructor(
}
requireNotNull(paidOverlay).isVisible = isLocked
requireNotNull(priceText).text = item.price.toString()
requireNotNull(reactionRow).isVisible = item.showReaction
requireNotNull(commentIcon).isVisible = item.showComment
requireNotNull(commentCountText).text = item.commentCount.toString()
requireNotNull(commentCountText).isVisible = item.showComment
requireNotNull(likeIcon).isVisible = item.showReaction
requireNotNull(likeCountText).text = item.likeCount.toString()
requireNotNull(likeCountText).isVisible = item.showReaction
applyClickState(item)
applyMoreClickState(item)
}
fun profileImageView(): ImageView = requireNotNull(profileImage)
@@ -116,6 +134,11 @@ class FeedCommunityView @JvmOverloads constructor(
currentItem?.let(::applyClickState)
}
fun setOnMoreClick(listener: ((FeedItem.Community) -> Unit)?) {
moreClickListener = listener
currentItem?.let(::applyMoreClickState)
}
fun setHideEmptyTextRows(hide: Boolean) {
hideEmptyTextRows = hide
currentItem?.let(::bind)
@@ -130,6 +153,14 @@ class FeedCommunityView @JvmOverloads constructor(
isClickable = listener != null
}
private fun applyMoreClickState(item: FeedItem.Community) {
val listener = moreClickListener
requireNotNull(moreButton).isVisible = item.showMore
requireNotNull(moreButton).setOnClickListener(
if (listener == null) null else View.OnClickListener { listener(item) }
)
}
private fun updateRootWidth(width: Int) {
val currentLayoutParams = layoutParams
layoutParams = if (currentLayoutParams == null) {
@@ -47,6 +47,19 @@ sealed class FeedItem(open val feedId: String, val variant: FeedVariant) {
val audioUrl: String? = null,
val price: Int = 0,
val existOrdered: Boolean = false,
val showKeyword: Boolean = true
) : FeedItem(feedId, FeedVariant.Community)
val isPinned: Boolean = false,
val isCommentAvailable: Boolean = true,
val hideReactionWhenLocked: Boolean = false,
val showKeyword: Boolean = true,
val showMore: Boolean = false
) : FeedItem(feedId, FeedVariant.Community) {
val isLocked: Boolean
get() = price > 0 && !existOrdered
val showReaction: Boolean
get() = !hideReactionWhenLocked || !isLocked
val showComment: Boolean
get() = showReaction && isCommentAvailable
}
}
@@ -73,7 +73,7 @@
android:includeFontPadding="false"
android:maxLines="1"
android:textColor="@color/white"
app:layout_constraintEnd_toStartOf="@id/layout_creator_channel_community_detail_price"
app:layout_constraintEnd_toStartOf="@id/btn_creator_channel_community_detail_more"
app:layout_constraintStart_toEndOf="@id/iv_creator_channel_community_detail_profile"
app:layout_constraintTop_toTopOf="@id/iv_creator_channel_community_detail_profile"
tools:text="크리에이터" />
@@ -91,36 +91,17 @@
app:layout_constraintTop_toBottomOf="@id/tv_creator_channel_community_detail_nickname"
tools:text="2분 전" />
<LinearLayout
android:id="@+id/layout_creator_channel_community_detail_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_creator_channel_community_price"
android:gravity="center"
android:orientation="horizontal"
android:paddingHorizontal="@dimen/spacing_4"
android:paddingVertical="2dp"
<ImageButton
android:id="@+id/btn_creator_channel_community_detail_more"
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@android:color/transparent"
android:contentDescription="@string/read_more"
android:src="@drawable/ic_seemore_vertical"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/iv_creator_channel_community_detail_profile"
tools:visibility="visible">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:contentDescription="@null"
android:src="@drawable/ic_bar_cash" />
<TextView
android:id="@+id/tv_creator_channel_community_detail_price"
style="@style/Typography.Caption3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:includeFontPadding="false"
android:textColor="@color/black"
tools:text="300" />
</LinearLayout>
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
@@ -222,22 +203,6 @@
tools:text="Audio"
tools:visibility="visible" />
<TextView
android:id="@+id/tv_creator_channel_community_detail_purchased"
style="@style/Typography.Caption2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="@dimen/spacing_8"
android:background="@drawable/bg_creator_channel_community_price"
android:includeFontPadding="false"
android:paddingHorizontal="@dimen/spacing_8"
android:paddingVertical="@dimen/spacing_4"
android:text="@string/creator_channel_community_purchased_badge"
android:textColor="@color/black"
android:visibility="gone"
tools:visibility="visible" />
<LinearLayout
android:id="@+id/layout_creator_channel_community_detail_reaction"
android:layout_width="match_parent"
@@ -122,13 +122,13 @@
tools:text="300" />
</LinearLayout>
<ImageView
android:id="@+id/iv_creator_channel_community_list_owner_more"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="@dimen/spacing_4"
android:contentDescription="@null"
android:src="@drawable/ic_new_more"
<ImageButton
android:id="@+id/btn_creator_channel_community_list_more"
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@android:color/transparent"
android:contentDescription="@string/read_more"
android:src="@drawable/ic_seemore_vertical"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
@@ -187,32 +187,34 @@
android:visibility="gone"
tools:visibility="visible" />
<TextView
android:id="@+id/tv_creator_channel_community_list_locked_price"
style="@style/Typography.Body3"
<LinearLayout
android:id="@+id/layout_creator_channel_community_list_locked_price"
android:layout_width="70dp"
android:layout_height="36dp"
android:layout_marginTop="@dimen/spacing_4"
android:background="@drawable/bg_creator_channel_community_price"
android:drawableStart="@drawable/ic_bar_cash"
android:drawablePadding="@dimen/spacing_6"
android:gravity="center"
android:includeFontPadding="false"
android:textColor="@color/black"
android:orientation="horizontal"
android:visibility="gone"
tools:text="30"
tools:visibility="visible" />
</LinearLayout>
tools:visibility="visible">
<ImageView
android:id="@+id/iv_creator_channel_community_list_play"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:contentDescription="@null"
android:src="@drawable/ic_new_player_play"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:contentDescription="@null"
android:src="@drawable/ic_bar_cash" />
<TextView
android:id="@+id/tv_creator_channel_community_list_locked_price"
style="@style/Typography.Body3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_6"
android:includeFontPadding="false"
android:textColor="@color/black"
tools:text="30" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<LinearLayout
@@ -8,7 +8,33 @@
android:padding="@dimen/spacing_14">
<LinearLayout
android:id="@+id/ll_feed_community_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacing_14"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
android:contentDescription="@null"
android:src="@drawable/ic_pin" />
<TextView
style="@style/Typography.Body5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:includeFontPadding="false"
android:text="@string/creator_channel_community_notice"
android:textColor="@color/green_400" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="42dp"
android:gravity="center_vertical"
android:orientation="horizontal">
@@ -22,9 +48,10 @@
tools:src="@drawable/ic_launcher_background" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_8"
android:layout_weight="1"
android:orientation="vertical">
<TextView
@@ -50,6 +77,16 @@
android:textColor="@color/gray_500"
tools:text="2분 전" />
</LinearLayout>
<ImageButton
android:id="@+id/btn_feed_community_more"
android:layout_width="42dp"
android:layout_height="42dp"
android:background="@android:color/transparent"
android:contentDescription="@string/read_more"
android:src="@drawable/ic_seemore_vertical"
android:visibility="gone"
tools:visibility="visible" />
</LinearLayout>
<TextView
@@ -125,6 +162,7 @@
</FrameLayout>
<LinearLayout
android:id="@+id/ll_feed_community_reaction"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_marginTop="@dimen/spacing_16"
@@ -132,6 +170,7 @@
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_feed_community_comment"
android:layout_width="18dp"
android:layout_height="18dp"
android:contentDescription="@null"
@@ -148,6 +187,7 @@
tools:text="5" />
<ImageView
android:id="@+id/iv_feed_community_like"
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_marginStart="15dp"