refactor(creator): 크리에이터 접근 가드를 공통화한다
This commit is contained in:
+13
-92
@@ -46,14 +46,9 @@ import kr.co.vividnext.sodalive.extensions.moneyFormat
|
||||
import kr.co.vividnext.sodalive.live.LiveViewModel
|
||||
import kr.co.vividnext.sodalive.live.room.create.LiveRoomCreateActivity
|
||||
import kr.co.vividnext.sodalive.live.room.donation.LiveRoomDonationDialog
|
||||
import kr.co.vividnext.sodalive.mypage.MyPageViewModel
|
||||
import kr.co.vividnext.sodalive.mypage.auth.Auth
|
||||
import kr.co.vividnext.sodalive.mypage.auth.AuthVerifyRequest
|
||||
import kr.co.vividnext.sodalive.mypage.auth.BootpayResponse
|
||||
import kr.co.vividnext.sodalive.report.UserReportDialog
|
||||
import kr.co.vividnext.sodalive.settings.ContentSettingsActivity
|
||||
import kr.co.vividnext.sodalive.splash.SplashActivity
|
||||
import kr.co.vividnext.sodalive.user.login.LoginActivity
|
||||
import kr.co.vividnext.sodalive.v2.access.AccessRequirement
|
||||
import kr.co.vividnext.sodalive.v2.access.ensureV2Access
|
||||
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
|
||||
@@ -93,7 +88,6 @@ class CreatorChannelActivity :
|
||||
CreatorChannelDonationFragment.Host {
|
||||
|
||||
private val liveViewModel: LiveViewModel by inject()
|
||||
private val myPageViewModel: MyPageViewModel by inject()
|
||||
private val creatorCommunityRepository: CreatorCommunityRepository by inject()
|
||||
private var creatorId: Long = 0L
|
||||
private var currentHeader: CreatorChannelHeaderUiModel? = null
|
||||
@@ -180,8 +174,7 @@ class CreatorChannelActivity :
|
||||
return
|
||||
}
|
||||
|
||||
if (SharedPreferenceManager.token.isBlank()) {
|
||||
showLoginActivity()
|
||||
if (!ensureV2Access(AccessRequirement.Login)) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
@@ -227,7 +220,7 @@ class CreatorChannelActivity :
|
||||
binding.btnCreatorChannelFantalkFixedPlus.setOnClickListener { openFanTalkWrite() }
|
||||
binding.btnCreatorChannelOwnerCta.setOnClickListener { onOwnerCtaClicked() }
|
||||
binding.tvChatButton.setOnClickListener {
|
||||
ensureLoginAndAdultAuth(isAdult = true) {
|
||||
ensureV2Access(AccessRequirement.AdultContent) {
|
||||
currentHeader?.characterId?.let { characterId -> homeActionDelegate?.createChatRoom(characterId) }
|
||||
}
|
||||
}
|
||||
@@ -602,12 +595,9 @@ class CreatorChannelActivity :
|
||||
|
||||
override fun onCreatorChannelCommunityPostClicked(postId: Long) {
|
||||
if (postId <= 0L) return
|
||||
if (SharedPreferenceManager.token.isBlank()) {
|
||||
showLoginActivity()
|
||||
return
|
||||
ensureV2Access(AccessRequirement.Login) {
|
||||
communityDetailLauncher.launch(CreatorChannelCommunityDetailActivity.newIntent(this, postId))
|
||||
}
|
||||
|
||||
communityDetailLauncher.launch(CreatorChannelCommunityDetailActivity.newIntent(this, postId))
|
||||
}
|
||||
|
||||
override fun onCreatorChannelFanTalkContentChanged() {
|
||||
@@ -623,14 +613,11 @@ class CreatorChannelActivity :
|
||||
override fun onCreatorChannelFanTalkItemClicked(item: CreatorChannelFanTalkUiModel) {
|
||||
if (currentHeader?.isOwner != true) return
|
||||
if (creatorId <= 0L || item.fanTalkId <= 0L) return
|
||||
if (SharedPreferenceManager.token.isBlank()) {
|
||||
showLoginActivity()
|
||||
return
|
||||
ensureV2Access(AccessRequirement.Login) {
|
||||
fanTalkDetailLauncher.launch(
|
||||
CreatorChannelFanTalkDetailActivity.newIntent(this, creatorId, item.toFanTalkDetailPayload())
|
||||
)
|
||||
}
|
||||
|
||||
fanTalkDetailLauncher.launch(
|
||||
CreatorChannelFanTalkDetailActivity.newIntent(this, creatorId, item.toFanTalkDetailPayload())
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreatorChannelFanTalkFloatingButtonVisibilityChanged(isVisible: Boolean) {
|
||||
@@ -917,11 +904,9 @@ class CreatorChannelActivity :
|
||||
|
||||
private fun openFanTalkWrite() {
|
||||
if (creatorId <= 0L) return
|
||||
if (SharedPreferenceManager.token.isBlank()) {
|
||||
showLoginActivity()
|
||||
return
|
||||
ensureV2Access(AccessRequirement.Login) {
|
||||
fanTalkWriteLauncher.launch(CreatorChannelFanTalkWriteActivity.newIntent(this, creatorId))
|
||||
}
|
||||
fanTalkWriteLauncher.launch(CreatorChannelFanTalkWriteActivity.newIntent(this, creatorId))
|
||||
}
|
||||
|
||||
private fun onOwnerFabCommunityClicked() {
|
||||
@@ -974,7 +959,7 @@ class CreatorChannelActivity :
|
||||
}
|
||||
|
||||
override fun onCreatorChannelCurrentLiveClicked(live: CreatorChannelLiveResponse) {
|
||||
ensureLoginAndAdultAuth(isAdult = live.isAdult) {
|
||||
ensureV2Access(AccessRequirement.forAdultContent(live.isAdult)) {
|
||||
liveCoordinator.enterLiveRoom(live.liveId)
|
||||
}
|
||||
}
|
||||
@@ -1033,70 +1018,6 @@ class CreatorChannelActivity :
|
||||
position == CreatorChannelTab.Donation.ordinal
|
||||
}
|
||||
|
||||
private fun ensureLoginAndAdultAuth(isAdult: Boolean, onAuthed: () -> Unit) {
|
||||
if (SharedPreferenceManager.token.isBlank()) {
|
||||
showLoginActivity()
|
||||
return
|
||||
}
|
||||
|
||||
if (isAdult) {
|
||||
val isKoreanCountry = SharedPreferenceManager.countryCode.ifBlank { "KR" } == "KR"
|
||||
if (isKoreanCountry && !SharedPreferenceManager.isAuth) {
|
||||
V2ModalDialog(
|
||||
activity = this,
|
||||
layoutInflater = layoutInflater,
|
||||
title = getString(R.string.auth_title),
|
||||
desc = getString(R.string.auth_desc_live),
|
||||
confirmButtonTitle = getString(R.string.auth_go),
|
||||
confirmButtonClick = { startAuthFlow() },
|
||||
cancelButtonTitle = getString(R.string.cancel),
|
||||
cancelButtonClick = {}
|
||||
).show(screenWidth)
|
||||
return
|
||||
}
|
||||
|
||||
if (!SharedPreferenceManager.isAdultContentVisible) {
|
||||
startActivity(
|
||||
Intent(this, ContentSettingsActivity::class.java).apply {
|
||||
putExtra(Constants.EXTRA_SHOW_SENSITIVE_CONTENT_GUIDE, true)
|
||||
}
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
onAuthed()
|
||||
}
|
||||
|
||||
private fun showLoginActivity() {
|
||||
if (SharedPreferenceManager.token.isBlank()) {
|
||||
startActivity(
|
||||
Intent(this, LoginActivity::class.java).apply {
|
||||
putExtra(Constants.EXTRA_DATA, intent.extras)
|
||||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startAuthFlow() {
|
||||
Auth.auth(this, this) { json ->
|
||||
val bootpayResponse = Gson().fromJson(json, BootpayResponse::class.java)
|
||||
val request = AuthVerifyRequest(receiptId = bootpayResponse.data.receiptId)
|
||||
runOnUiThread {
|
||||
myPageViewModel.authVerify(request) {
|
||||
startActivity(
|
||||
Intent(this, SplashActivity::class.java).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateViewPagerHeight(afterHeightUpdated: (() -> Unit)? = null) {
|
||||
updateCreatorChannelTabViewportHeight()
|
||||
binding.viewPager.post {
|
||||
|
||||
Reference in New Issue
Block a user