Skip to content

Instantly share code, notes, and snippets.

@ParkSangGwon
Created February 11, 2020 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ParkSangGwon/f35421603ed9166de2ab0961447947be to your computer and use it in GitHub Desktop.
Save ParkSangGwon/f35421603ed9166de2ab0961447947be to your computer and use it in GitHub Desktop.
enum class DeepLinkInfo(@StringRes val hostStringResId: Int) {
MAIN(R.string.scheme_host_main) {
override fun getIntent(context: Context, deepLinkUri: Uri) =
getMainIntent(context)
},
DETAIL(R.string.scheme_host_detail) {
override fun getIntent(context: Context, deepLinkUri: Uri) =
DetailActivity.getIntent(context, deepLinkUri)
},
COUNTRY(R.string.scheme_host_country) {
override fun getIntent(context: Context, deepLinkUri: Uri) =
CountryActivity.getIntent(context, deepLinkUri)
};
private val host: String = TedApplication.instance.getString(hostStringResId)
abstract fun getIntent(context: Context, deepLinkUri: Uri): Intent
companion object {
fun getMainIntent(context: Context) = MainActivity.getIntent(context)
operator fun invoke(uri: Uri): DeepLinkInfo =
values().find { it.host == uri.host } ?: run {
logd("등록되지 않은 딥링크")
logd("Not registered deep link host")
MAIN
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment