Skip to content

Commit d8cee78

Browse files
safeargsnot working
1 parent ac8a1a3 commit d8cee78

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/src/main/java/com/example/android/navigation/GameWonFragment.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616

1717
package com.example.android.navigation
1818

19+
import android.content.Context
1920
import android.os.Bundle
2021
import android.view.LayoutInflater
2122
import android.view.View
2223
import android.view.ViewGroup
24+
import android.widget.Toast
2325
import androidx.databinding.DataBindingUtil
2426
import androidx.fragment.app.Fragment
2527
import androidx.navigation.findNavController
@@ -33,9 +35,11 @@ class GameWonFragment : Fragment() {
3335
val binding: FragmentGameWonBinding = DataBindingUtil.inflate(
3436
inflater, R.layout.fragment_game_won, container, false)
3537
binding.nextMatchButton.setOnClickListener{view: View ->
36-
view.findNavController().navigate(R.id.action_gameWonFragment_to_gameFragment)
37-
}
38+
view.findNavController().navigate(GameFragmentDirections.actionGameFragmentToGameWonFragment(numQuestions, questionIndex))
3839

40+
}
41+
val args = GameWonFragmentArgs.fromBundle(arguments!!)
42+
Toast.makeText(context, "NumCorrect: ${args.numCorrect}, NumQuestions: ${args.numQuestions}", Toast.LENGTH_LONG).show()
3943
return binding.root
4044
}
4145
}

0 commit comments

Comments
 (0)