feat(creator-channel): FanTalk 글 입력 화면을 연결한다

This commit is contained in:
2026-07-08 03:44:44 +09:00
parent b020b8096b
commit 25af312d91
4 changed files with 228 additions and 0 deletions

View File

@@ -114,6 +114,9 @@
<activity android:name=".v2.main.MainV2Activity" />
<activity android:name=".v2.main.content.overview.ContentOverviewActivity" />
<activity android:name=".v2.creator.channel.CreatorChannelActivity" />
<activity
android:name=".v2.creator.channel.fantalk.write.CreatorChannelFanTalkWriteActivity"
android:windowSoftInputMode="stateVisible|adjustResize" />
<activity android:name=".v2.live.onair.HomeOnAirLiveActivity" />
<activity
android:name=".v2.main.chat.dm.DmChatRoomActivity"

View File

@@ -185,6 +185,7 @@ import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelApi
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
import kr.co.vividnext.sodalive.v2.creator.channel.donation.CreatorChannelDonationViewModel
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.CreatorChannelFanTalkViewModel
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.write.CreatorChannelFanTalkWriteViewModel
import kr.co.vividnext.sodalive.v2.creator.channel.live.CreatorChannelLiveViewModel
import kr.co.vividnext.sodalive.v2.creator.channel.series.CreatorChannelSeriesViewModel
import kr.co.vividnext.sodalive.v2.live.onair.HomeOnAirLiveViewModel
@@ -453,6 +454,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
viewModel { CreatorChannelSeriesViewModel(get()) }
viewModel { CreatorChannelCommunityViewModel(get(), get()) }
viewModel { CreatorChannelFanTalkViewModel(get(), get()) }
viewModel { CreatorChannelFanTalkWriteViewModel(get()) }
viewModel { CreatorChannelDonationViewModel(get(), get()) }
viewModel { PushNotificationListViewModel(get()) }
viewModel { CharacterTabViewModel(get()) }

View File

@@ -0,0 +1,146 @@
package kr.co.vividnext.sodalive.v2.creator.channel.fantalk.write
import android.content.Context
import android.content.Intent
import android.text.InputFilter
import android.view.Gravity
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.activity.addCallback
import androidx.core.content.ContextCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.widget.addTextChangedListener
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.base.SodaDialog
import kr.co.vividnext.sodalive.databinding.ActivityCreatorChannelFantalkWriteBinding
import org.koin.androidx.viewmodel.ext.android.viewModel
class CreatorChannelFanTalkWriteActivity : BaseActivity<ActivityCreatorChannelFantalkWriteBinding>(
ActivityCreatorChannelFantalkWriteBinding::inflate
) {
private val viewModel: CreatorChannelFanTalkWriteViewModel by viewModel()
private var creatorId: Long = 0L
override fun setupView() {
creatorId = intent.getLongExtra(EXTRA_CREATOR_ID, 0L)
if (creatorId <= 0L) {
finish()
return
}
setupContentInput()
setupClickListeners()
setupBackHandler()
observeViewModel()
focusContentInput()
}
private fun setupContentInput() = with(binding.etCreatorChannelFantalkWriteContent) {
filters = arrayOf(InputFilter.LengthFilter(CreatorChannelFanTalkWriteViewModel.MAX_CONTENT_LENGTH))
}
private fun setupClickListeners() = with(binding) {
tvCreatorChannelFantalkWriteCancel.setOnClickListener { handleCancel() }
tvCreatorChannelFantalkWriteSend.setOnClickListener { viewModel.submit(creatorId) }
etCreatorChannelFantalkWriteContent.addTextChangedListener { text ->
viewModel.onContentChanged(text?.toString().orEmpty())
}
}
private fun setupBackHandler() {
onBackPressedDispatcher.addCallback(this) {
handleCancel()
}
}
private fun observeViewModel() {
viewModel.isSendEnabledLiveData.observe(this) { isEnabled ->
bindSendEnabled(isEnabled && viewModel.isLoadingLiveData.value != true)
}
viewModel.contentLengthLiveData.observe(this) { length ->
binding.tvCreatorChannelFantalkWriteCount.text = length.toString()
}
viewModel.isLoadingLiveData.observe(this) { isLoading ->
bindLoading(isLoading)
}
viewModel.finishEventLiveData.observe(this) { shouldFinish ->
if (shouldFinish == true) {
setResult(RESULT_OK)
finish()
}
}
viewModel.toastEventLiveData.observe(this) { message ->
message?.let { Toast.makeText(this, it, Toast.LENGTH_SHORT).show() }
}
}
private fun bindSendEnabled(isEnabled: Boolean) = with(binding.tvCreatorChannelFantalkWriteSend) {
this.isEnabled = isEnabled
setTextColor(
ContextCompat.getColor(
context,
if (isEnabled) R.color.white else R.color.gray_500
)
)
setBackgroundResource(
if (isEnabled) {
R.drawable.bg_creator_channel_fantalk_write_send_enabled
} else {
R.drawable.bg_creator_channel_fantalk_write_send_disabled
}
)
}
private fun bindLoading(isLoading: Boolean) = with(binding) {
etCreatorChannelFantalkWriteContent.isEnabled = !isLoading
tvCreatorChannelFantalkWriteSend.text = getString(
if (isLoading) R.string.creator_channel_fantalk_write_sending else R.string.creator_channel_fantalk_write_send
)
bindSendEnabled(!isLoading && viewModel.isSendEnabledLiveData.value == true)
}
private fun focusContentInput() {
binding.etCreatorChannelFantalkWriteContent.post {
binding.etCreatorChannelFantalkWriteContent.requestFocus()
WindowCompat.getInsetsController(window, binding.etCreatorChannelFantalkWriteContent)
.show(WindowInsetsCompat.Type.ime())
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(binding.etCreatorChannelFantalkWriteContent, InputMethodManager.SHOW_IMPLICIT)
}
}
private fun handleCancel() {
if (binding.etCreatorChannelFantalkWriteContent.text?.toString().orEmpty().trim().isEmpty()) {
finish()
} else {
showCancelConfirmDialog()
}
}
private fun showCancelConfirmDialog() {
SodaDialog(
activity = this,
layoutInflater = layoutInflater,
title = getString(R.string.creator_channel_fantalk_write_exit_title),
desc = getString(R.string.creator_channel_fantalk_write_exit_desc),
confirmButtonTitle = getString(R.string.creator_channel_fantalk_write_exit_confirm),
confirmButtonClick = { finish() },
cancelButtonTitle = getString(R.string.creator_channel_fantalk_write_exit_cancel),
cancelButtonClick = {},
descGravity = Gravity.CENTER
).show(screenWidth)
}
companion object {
const val EXTRA_CREATOR_ID: String = "extra_creator_id"
fun newIntent(context: Context, creatorId: Long): Intent {
return Intent(context, CreatorChannelFanTalkWriteActivity::class.java).apply {
putExtra(EXTRA_CREATOR_ID, creatorId)
}
}
}
}