‫Hello, my friends.
‫Our error is in getting the journal user.
‫So always in this app we are getting a null user, the user ID and the user name.
‫Now I will skip using the journal user and I will use the already made, uh, current user and authentication
‫users in firebase package.
‫So for that I will open the main activity and I will search for any time I use the the user journal
‫user.
‫You can see here that I'm using authentication dot current user.
‫I will remove it and now I will add.
‫So please guys, fix these errors because they are very important and they are preventing us from making
‫the good app to work.
‫I will create a new journal user.
‫And I am making getting the instance.
‫Journal user instance.
‫And of course it's not equal to not asserted.
‫Okay.
‫Journal.
‫I am setting now the current user ID.
‫ID equal to authentication.
‫I am telling that this journal user, which is the instance that we created in in our application and
‫companion object, is a singleton object.
‫We will use authentication dot current user and dot display uid.
‫Okay.
‫I'm getting the user ID.
‫You can see here I'm using journal dot user name equal to authentication dot current user dot display
‫name.
‫You can see how we get the user ID and the user name and set them correctly here in the main activity.
‫Okay.
‫Also, I'm going to fix the Add journal activity because I used the authentication here.
‫So despite using this firebase auth dot get instance, I'm going to use Firebase dot OAuth.
‫You can get it directly.
‫Now I'm going to use the current user ID.
‫Despite using this, I will comment it and I will comment this.
‫Despite using this current user ID, I'm using current user ID equal to auth.
‫You can see guys, the current user dot uid dot two string.
‫Also in the same way I will use the current username.
‫Equal to oth dot.
‫Current user dot display name dot to string.
‫Okay.
‫So I am going to remove I'm going to remove these two unused lines.
‫So this is what we have changed.
‫Because these are making for us the error and preventing us from getting the exact the exact user ID
‫and username.
‫Now let's stop the application and run it again.
‫And as you see, our application is not displaying any posts.
‫So I think also we are getting we are trying to get the data from the incorrect user ID.
‫So for that I will go to the journal list here and let's go up to here.
‫Okay.
‫So.
‫You can see that we are using here the journal User instance.
‫For that I will change this to.
‫User dot uid.
‫Okay.
‫This is the first change.
‫Now I will.
‫I have created this logo I tag.
‫The size I will get the size of the how many documents are there inside the collection.
‫Also, I have created this tag to get the elements.
‫So here elements.
‫Okay, now let's run our application and see if we are getting things good into the logcat or not.
‫And you can see, guys that here we are.
‫The application is crashing, but we are getting the size is one and the elements.
‫This is the reference of the elements.
‫So we are not getting the document query, document, snapshot correctly.
‫We don't need to convert it like this to journal.
‫Okay.
‫So I will comment it because we are getting everything correct we have in this collection.
‫We have one document and the size is one and we are getting the reference, not the not the query document
‫snapshot.
‫So for that I will change this.
‫I will remove this.
‫I will start with four.
‫Document.
‫I'm getting this document in it because it is a query snapshot.
‫You can see it, guys, and I've talked about this.
‫Please, please go back to the Firestore section and you can see the course and the lesson about getting
‫the multiple documents in the collection.
‫Okay.
‫We need from this to create a var called journal.
‫So every document inside the query snapshot, go and create a journal object from it.
‫Equal to journal and I will pass the parameters of this journal class.
‫Document dot Data.
‫This is how we access the data and get what I need to get.
‫I need to get the title.
‫So guys, this is a very important.
‫We are deserializing things.
‫Exactly.
‫So please, you need to focus here at the key you these are these are case sensitive, so you need to
‫focus on them.
‫I am going to get them directly.
‫You can use the journal because I am saving them exactly like this.
‫So this is the modal class title.
‫This is the title dot to string goes.
‫I'm storing them as strings.
‫Document.
‫This is the first parameter.
‫The second parameter, I will copy them.
‫Six times because I have six parameters.
‫The Journal.
‫The thoughts.
‫It's a string.
‫The image URL, you can see it's a string.
‫User ID.
‫User id.
‫The time added.
‫It's at timestamp.
‫Here.
‫Alt+ enter to cast the expression as timestamp and here a username which is the string.
‫Okay.
‫And despite using the get I can use like this.
‫This is the.
‫This is more.
‫Like this data.
‫Okay.
‫You can use like this.
‫Now, after that, when I finished this journal I need to get and every loop I need to add the journal
‫list that add journal.
‫I need to add this journal to the list of the journals that I have.