Welcome back.
At this point, we want to display the members, of course, and as you can see, we have members here
at the top with a back button and then we have the member itself here, which is Dennis and this little
icon, which is the image of the user in this case.
I don't have a user image for that user.
But overall, you can see that one member is displayed.
Of course, only one member is assigned.
And we will need to add more members or we can add more members later on, of course.
But for now, that is what we want to implement.
All right.
So you can try to build it yourself.
You know, everything that you need to know to do that.
But of course, you can also follow along.
I will do some copy and pasting, of course, because it doesn't make sense for me to show you for the
15th time how an adapter is created.
So I think let's just start with that, OK?
So.
This is something, as I said, you can try to build it yourself, but at one point, once you got the
hang of it, it really just makes sense to just go ahead and.
Yeah, just reuse your code.
Right.
It doesn't make sense to write everything from scratch all over again each time.
And here just makes sense to make changes.
All right, so I'm just going to paste in the adapter, it's the list item adapter.
If you have a just copy and paste a class and you, of course need to make some adjustments, it needs
to have the right imports.
That's one thing.
So, for example, we need to import our user class.
We also need to import our our so our resources.
So, of course, the package name will be different.
That's why it's important to make these adjustments.
All right.
So overall, what does this members list adapter look like?
Well, we have uncreate view holder and which we just have a default layout inflator, which where we
inflate our item number, which is this item here that we prepared in the last video.
Then in Unbind view, Holder, that's where a little bit more happens.
So first of all, we create a model out of the list position.
So the list that is given to the adapter here at the top and the position that the new holder itself
has so positioned, zero would be the first entry one, the second and so forth.
Then if the holder is my view Holder and my view Holder is, by the way, our own class here, which
inherits from side view view Holder.
If that's the case, then we use Glide in order to display the right image.
So.
We need to pass in the context, we need to load the image, so this is the image you URL, which is
model image.
So from the user, that image that we want to display, then the next step is to.
Define a placeholder and then where we want to put it.
So we want to put it into a five member image, which is this image here, of course.
All right, and then we assign the text for the member name and the email as well.
OK, now in the members activity, we need to let this activity know that it should use this member's
list adapter or members list items adapter, and I'm going to create a function for this set up member
list where I pass on the list of.
Users.
All right, so on the list of user objects, and then we need to import user in our members activity
so that we can use it and it's the user that we created ourselves or our own model that we created.
And here, first of all, I want to hide my progress dialogue, so.
This is something that you will find out once you test the application and you will see that potentially
a displaced dialogue and it never disappears.
So high progress, dialogue.
And in order to be able to use this function, we need to inherit from base activity instead of a combat
activity, as we've done multiple times already.
So, you know, now in base activity, we have defined functions that we reuse.
All right.
So hi, progress dialogue, for example, and display progress, dialogue and so forth.
OK, so that is the first step.
And then we need to assign to our members.
XML, RV sold to this recycler, view the right adapter, so first of all, we need to give the layout
member manager, then we need to fix the size and then we can assign them adapter.
OK, so let's get real quick.
So RV member list, the layout manager should be a linear layout manager.
And when you create an object from that, you can or you have to pass in the context, then I'm going
to assign the has fixed size true.
So are members list has or set has fixed size to true.
And now we can assign the adapter.
So first of all, we create an object of the adapter, which is our member list items adapter that we
needed to pass in the context and of course the list.
So the object that we want to pass.
So I'm just going to pass in the list.
And that is the list that is given to the function when it's loaded, so set up members list needs to
have a list and now I pass on this list of numbers and then we can assign that adapter to our RV members
list.
So our members list adaptor should be the adapter that we prepared.
OK, now that point, let's go ahead and create another entry in our constants, so the thing is we
will need to use the user ID.
So I'm just going to create a constant ID here, which will be the idea of the user.
OK, so we are going to reuse that multiple times and so forth.
So now we want to get the members list, so we want to get it from the collections.
So we want to get the assigned members, so to speak.
So if we look at that, you can see assigned to it has this idea.
So this is the member that is assigned to it currently, just one member, but it could be multiple
ones.
Right.
So it's, of course, the user here that we created, which is then is a Gmail dot com, which is the
one with this unique user I.D. So that's the one that is assigned to that port.
And yeah, that's basically the one that is assigned to the card as well and so forth.
So let's go ahead and get that value and make it available in our application.
Now, what would be a good function or better said class to do that would of course, do that in our
members activity directly.
But as we have done before, we want to do all of the firebase stuff in the firebase or Firestar class,
because here is where all of the firestorm stuff happens, right.
Will be low data, where we update data in the database and so forth.
So that's exactly what we want to do here as well.
So let's go ahead and create a new function here.
Which I'm going to call fun, get assigned members, list details.
And we need to pass an activity and this one will be the members activity.
And then you need a person assigned to so assigned.
Two, which will be an array, lists of strengths.
So let's look at it again.
This is basically the head of the function and now we can implement it.
So I want to load it from the fire store, right.
So we need to get faster collections users.
And which one do we want?
Well, we want all of those where the ID is the one that we have assigned to.
OK, so here we want to check all the uses that we have where the ID is equal to the one that is assigned
to.
OK, so that is exactly what we're going to do.
And that's the power of the store once again, right where we can use where clauses and where in clauses
and stuff like that.
So let's just do that here, so firestorm collection and the collection name is Constance Thought Users,
of course, internally, it's just.
Users, OK?
And then we can use where in so here I'm just going to say we are in constant thought it is equal to
assigned to OK, because in society we use this ID of the user.
That's the ID that we have as Constancia.
So here we are checking is it equal.
So is there one that is equal or multiple ones?
And we want to get those and then we add in on success listener.
So if that was successful, then we will get a document.
But you want to use so we're just going to log it here with the aggressive log e so an error logging
where we just get the document to string and then we can go ahead and use VUL user list, which will
be an array list.
Of users.
And I'm going to start with an empty array list first.
And then I can go through the document that was given to us, that was passed to us and it was successful.
To add all of those users to the users list, so I in document the documents.
And here I can just say, OK, vol user is going to be I to object, and here it will be end user Java
or Cluster Chilo here.
And that users should then be added to the users list.
Ed.
The user.
OK, so what we are doing here is.
We are.
Checking the database, we get the users, then we get the list of all the users that fit this criteria
and we go through all of them with this volume and we put them into this users list that we have here
so that we can then call this set up members list function that we prepared.
Right.
So here it's complaining because this could.
Return nothing, right, that could return now, but as I'm sure that it will return something, I'm
just going to force it.
Of course, you can check if this is empty or not beforehand, but that's what we're going to do as
of now and then we can call activity that set up members list and here we can pass on the user's list.
So if we look at this function here to set up members list, there's dysfunction we just created in
our members activity, which requires in the list of users.
And that's exactly what we prepared here.
We prepared a list and array list of users.
We filled it up and then we called this function.
All right.
Now we can also add a failure listener.
So what should happen if something goes wrong?
And I'm just going to say, OK, add on for your listener.
The exception should be logged, so look the exception and then also highlight the progress dialogue
if something went wrong.
Now, we could, of course, let the user know as well as voting members went wrong or something like
that.
So you can add a little task.
Snack bar here, for example.
But I think for now, it's going to be fine.
OK, and now we can go into the member's activity once again and here in the uncreate, that is where
we can now, first of all, show the progress dialogue.
So the user comes to this activity.
First, we show the progress dialogue, then we call the function of the forest or class Soulfire store.
Class, get assigned and come on, give me something.
Import Firestone Glacier.
Get a signed.
Members list details, then we need to pass and the activity so this and we need to give it and more
details.
All right.
So here and board details that assigned to.
Because if we look at our get assigned numbers list, it needs to get an array list of assigned to values,
right.
So a bunch of strengths.
And that is exactly what we are passing here with more details assigned to, because if you look at
it, assigned to is an array list of strengths.
And now everything comes together and we can basically use it now.
Now, you could, of course, put this code into the if statement, so only if there are more details
we want to do anything.
So if you want to really make sure that this only runs, then you could put it here.
But usually nothing should go wrong.
Right?
So we should have at least one assigned member.
If that goes wrong and this creates an error, then we have an error somewhere else, actually.
So this is just going to then be one symptom of the error.
OK, so I'm just going to leave it where it was.
So these kind of things they are always expecting or.
Yeah, when you write code like that, you're always expecting that everything that you wrote before
is correct.
So the code works correctly.
So if you want to really make sure that everything goes right, then you would put it into the if then
you would have an L statement where you then notify or when you write another log entry.
But the thing is, those functions themselves, they also give us log entries.
Right.
So we will see the error even before.
OK, so now let's test that.
Let's see if we actually can see the members in this case, just one member, which will be Homer assigned
to our different part boards.
OK, so there we are, bored with image.
Let's go over let's go to the members.
And we will see much there, the images populated, the email addresses there as well.
Perfect.
All right.
So that is it for this video.
Of course, we want to be able to add members later on and do a bunch of other stuff, but that's for
the next few videos.
So we'll see you in the next one.