‫In the previous video we created this layout.
‫Now open add journal activity and let's add the codes to connect to the firebase and to get the authentication
‫in order to upload the post into the storage.
‫Since I used the layout here.
‫Layout tag.
‫I'm going to create the object the data binding object so late initiate var.
‫Binding.
‫Of Jonah Journal.
‫Add or activity.
‫Journal.
‫A journal binding.
‫Now let's remove this set content view and let's use binding equal to.
‫Data binding util.
‫Thought setcontentview.
‫Thus or dot layout dot.
‫Adjourn.
‫Now I need a username and ID for the current user.
‫So here I am going to create the credentials.
‫Var.
‫String of current user id is type string equal to.
‫Empty and var current user name type string equal this empty.
‫String.
‫Now let's make the section for Firebase.
‫The authentication.
‫So I will create var or let initiate.
‫Var firebase auth.
‫Okay.
‫I would name it as oth.
‫And.
‫Late in shade.
‫Var.
‫Firebase user.
‫Now.
‫Also, I need to make a connection to fire Firestore.
‫So here.
‫This is the Firebase Firestore.
‫Firebase storage.
‫I will create var.
‫Var db equal.
‫Or if it's type Firebase Firestore.
‫Equal to Firestore.
‫Dot get instance and here I will create a late initiate var storage reference.
‫Of type storage reference and I will create the collection reference.
‫So you and you you I think you remember the collection and the document.
‫We said that the collection and the documents are the main things and the main storage of the Firestore
‫and the main terms.
‫So the data is included inside documents.
‫Documents are included inside the collection.
‫So a collection is a collection or a collection is a.
‫Collection of documents.
‫For that I will create var collection reference.
‫As of type correct collection reference.
‫Or I can create like this.
‫DB dot collection.
‫And here I will specify the name and the collection path, which is Jordan.
‫Private or private image.
‫Uri.
‫This is a var image.
‫Uri.
‫Lots of type.
‫Your I equal to two.
‫Or I will make it like late in sheet.
‫And here we go.
‫These are the things that we're going to use and instantiate through this activity.
‫Now let's open the Oncreate method and start initializing things.
‫First of all, the storage reference equal to Firebase storage dot get instance, dot get reference.
‫And here I will start with OAuth equal to Firebase auth dot OAuth.
‫And I can use get instance.
‫Now let's set the progress bar visible.
‫So binding dot apply because I'm going to use binding in in many in many ways.
‫So the first way is the progress bar.
‫Post progress bar dot set visibility.
‫Equal to visibility.
‫Thought.
‫What have you.
‫Thought invisible.
‫Now.
‫We need to get and display the current user.
‫For that I will use f journal user dot get instance doesn't equal to null.
‫So there is a valid user logged logged in.
‫Current user ID, which is the text to view.
‫Equal to journal.
‫The user or I can set it like this.
‫Current user ID.
‫This is the string.
‫Okay.
‫I will set the string two and get it from the journal user dot instance.
‫You see the instance, This is the Singleton class that we've done before.
‫I need from the Singleton class.
‫The user ID?
‫And I need to change it to a string.
‫And of course I will use non-null non-null asserted operator.
‫In the same way I will get the current user name.
‫Equal journal user dot instance dot get user name user name.
‫Now, in order to set the text view, I will use current.
‫Text The View.
‫Which is the post.
‫User name text view dot text equal to.
‫The current user name.
‫Okay.
‫This is if we need to check if the user.
‫And get the current user is logged in and valid.
‫I will get its name and display it inside this text view.
‫Now we need to get the the buttons here so when the user click on save and when the user click on the
‫image view.
‫So we will go to the next video and handle the click events on these two widgets.