콘텐츠 댓글 리스트
- 댓글이 없을 때 유료 콘텐츠를 구매한 사람이 비밀댓글을 등록할 수 있는 기능 추가
This commit is contained in:
parent
6640130ef9
commit
4961727237
|
@ -14,7 +14,8 @@ import kr.co.vividnext.sodalive.databinding.DialogAudioContentCommentBinding
|
||||||
|
|
||||||
class AudioContentCommentFragment(
|
class AudioContentCommentFragment(
|
||||||
private val creatorId: Long,
|
private val creatorId: Long,
|
||||||
private val audioContentId: Long
|
private val audioContentId: Long,
|
||||||
|
private val isShowSecret: Boolean
|
||||||
) : BottomSheetDialogFragment() {
|
) : BottomSheetDialogFragment() {
|
||||||
|
|
||||||
private lateinit var binding: DialogAudioContentCommentBinding
|
private lateinit var binding: DialogAudioContentCommentBinding
|
||||||
|
@ -50,7 +51,8 @@ class AudioContentCommentFragment(
|
||||||
val commentListFragmentTag = "COMMENT_LIST_FRAGMENT"
|
val commentListFragmentTag = "COMMENT_LIST_FRAGMENT"
|
||||||
val commentListFragment = AudioContentCommentListFragment.newInstance(
|
val commentListFragment = AudioContentCommentListFragment.newInstance(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
audioContentId = audioContentId
|
audioContentId = audioContentId,
|
||||||
|
isShowSecret = isShowSecret
|
||||||
)
|
)
|
||||||
val fragmentTransaction = childFragmentManager.beginTransaction()
|
val fragmentTransaction = childFragmentManager.beginTransaction()
|
||||||
fragmentTransaction.add(R.id.fl_container, commentListFragment, commentListFragmentTag)
|
fragmentTransaction.add(R.id.fl_container, commentListFragment, commentListFragmentTag)
|
||||||
|
|
|
@ -35,6 +35,7 @@ class AudioContentCommentListFragment : BaseFragment<FragmentAudioContentComment
|
||||||
|
|
||||||
private var creatorId: Long = 0
|
private var creatorId: Long = 0
|
||||||
private var audioContentId: Long = 0
|
private var audioContentId: Long = 0
|
||||||
|
private var isShowSecret: Boolean = false
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
|
@ -43,6 +44,7 @@ class AudioContentCommentListFragment : BaseFragment<FragmentAudioContentComment
|
||||||
): View? {
|
): View? {
|
||||||
creatorId = arguments?.getLong(Constants.EXTRA_AUDIO_CONTENT_CREATOR_ID) ?: 0
|
creatorId = arguments?.getLong(Constants.EXTRA_AUDIO_CONTENT_CREATOR_ID) ?: 0
|
||||||
audioContentId = arguments?.getLong(Constants.EXTRA_AUDIO_CONTENT_ID) ?: 0
|
audioContentId = arguments?.getLong(Constants.EXTRA_AUDIO_CONTENT_ID) ?: 0
|
||||||
|
isShowSecret = arguments?.getBoolean(Constants.EXTRA_IS_SHOW_SECRET) ?: false
|
||||||
return super.onCreateView(inflater, container, savedInstanceState)
|
return super.onCreateView(inflater, container, savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,8 +75,20 @@ class AudioContentCommentListFragment : BaseFragment<FragmentAudioContentComment
|
||||||
binding.ivCommentSend.setOnClickListener {
|
binding.ivCommentSend.setOnClickListener {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
val comment = binding.etComment.text.toString()
|
val comment = binding.etComment.text.toString()
|
||||||
|
val isSecret = binding.tvSecret.isSelected
|
||||||
|
viewModel.registerComment(audioContentId, comment, isSecret)
|
||||||
|
|
||||||
binding.etComment.setText("")
|
binding.etComment.setText("")
|
||||||
viewModel.registerComment(audioContentId, comment)
|
binding.tvSecret.isSelected = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isShowSecret) {
|
||||||
|
binding.tvSecret.visibility = View.VISIBLE
|
||||||
|
binding.tvSecret.setOnClickListener {
|
||||||
|
binding.tvSecret.isSelected = !binding.tvSecret.isSelected
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
binding.tvSecret.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter = AudioContentCommentAdapter(
|
adapter = AudioContentCommentAdapter(
|
||||||
|
@ -202,10 +216,15 @@ class AudioContentCommentListFragment : BaseFragment<FragmentAudioContentComment
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(creatorId: Long, audioContentId: Long): AudioContentCommentListFragment {
|
fun newInstance(
|
||||||
|
creatorId: Long,
|
||||||
|
audioContentId: Long,
|
||||||
|
isShowSecret: Boolean
|
||||||
|
): AudioContentCommentListFragment {
|
||||||
val args = Bundle()
|
val args = Bundle()
|
||||||
args.putLong(Constants.EXTRA_AUDIO_CONTENT_CREATOR_ID, creatorId)
|
args.putLong(Constants.EXTRA_AUDIO_CONTENT_CREATOR_ID, creatorId)
|
||||||
args.putLong(Constants.EXTRA_AUDIO_CONTENT_ID, audioContentId)
|
args.putLong(Constants.EXTRA_AUDIO_CONTENT_ID, audioContentId)
|
||||||
|
args.putBoolean(Constants.EXTRA_IS_SHOW_SECRET, isShowSecret)
|
||||||
|
|
||||||
val fragment = AudioContentCommentListFragment()
|
val fragment = AudioContentCommentListFragment()
|
||||||
fragment.arguments = args
|
fragment.arguments = args
|
||||||
|
|
|
@ -84,7 +84,7 @@ class AudioContentCommentListViewModel(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerComment(contentId: Long, comment: String) {
|
fun registerComment(contentId: Long, comment: String, isSecret: Boolean) {
|
||||||
if (!_isLoading.value!!) {
|
if (!_isLoading.value!!) {
|
||||||
_isLoading.value = true
|
_isLoading.value = true
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ class AudioContentCommentListViewModel(
|
||||||
repository.registerComment(
|
repository.registerComment(
|
||||||
contentId = contentId,
|
contentId = contentId,
|
||||||
comment = comment,
|
comment = comment,
|
||||||
|
isSecret = isSecret,
|
||||||
token = "Bearer ${SharedPreferenceManager.token}"
|
token = "Bearer ${SharedPreferenceManager.token}"
|
||||||
)
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
|
|
@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.audio_content.detail
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.app.Service
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -9,8 +10,11 @@ import android.content.IntentFilter
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
@ -65,6 +69,7 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||||
private val audioContentReceiver = AudioContentReceiver()
|
private val audioContentReceiver = AudioContentReceiver()
|
||||||
|
|
||||||
private var creatorId: Long = 0
|
private var creatorId: Long = 0
|
||||||
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
|
|
||||||
private var refresh = false
|
private var refresh = false
|
||||||
private var title = ""
|
private var title = ""
|
||||||
|
@ -72,6 +77,7 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||||
private lateinit var activityResultLauncher: ActivityResultLauncher<Intent>
|
private lateinit var activityResultLauncher: ActivityResultLauncher<Intent>
|
||||||
private lateinit var audioContent: GetAudioContentDetailResponse
|
private lateinit var audioContent: GetAudioContentDetailResponse
|
||||||
private lateinit var orderType: OrderType
|
private lateinit var orderType: OrderType
|
||||||
|
private lateinit var imm: InputMethodManager
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onNewIntent(intent: Intent) {
|
override fun onNewIntent(intent: Intent) {
|
||||||
|
@ -92,6 +98,8 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||||
audioContentId = intent.getLongExtra(Constants.EXTRA_AUDIO_CONTENT_ID, 0)
|
audioContentId = intent.getLongExtra(Constants.EXTRA_AUDIO_CONTENT_ID, 0)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
imm = getSystemService(Service.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
|
||||||
if (audioContentId <= 0) {
|
if (audioContentId <= 0) {
|
||||||
Toast.makeText(applicationContext, "잘못된 요청입니다.", Toast.LENGTH_LONG).show()
|
Toast.makeText(applicationContext, "잘못된 요청입니다.", Toast.LENGTH_LONG).show()
|
||||||
finish()
|
finish()
|
||||||
|
@ -471,7 +479,11 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||||
binding.rlInputComment.visibility = View.GONE
|
binding.rlInputComment.visibility = View.GONE
|
||||||
binding.tvSecret.visibility = View.GONE
|
binding.tvSecret.visibility = View.GONE
|
||||||
|
|
||||||
binding.llComment.setOnClickListener { showCommentBottomSheetDialog() }
|
binding.llComment.setOnClickListener {
|
||||||
|
showCommentBottomSheetDialog(
|
||||||
|
isShowSecret = response.existOrdered
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.tvCommentText.visibility = View.GONE
|
binding.tvCommentText.visibility = View.GONE
|
||||||
binding.rlInputComment.visibility = View.VISIBLE
|
binding.rlInputComment.visibility = View.VISIBLE
|
||||||
|
@ -482,6 +494,7 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.ivCommentSend.setOnClickListener {
|
binding.ivCommentSend.setOnClickListener {
|
||||||
|
hideKeyboard()
|
||||||
val comment = binding.etComment.text.toString()
|
val comment = binding.etComment.text.toString()
|
||||||
val isSecret = binding.tvSecret.isSelected
|
val isSecret = binding.tvSecret.isSelected
|
||||||
viewModel.registerComment(audioContentId, comment, isSecret)
|
viewModel.registerComment(audioContentId, comment, isSecret)
|
||||||
|
@ -507,10 +520,11 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showCommentBottomSheetDialog() {
|
private fun showCommentBottomSheetDialog(isShowSecret: Boolean) {
|
||||||
val dialog = AudioContentCommentFragment(
|
val dialog = AudioContentCommentFragment(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
audioContentId = audioContentId
|
audioContentId = audioContentId,
|
||||||
|
isShowSecret = isShowSecret
|
||||||
)
|
)
|
||||||
dialog.show(
|
dialog.show(
|
||||||
supportFragmentManager,
|
supportFragmentManager,
|
||||||
|
@ -932,6 +946,15 @@ class AudioContentDetailActivity : BaseActivity<ActivityAudioContentDetailBindin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun hideKeyboard() {
|
||||||
|
handler.postDelayed({
|
||||||
|
imm.hideSoftInputFromWindow(
|
||||||
|
window.decorView.applicationWindowToken,
|
||||||
|
InputMethodManager.HIDE_NOT_ALWAYS
|
||||||
|
)
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
|
||||||
inner class AudioContentReceiver : BroadcastReceiver() {
|
inner class AudioContentReceiver : BroadcastReceiver() {
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
|
|
@ -59,6 +59,7 @@ object Constants {
|
||||||
const val EXTRA_AUDIO_CONTENT_NEXT_ACTION = "audio_content_next_action"
|
const val EXTRA_AUDIO_CONTENT_NEXT_ACTION = "audio_content_next_action"
|
||||||
const val EXTRA_AUDIO_CONTENT_ALERT_PREVIEW = "audio_content_alert_preview"
|
const val EXTRA_AUDIO_CONTENT_ALERT_PREVIEW = "audio_content_alert_preview"
|
||||||
const val EXTRA_AUDIO_CONTENT_COVER_IMAGE_URL = "audio_content_cover_image_url"
|
const val EXTRA_AUDIO_CONTENT_COVER_IMAGE_URL = "audio_content_cover_image_url"
|
||||||
|
const val EXTRA_IS_SHOW_SECRET = "extra_is_show_secret"
|
||||||
|
|
||||||
const val LIVE_SERVICE_NOTIFICATION_ID: Int = 2
|
const val LIVE_SERVICE_NOTIFICATION_ID: Int = 2
|
||||||
const val ACTION_AUDIO_CONTENT_RECEIVER = "soda_live_action_content_receiver"
|
const val ACTION_AUDIO_CONTENT_RECEIVER = "soda_live_action_content_receiver"
|
||||||
|
|
|
@ -63,11 +63,29 @@
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:background="@color/color_595959" />
|
android:background="@color/color_595959" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_secret"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/divider"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginTop="13.3dp"
|
||||||
|
android:button="@null"
|
||||||
|
android:drawablePadding="8dp"
|
||||||
|
android:fontFamily="@font/gmarket_sans_medium"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginHorizontal="13.3dp"
|
||||||
|
android:text="비밀댓글"
|
||||||
|
android:textColor="@color/color_eeeeee"
|
||||||
|
android:textSize="13.3sp"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:drawableStartCompat="@drawable/ic_select" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ll_comment_input"
|
android:id="@+id/ll_comment_input"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/divider"
|
android:layout_below="@+id/tv_secret"
|
||||||
android:background="@drawable/bg_top_round_corner_8_222222"
|
android:background="@drawable/bg_top_round_corner_8_222222"
|
||||||
android:elevation="13.3dp"
|
android:elevation="13.3dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
|
Loading…
Reference in New Issue