Upgrade to Pro — share decks privately, control downloads, hide ads and more …

NavigationのNavOptions周りを覗いてみよう

 NavigationのNavOptions周りを覗いてみよう

Keisuke kiuchi

June 26, 2018
Tweet

More Decks by Keisuke kiuchi

Other Decks in Programming

Transcript

  1. /BWJHBUJPOͷ࣮૷!'SBHNFOU view?.findViewById<Button>(R.id.button2_to_activity2)?.setOnClickListener { val intent = Intent(context, Main2Activity::class.java) startActivity(intent) }

    #FGPSF view?.findViewById<Button>(R.id.button2_to_activity2)?.setOnClickListener { view?.let { Navigation.findNavController(it). navigate(R.id.action_mainFragment_to_main2Activity) } } "GUFS
  2. /BWJHBUJPOͷ࣮૷!'SBHNFOU view?.findViewById<Button>(R.id.button2_to_activity2)?.setOnClickListener { val intent = Intent(context, Main2Activity::class.java) intent.flags =

    Intent.FLAG_ACTIVITY_SINGLE_TOP startActivity(intent) } #FGPSF "GUFS view?.findViewById<Button>(R.id.button2_to_activity2)?.setOnClickListener { val options = NavOptions.Builder().setLaunchSingleTop(true).build() view?.let { Navigation.findNavController(it).navigate(R.id.action_mainFragment_to_main2Activit y, null, options) } }
  3. /BWJHBUJPOͷ࣮૷!'SBHNFOU view?.findViewById<Button>(R.id.button2_to_activity2)?.setOnClickListener { val intent = Intent(context, Main2Activity::class.java) intent.flags =

    Intent.FLAG_ACTIVITY_SINGLE_TOP startActivity(intent) } #FGPSF "GUFS view?.findViewById<Button>(R.id.button2_to_activity2)?.setOnClickListener { val options = NavOptions.Builder().setLaunchSingleTop(true).build() view?.let { Navigation.findNavController(it).navigate(R.id.action_mainFragment_to_main2Activit y, null, options) } }
  4. /BW0QUJPOT
 TFU-BVODI4JOHMF5PQ NavOptions.Builder().setLaunchSingleTop(true) /** * Launch a navigation target as

    single-top if you are making a lateral navigation * between instances of the same target (e.g. detail pages about similar data items) * that should not preserve history. * * @param singleTop true to launch as single-top */ @NonNull public Builder setLaunchSingleTop(boolean singleTop) { if (singleTop) { mLaunchMode |= LAUNCH_SINGLE_TOP; } else { mLaunchMode &= ~LAUNCH_SINGLE_TOP; } return this; } /BW0QUJPOTKBWB
  5. /BWJHBUJPOͷ࣮૷!'SBHNFOU view?.findViewById<Button>(R.id.button2_to_activity2)?.setOnClickListener { val intent = Intent(context, Main2Activity::class.java) startActivity(intent) activity!!.overridePendingTransition(R.anim.abc_fade_in,

    R.anim.abc_fade_out) } #FGPSF "GUFS view?.findViewById<Button>(R.id.button2_to_activity2)?.setOnClickListener { val options = NavOptions.Builder() .setEnterAnim(R.anim.abc_fade_in) .setExitAnim(R.anim.abc_fade_out) .build() Navigation.findNavController(it).navigate(R.id.action_mainFragment_to_main2Activity, null, options) }
  6. /BW0QUJPOT
 TFU-BVODI4JOHMF5PQ NavOptions.Builder().setEnterAnim(R.anim.abc_fade_in) .setExitAnim(R.anim.abc_fade_out).build() @NonNull public Builder setEnterAnim(@AnimRes @AnimatorRes int

    enterAnim) { mEnterAnim = enterAnim; return this; } @NonNull public Builder setExitAnim(@AnimRes @AnimatorRes int exitAnim) { mExitAnim = exitAnim; return this; } /BW0QUJPOTKBWB