Skip to content

Commit

Permalink
[fix/#841] Fix build issues (due to conflicts)
Browse files Browse the repository at this point in the history
  • Loading branch information
l2hyunwoo committed Sep 18, 2024
1 parent f13250f commit 1e3b4b4
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class HomeActivity : AppCompatActivity() {
tracker.track(type = EventType.CLICK, name = "mypage", properties = mapOf("view_type" to args?.userStatus?.value))
lifecycleScope.launch {
startActivity(
MyPageActivity.getIntent(this@HomeActivity, MyPageActivity.Argument(viewModel.userActiveState.value))
MyPageActivity.getIntent(this@HomeActivity, MyPageActivity.StartArgs(viewModel.userActiveState.value))
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class NavigatorProviderIntent @Inject constructor(

override fun getMyPageActivityIntent(name: String) = MyPageActivity.getIntent(
context,
MyPageActivity.Argument(UserActiveState.valueOf(name))
MyPageActivity.StartArgs(UserActiveState.valueOf(name))
)

override fun getAttendanceActivityIntent() = AttendanceActivity.newInstance(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,70 +45,94 @@ import javax.inject.Inject

@AndroidEntryPoint
class SchemeActivity : AppCompatActivity() {
@Inject
lateinit var dataStore: SoptDataStore
private val args by serializableExtra(Argument("", ""))

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
handleDeepLink()
}
@Inject
lateinit var dataStore: SoptDataStore
private val args by serializableExtra(
Argument(
"",
""
)
)

private fun handleDeepLink() {
val link = args?.link
val linkIntent = when (link.isNullOrBlank()) {
true -> NotificationDetailActivity.getIntent(this, args?.notificationId.orEmpty())
false -> checkLinkExpiration(link)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
handleDeepLink()
}

when (!isTaskRoot) {
true -> startActivity(linkIntent)
false -> TaskStackBuilder.create(this).apply {
if (!isIntentToHome(linkIntent)) {
addNextIntentWithParentStack(
DeepLinkType.getHomeIntent(UserStatus.of(dataStore.userStatus))
)
private fun handleDeepLink() {
val link = args?.link
val linkIntent = when (link.isNullOrBlank()) {
true -> NotificationDetailActivity.getIntent(
this,
args?.notificationId.orEmpty()
)

false -> checkLinkExpiration(link)
}

when (!isTaskRoot) {
true -> startActivity(linkIntent)
false -> TaskStackBuilder.create(this).apply {
if (!isIntentToHome()) {
addNextIntentWithParentStack(
DeepLinkType.getHomeIntent(UserStatus.of(dataStore.userStatus))
)
}
addNextIntent(linkIntent)
}.startActivities()
}
addNextIntent(linkIntent)
}.startActivities()
finish()
}
finish()
}

private fun checkLinkExpiration(link: String): Intent {
return try {
val expiredAt = link.extractQueryParameter("expiredAt")
when (expiredAt.isExpiredDate()) {
true -> DeepLinkType.getHomeIntent(
UserStatus.of(dataStore.userStatus), DeepLinkType.EXPIRED
)
private fun checkLinkExpiration(link: String): Intent {
return try {
val expiredAt = link.extractQueryParameter("expiredAt")
when (expiredAt.isExpiredDate()) {
true -> DeepLinkType.getHomeIntent(
UserStatus.of(dataStore.userStatus),
DeepLinkType.EXPIRED
)

else -> when (link.contains("http://") || link.contains("https://")) {
true -> Intent(
Intent.ACTION_VIEW,
Uri.parse(link)
)

else -> when (link.contains("http://") || link.contains("https://")) {
true -> Intent(Intent.ACTION_VIEW, Uri.parse(link))
false -> DeepLinkType.of(link).getIntent(
this, UserStatus.of(dataStore.userStatus), link
)
false -> DeepLinkType.of(link).getIntent(
this,
UserStatus.of(dataStore.userStatus),
link
)
}
}
} catch (exception: Exception) {
Timber.e(exception)
DeepLinkType.getHomeIntent(
UserStatus.of(dataStore.userStatus),
DeepLinkType.UNKNOWN
)
}
}
} catch (exception: Exception) {
Timber.e(exception)
DeepLinkType.getHomeIntent(
UserStatus.of(dataStore.userStatus), DeepLinkType.UNKNOWN
)
}
}

private fun Intent.isIntentToHome(): Boolean =
intent.component?.className == HomeActivity::class.java.name
}
}
private fun isIntentToHome(): Boolean = intent.component?.className == HomeActivity::class.java.name

data class Argument(
val notificationId: String, val link: String
) : Serializable
data class Argument(
val notificationId: String,
val link: String
) : Serializable

companion object {
@JvmStatic
fun getIntent(context: Context, args: Argument) = Intent(context, SchemeActivity::class.java).putExtra("args", args)
}
companion object {
@JvmStatic
fun getIntent(
context: Context,
args: Argument
) = Intent(
context,
SchemeActivity::class.java
).putExtra(
"args",
args
)
}
}

0 comments on commit 1e3b4b4

Please sign in to comment.