Last active
July 11, 2019 11:32
-
-
Save mataku/83334303f234fbe9047aa74682c8ed2b 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
// startActivity(ActivityList.Main.toIntent()) で遷移 | |
object ActivityList { | |
const val BASE_PACKAGE_NAME = "com.mataku.amazing" | |
object Main : MatakuActivity { | |
override val className: String | |
get() = "$BASE_PACKAGE_NAME.app.ui.activity.MainActivity" | |
} | |
interface MatakuActivity { | |
val className: String | |
} | |
fun packageName(debuggable: Boolean): String { | |
return if (debuggable) { | |
"$BASE_PACKAGE_NAME.app.dev" | |
} else { | |
"$BASE_PACKAGE_NAME.app" | |
} | |
} | |
} | |
fun ActivityList.MatakuActivity.toIntent(): Intent { | |
return Intent(Intent.ACTION_VIEW).setClassName( | |
ActivityList.packageName(BuildConfig.DEBUG), | |
this.className | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment