Welcome back.
Now it's time to display the list of boards that we have, and in order to do so, we, of course,
need to add some more code.
So let's get started.
Therefore, I'm going to go to the main activity and there we need to create a new function which will
take care of populating our board.
So let's go ahead and created here fun populate boards list to you.
So I'm going to call it and we first need the boards list, which is going to be an array list of boards.
So array list of board.
And then we need to import board here.
And we can start with a code for dysfunction.
OK, so what do we want to do here?
Well, first of all, we want to highlight the progress bar if it was loading before.
So let's hide it then.
We want to check if the borders list is empty or not or is zero or not.
So both this size is greater zero if it's more than zero.
What we know is that we can make our our V borders list visible so that the visibility to view that
visible and then we can go ahead and make the TV no boards available text invisible.
So we have visibility set to view dog gone because Invisibles are going to be enough.
It actually has to get out of our whole layout.
Then I'm going to tell my Archibald's list what kind of layout manager I want to use.
So here layout manager will be a linear layout manager where I then pass this activity to and then I
can set has fixed size to true.
So that our boards list has a fixed size.
All right.
So that's what this function does.
So reactive you function.
And and that the changes cannot affect the size of the risk of you.
Then, as always, with respect to views, they need an adapter, right?
So let's prepare an adapter here, which will be our board items adapter that we created in the last
video here.
We needed to pass the context and the list that we want to use.
That is that I want to use is the board's list.
OK, so if you recall this item adapters, the class that we created in the last video, we needed to
pass in the context and then a list of bords.
OK, so that's what we do here and now we can assign that adapter to our boys list, so we bought list
that there should be the adapter that we just created.
And then if the wordlist is in fact empty, then we don't want to display our port list, but we want
to do it the other way around, pretty much so here then our ports, this should be gone.
And the text that says that there are no boards available.
This one here, this is TextView.
No boards are available.
Should be set to visible.
So this function will just take care of creating the boards in the why it's you guys going to actually
download it, right?
Because we will download it somewhere else, then we will pass it to this function and this function
will then go ahead and display everything in the UI.
OK, now I want to make a little change in my boards because the board doesn't know about his I.D.,
so I'm going to create a new variable here, VUL document I.D., which is a string, and then we of
course need to add that here as well.
So parcel restring.
Then further down here, Passell right string with the document ID.
OK, then, in the constant.
I will also use this assigned to so I'm going to create a assigned to.
Horrible.
And my utils constant.
So here we have the mobile with the name The Image Debord's Everything.
Now let's create one for our assigned to.
OK, uh, signed two, which will be a string, which will just have this text called Assigns to.
Because now we can use this constant instead of using the string, which will be a magical string,
and it's always difficult to then find the right spot where we use that string and how we called it.
And if we made a mistake, then it's going to be difficult to find that mistake.
So it's really a lot easier when you just work with constants that you can then quite easily adjust.
All right.
So now we can go to our Firestar class, because now it's actually time to get the boards list from
our fire store database.
So let's go ahead and create a new function here.
So here we created the boards that we obtained user profile.
Well, let's create a function to get the boards a list and we need to get the main activity as the
activity that calls this function.
Then I'm going to use this collection stuff as well, so am fire store collection with the constants
dot boards then.
Now we're using queries.
So that is something that is pretty powerful and that is a feature that Firestone offers that unfortunately
the real time database of Firebase doesn't offer.
And that's really where the power of our store lies.
That's why we use it.
OK, I thought about using a database or a real time database and I even tried to build it there.
But man, oh, man, that was a tough one.
It really made things so much more difficult when you wanted to create a maintainable and hugely flexible
database structure.
That was a pain.
So I decided to go with the fire store approach.
And this is why pretty much all the stuff that we're going to do now is really a big part of why I decided
to use the fire storm.
So we are checking what the array contains, constants that assigned to and what is it designed to?
Well, our current user ID.
So current user, actually, we need to get it right, get current user I.D., this one.
OK, so what we're doing is we're checking.
The board's collection where the value for assigned to is the current user idee.
So if we look at our boards here, for example, this board was created by this user and that's the
user ID of the current user ID or the current user that is locked in the secure and user ID.
So we just checked through all of the boards that we have were assigned to is equal to whatever, just
ideas that we have.
And if it's the same, then we want to display this board because then we want to use this board and
it was assigned to us.
So either we created it ourselves, so it's assigned to us or somebody else created it and assigned
it to us.
Then we also want to see this board, because then we need to make adjustments on the board maybe,
or we need to finish tasks.
And this project is also assigned to us and so forth.
So what do we want to do with that?
Well, we want to get it, so get and then that's add on success listener.
So if that was successful then we will get and you can see there are multiple different options.
What we will get and I'm just going to get a document.
OK, so I'm just going to say, OK, now that you give me this document, let's use it.
And I'm just going to write a little lock entry here.
So simple document documents to string.
So I'm just going to display the whole document as well as I will create a boards list.
Which will be an array list of Borz.
Which will be for now, an empty array list and of course, I want to add all of the words from that
document to it.
OK, so this document is a snapshot and the snapshot only contains the stuff that is assigned to us.
So only the boards that are assigned to us.
So what I can now do is I can go through the whole document.
And then had every single board to my board list, so what I'm going to do is I'm going to say, OK,
create a board, which is I to object.
And here is our port call and column class, not Java.
So we're basically saying whatever object you have there now, create a board object from it and stored
in this board variable, which we then can use to, first of all, get the idea of that board.
So now we don't only get the board list, but we are also getting the document ID of the board and we
can now go ahead and add that board's list.
Or the board to the board's list now, as it seems, the document idee.
String, let's have a look what the problem is.
Well, it has to do with two objects returning a nullable, these are the tricky ones, right?
So it returns on nullable.
That's why we need to.
Use double exclamation marks here and here.
Still getting a little error, that's because my document I.D. is a var or should be a var instead of
a because I want to be able to change the document ID, as you can see.
So what we do here and that's why I needed to change it real quick.
OK, so at this point, we get the whole list, but what should we do now?
Well, we should, of course, also populate our activity.
So activity that populate the boards list to UI with the boards listed, we just prepare.
OK, so that's what the whole Paulista UI function was for.
It needed a shortlist to then display the board's list in our recent review.
So that was the whole point of this function.
And then we created this function to get the board's list, to then populate our board with it.
So that's the add on success listener.
Now, let's add in failure listener as well, and which I'm just going to highlight the progress dialogue.
So here at Unfilial Listener, with an exception here called E!
And I'm just going to say log E, simple name error while creating a board.
All right, the next step that I'm going to do is also a little optimization step, so to speak.
So let's go to the last user data function.
So we have this function here, load user data.
This one here.
What I'm going to do is I'm going to add a parameter here.
So that's going to be called Read Bords List, which will be a boolean.
All right.
So I want to know if I should read the board's list or I shouldn't.
And this will be relevant here in the updated navigation user detail, because I want to make sure that
I only update their navigation user details and only read the boards in there if necessary.
OK, so let's go to our update, navigation user details.
And actually, before we do that, real quick, I'm going to assign faults to this value, so not here,
but here, I'm going to assign default faults.
So this will be by default faults.
So you don't always have to add a value, but if you add one, then you can make changes to it.
OK.
So now let's go over to our update navigation user detail, and here we need to accept a boolean and
I'm going to give it the same name will be a Boolean.
The idea behind this is that we don't always load everything from scratch, but, yeah, sometimes we
just have to clean up things, right.
OK, so before we update this function, I want to make clear why we even need that.
So inside of our main activity in the uncreate, we load the user data.
All right.
So here first, our class load user data.
At this point, we want to also load the ports so the user comes to the main activity for the first
time and then we want to load all of the boards of that user.
So here we need to pass in.
True, because load user data is the function where we load the user data.
Right.
So it reads the board list or should it read the boards list boolean true or false.
Well, I say yes, please read it.
So then.
It should read it when we loaded the first time, but now let's say the user has this work, this flow,
so he comes to the app and he sees all of his elements here.
Then he goes to the profile, he changes something in the profile and he comes back to this activity.
Then I don't want him to load the whole board.
Once again, the board can stay the same as it was before.
The page will load, but it will not load all of the details of the boards.
It will just keep the boards as they were before.
All right, so this is just a design decision, you could have left that out, but it wouldn't be that
optimized done.
OK, and now we can go back to our update.
Navigation user details.
And here.
I want to load the board's list if the rewards list is set to true, so if reports list said true,
then go ahead and show the progress dialogue.
That we have prepared so far, which is this please wait, progress dialogue, so here you can use resources,
get string or string, please wait.
And then our fire class get more list with this activity.
And at this point, we can finally test our application.
All right, so.
Pro gymnast.
No boats are available.
And then it loads a lot someone, as you can see here, bought with image and bought without image.
OK, so these are our boards were created earlier on.
Now, there is one thing that I'm not so happy about, and that is the fact that I cannot distinguish
the two boards from each other or where one ends and the other starts and so forth.
So we should go back to our resources.
And here we have the layout item board.
And at the very bottom, I want to add something.
So it's just inside of the last linear layout, which is just a little separator.
All right.
So width should be match parent and height will be.
The item poorer on board divider height.
All right, then.
The margin top, so here margin top should be the wider margin top.
And then finally, I want to have a little background, which will be at colors, divide or color.
So it's this divided color that we prepared to grayish, whitish color, so slightly different than
white.
OK, so let's close this and run this again.
All right, and so there's this little line here, barely visible, but it's there and that is just
the watercolor.
Of course, you could make it more grey.
So it's a little more visible, but it is all design choice that you can make yourself OK.
So that is it for this video.
See you in the next one.