‫Hello, my friends.
‫In the previous videos, we have created the layouts.
‫Now we are going to add the functionality for our app and handle the click events from the user.
‫So first of all, I will create a new class Java class here.
‫I will limit as bottom dialog.
‫This class will act as a template for creating and displaying the data as a dialog under the at the
‫bottom of the screen.
‫So the user clicks on the image and take an image of the QR code and the result will be displayed in
‫this dialog.
‫So this is a template and I will link it for the button dialog layout that we have created in the previous
‫video.
‫So we're here, we have an image view.
‫Text, the view and other to text.
‫So we have three text views and one image view.
‫For that I will extend this extends from the bottom
‫cheat dialog frame.
‫On the fragment.
‫So here I will start initializing the widgets.
‫We have three text views.
‫First is title.
‫The second is Link, and the third is button.
‫Visit
‫alt plus enter to import the text view and private image view.
‫Close.
‫And a private string here.
‫String fetch URL plus enter to import the package and the class of that image view.
‫And here we start by adding the anchor and overriding the methods of the button.
‫Button sheet dialog fragment.
‫Since it is a fragment.
‫So it follows the lifecycle of a fragment.
‫So despite using the on create, we are a method.
‫We are going to use the create a view here on create view.
‫Click enter to override this method or you can search for it plus and insert and override methods.
‫And here we start searching for on create that dialog view or that.
‫So this is the methods that you have on create view took into parameters the inflator, which is a layout
‫inflator and we have talked about it many times in that in the advanced views.
‫The View Group and the Bond.
‫So what we what we need here is to remove the return, and I will return my custom view.
‫So I will create a new view equal to inflator, dot inflate, r dot layout, dot button dialog.
‫So I am linking this button dialog layout with my class.
‫I will add the container and then I will use touch to root as false title.
‫Now let's initialize this widgets title equal to view dot find view by ID are the ID dot text title
‫and link equal to if you don't find view by ID are the ID dot text link.
‫Button visit equal to a view dot find the view by ID or id dot visit
‫and I will use the close at the image view view dot fine view by id are the ID dot close.
‫So let's add the functionality to that button.
‫But first let me add the title here dot set text because I miss always the text.
‫So button dot visit dot set on click listener knew of you on click listen and the on click method is
‫override intent I equal to new intent.
‫What we are going to do.
‫We are going to tell Android, the studio and the application, the Android system also that when the
‫user click on the button visit it will took him to that data that it stored inside this QR code.
‫For that I will use Android dot ten dot action dot view
‫I dot set data to you are I dot pass what we are going to pass we are going to pass the fetch it URL
‫which is the text and the string that we have created before.
‫Now start activity at the intent.
‫This is what we do here inside our start or button visit.
‫And the button close here we put set on click listener.
‫New View on Click Listener.
‫And we override that dismiss method on Click Method and we call the method dismiss.
‫So what we are doing actually here is like creating our custom dialog.
‫So this class, this class is making the functionality for this layout in order to display the text.
‫I love the user to the user to click on the events like dismiss here the close button and the button
‫visit.
‫So it will took the user to the link that it may be stored inside the QR code.
‫So again guys, please pay attention with me.
‫There are three possibilities of the text and an image.
‫So any QR code, it will contain an image, it may contain a title, it may contain a text link like
‫display at the description and a visit link.
‫So if you have a QR code with a visit link, it will be displayed here in the visit link, text view
‫and this, this button visit.
‫It will allow you to go and like call this you are visiting your this you are this is the purpose of
‫this class return view here
‫and here we are making the public void fetch you are l fetch you are l.
‫This is the method that we have to call.
‫Fetch.
‫You are l.
‫This is the string u r l.
‫And here we are going.
‫To create that executable, serve, execute service,
‫then we will use the hands.
‫So first of all, execute the service.
‫Execute or service equal to execute or.
‫Scooters dot new single thread execute why we are using this.
‫As I told you in in the previous videos that whenever you deal with network, you need to add libraries,
‫you need to use other services that do the job in the background so you can't make your connection or
‫download a file or whatever you want to make or fetch the data from internet or network or databases
‫in the main thread.
‫So always use background services like executables handlers enables other other managers, time manager
‫like that, service manager, job manager, work manager, time managers and others in the Android.
‫So we took a we we have talked about this in many videos before, but please pay attention for me like
‫while I am coding this your at this method, pay attention and keep your eyes with me new handler here
‫and I will use the loop also it is getting the main loop and this is what we have talked about in the
‫in the previous minute.
‫This is how we use these classes to do the job by fetching the URL in the background.
‫Execute.
‫The DOT execute.
‫You are honorable.
‫And this is override method run.
‫We are going to fetch your EL equal.
‫You are an OC.
‫This is the fetch.
‫You are El.
‫Fetch.
‫You are.
‫This is the string that we have created.
‫I'm initializing it with the string here.
‫So that now we are good here and we have finished the pattern dialog that extends from the bottom sheet
‫dialogue fragment and acts as a template for our dialogues that will be displayed when the user scan
‫for.