Last active
April 4, 2019 08:58
-
-
Save TomohikoSato/0c80441743d5aaddbdb3613cfdc3e316 to your computer and use it in GitHub Desktop.
画面遷移用DSL
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
class HogeFragment: Fragment, Screen { | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
hogeButton.setOnClickListener { navigate(Event.HogeOkClicked()) } | |
} | |
} |
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
class SampleActivity : AppCompatActivity(), Screen { | |
private val route: Route by Extra() | |
private val navigator by lazy { createNavigator(route, supportFragmentManager, R.id.fragment_nav_container, this) } | |
override fun onCreate(savedInstanceState: Bundle?) { | |
/** Activity初期生成の場合のみ[navigate]によって表示するFragmentを指定する。Activity再生成の場合は、Activity生成前に表示していたFragmentがAndroidOSによって再表示されれば良いので、何もしない。 */ | |
if (savedInstanceState == null) navigate(this, Event.OnRootCreated) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment