‫Hello, my friends.
‫In this video we will learn how to send data between two destinations so the user will enter his name
‫in in this field, in this edit text, click on submit and then will be directed to the second fragment
‫containing the data.
‫So we've learned before how to do this using the intents.
‫In this video we'll learn how to do this.
‫This passage of data between two destinations using the navigation and using the bundle.
‫So I will go to the home fragment and here I will inside the handle click event, I will create.
‫If Val called bundle, it's of type bundle equal to bundle of.
‫So in order to pass data, we should pass them in form of a bond.
‫Here we put the name of the bundle, the pair and the value of it.
‫And after that to operator.
‫So please concentrate.
‫Name.
‫To binding dot edit text dot.
‫Text dot to string.
‫Here I'm creating a variable called name the key of this.
‫A variable or this bundle is called name two is used to create a tuple of pair.
‫From this and that from this and that.
‫I'm creating a tuple.
‫A key value from this and that that is getting the edit text.
‫Content and input so the user will enter the the name in the edit text.
‫So I'm getting it as a value, assigning it to a key called name and using the operator to will make
‫a this will be useful for creating map literals with less noise.
‫So I'm making a map a key value pair key value.
‫Okay.
‫Give me the key.
‫I will give you the value.
‫In order to pass this bundle, I need to get it and pass it inside the second parameter here in the
‫nav controller navigate function.
‫So I need to pass the bundle.
‫I am passing it correctly.
‫Here I will make a very simple check for if the user will will not enter any text.
‫It will not.
‫Direct him to the second fragment.
‫It will display an error toast message.
‫So text utils dot is empty.
‫If it is an empty, I will check for this binding dot.
‫Edit text dot.
‫Text dot to string.
‫I'm checking if it is an empty go and.
‫It is not empty, then I will do and execute this code.
‫Otherwise it will display a toast message, an error message telling him to insert a name activity.
‫Enter your name.
‫And the toast.
‫Dot length.
‫Long dot show.
‫Okay, so I am sending the data to the destination.
‫How to receive the data in the destination.
‫I will open the second fragment here.
‫I will create an input of type input variable.
‫Var.
‫Arguments.
‫This is the not null operator.
‫Get string.
‫It will not be a null.
‫Get string from where?
‫From the key name.
‫So give me the key.
‫Here is the key.
‫I will give you the value that it is entered by the user.
‫So var input arguments here.
‫Alt+ enter replace with required arguments or arguments.
‫And here.
‫I will create bundle binding dot text.
‫Of you.
‫Second fragment text equal to input dot two string.
‫You can replace it with require arguments, but now I can use it.
‫So it's not an error, a big error that will stop me from running the app.
‫Let me create a clean the project, create a rebuild project, and I will click run the application.
‫Then we run the project.
‫And here we go.
‫This is our application.
‫Please enter your name.
‫I will.
‫Jack.
‫Submit.
‫And here we go.
‫It's transitioning us to a new fragment.
‫The second fragment with a data with the bundle that contains a string with key name and the value check
‫that it's entered by the user.
‫So congratulations, guys.
‫We're creating.
‫We've created this amazing application that helps us to understand the navigation architecture component.
‫Now let's move to to make a complex application using navigation, save args, Mvvm room data binding
‫and Viewmodels.
‫So are you ready to make a complex application?
‫Yes, I.