Created
February 11, 2020 16:19
-
-
Save ParkSangGwon/f35421603ed9166de2ab0961447947be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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