feat(main): 라이브룸 딥링크 지연 처리를 추가한다

This commit is contained in:
2026-09-18 14:48:47 +09:00
parent 5e114e18a0
commit 086af8a366
3 changed files with 130 additions and 16 deletions
@@ -55,6 +55,7 @@ import kr.co.vividnext.sodalive.databinding.ActivityMainV2Binding
import kr.co.vividnext.sodalive.explorer.profile.creator_community.write.CreatorCommunityWriteActivity
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.live.LiveViewModel
import kr.co.vividnext.sodalive.live.room.LiveRoomActivity
import kr.co.vividnext.sodalive.live.room.create.LiveRoomCreateActivity
import kr.co.vividnext.sodalive.main.EventPopupDialogFragment
import kr.co.vividnext.sodalive.message.MessageActivity
@@ -107,6 +108,18 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
private var mediaControllerFuture: ListenableFuture<MediaController>? = null
private val handler = Handler(Looper.getMainLooper())
private val showMiniPlayerRunnable = Runnable { initAndVisibleMiniPlayer() }
private val deferredRouteRunnable = Runnable {
if (isFinishing || isDestroyed) return@Runnable
try {
if (!handleAudioNotificationRoute(intent) && isV2AccessAllowed(AccessRequirement.Login)) {
executeDeeplink(intent)
}
} finally {
isDeferredRouteLoading = false
updateRouteLoadingDialog()
}
}
private val audioContentReceiver = AudioContentReceiver()
private var playerStateJob: Job? = null
private var isDeferredRouteLoading = false
@@ -144,13 +157,7 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
trackAppLaunchIfNeeded()
pushTokenUpdate()
handler.postDelayed({
if (!handleAudioNotificationRoute(intent) && isV2AccessAllowed(AccessRequirement.Login)) {
executeDeeplink(intent)
}
isDeferredRouteLoading = false
updateRouteLoadingDialog()
}, 1000)
handler.postDelayed(deferredRouteRunnable, 1000)
if (isV2AccessAllowed(AccessRequirement.Login)) {
updatePidAndGaid()
@@ -177,15 +184,27 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
handler.removeCallbacks(deferredRouteRunnable)
isDeferredRouteLoading = false
updateRouteLoadingDialog()
if (intent.hasExtra(EXTRA_CHAT_FILTER)) {
openChatWithInitialFilter()
return
}
if (!handleAudioNotificationRoute(intent) && isV2AccessAllowed(AccessRequirement.Login)) {
executeDeeplink(intent)
if (handleAudioNotificationRoute(intent) || !isV2AccessAllowed(AccessRequirement.Login)) {
return
}
if (LiveRoomActivity.isForeground && isLiveRoomDeepLink(intent)) {
isDeferredRouteLoading = true
updateRouteLoadingDialog()
handler.postDelayed(deferredRouteRunnable, 1000)
return
}
executeDeeplink(intent)
}
@SuppressLint("UnspecifiedRegisterReceiverFlag")
@@ -212,6 +231,9 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
}
override fun onDestroy() {
handler.removeCallbacks(deferredRouteRunnable)
isDeferredRouteLoading = false
routeLoadingDialog.dismiss()
deInitMiniPlayer()
playerStateJob?.cancel()
super.onDestroy()
@@ -759,19 +781,53 @@ class MainV2Activity : BaseActivity<ActivityMainV2Binding>(ActivityMainV2Binding
}
private fun executeDeeplink(intent: Intent) {
val bundle = intent.getBundleExtra(Constants.EXTRA_DATA) ?: return
val routeBundle = resolveDeepLinkBundle(intent) ?: return
if (executeBundleRoute(routeBundle)) {
clearDeferredDeepLink()
}
}
private fun resolveDeepLinkBundle(intent: Intent): Bundle? {
val bundle = intent.getBundleExtra(Constants.EXTRA_DATA) ?: return null
val deepLinkUrl = bundle.getString("deep_link")
val routeBundle = if (!deepLinkUrl.isNullOrBlank()) {
return if (!deepLinkUrl.isNullOrBlank()) {
Bundle(bundle).apply {
buildBundleFromDeepLinkUrl(deepLinkUrl)?.let { putAll(it) }
}
} else {
bundle
}
}
if (executeBundleRoute(routeBundle)) {
clearDeferredDeepLink()
private fun isLiveRoomDeepLink(intent: Intent): Boolean {
val bundle = resolveDeepLinkBundle(intent) ?: return false
if (isDmChatDeepLink(bundle)) return false
val roomId = bundle.getString("room_id")?.toLongOrNull()
?: bundle.getLong(Constants.EXTRA_ROOM_ID).takeIf { it > 0 }
if (roomId != null && roomId > 0) return true
if (hasDirectNonLiveRoute(bundle)) return false
val deepLinkValueId = bundle.getString("deep_link_sub5")?.toLongOrNull()
return bundle.getString("deep_link_value")?.lowercase(Locale.ROOT) == "live" &&
deepLinkValueId != null && deepLinkValueId > 0
}
private fun hasDirectNonLiveRoute(bundle: Bundle): Boolean {
fun hasPositiveId(stringKey: String, longKey: String): Boolean {
return (
bundle.getString(stringKey)?.toLongOrNull()
?: bundle.getLong(longKey).takeIf { it > 0 }
)?.let { it > 0 } == true
}
return hasPositiveId(Constants.EXTRA_COMMUNITY_POST_ID, Constants.EXTRA_COMMUNITY_POST_ID) ||
hasPositiveId("channel_id", Constants.EXTRA_USER_ID) ||
hasPositiveId("content_id", Constants.EXTRA_AUDIO_CONTENT_ID) ||
hasPositiveId("message_id", Constants.EXTRA_MESSAGE_ID) ||
hasPositiveId(Constants.EXTRA_COMMUNITY_CREATOR_ID, Constants.EXTRA_COMMUNITY_CREATOR_ID) ||
hasPositiveId("audition_id", Constants.EXTRA_AUDITION_ID)
}
private fun buildBundleFromDeepLinkUrl(deepLinkUrl: String): Bundle? {