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

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

9d4a459864f822fb5aa7a5741e60e26b?s=128

Keisuke kiuchi

June 26, 2018
Tweet

Transcript

  1. 7.

    /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. 8.

    /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. 14.

    /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. 15.

    /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. 29.

    /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. 30.

    /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