Welcome back.
In this video, we are going to look into the members functionality, so let's look at a specific card
and here we can select members now.
So you can see I want a new dialogue to open up as we can then select multiple members who are added
to this particular card who are not added but responsible.
I think that's the better word.
So here, of course, we are not finishing the functionality yet because there is a lot to do.
But we are adding this feature here, at least this dialogue for now, where we can then see the individual
members again.
So I think let's just get started with this without further ado.
So the first thing we need to do is add a new constant dimensions, all the standard stuff.
Right.
OK, so let's go over to our Constance Katie here.
We are going to need a new Consed Vol select, which will be the string that's going to say select and
then const vol on select.
Which will be a string that says unselected.
Then we need a dimension, and in this case, you don't need to download the latest dimensioned file
because it's really just one dimension that we need to add here.
So in the values, let's go ahead and add the dimension, which will be the following.
So it's just as Adam's elected member image size, and that's 45 DPE.
All right, the next thing is that in the members list items adapter, I would like to add the functionality
to be able to click on it.
OK, so what we need, therefore, is an interface.
So here, interface on Click Listener, and it just has one function, which is the click function,
which needs to position, which is an integer and the user, which is a user.
And then finally, the action that we want to do so action, which will be a straight.
Next, inside the unbinding view holder here, I will add a check if Model Todd selected.
And by the way, model is, of course, our user and selected is a new property that we need to add.
So go over to your.
Model called user, so here, models, user, and here you will need to add this boolean saying var
selected Bujon equals false.
OK, so the idea is that the user can be selected inside of a card where he can be unselected and that's
what this variable will take care of.
And now we can use selected.
So we have the user here now and then we can go back to our members.
This.
Times adapter, so here, so if the model is selected, then I want to make a change to my item member.
Layout, which we haven't created yet, I think.
Well, we do.
So there it is, item number.
So here I'm going to adjust item number a little bit.
It's not much, but what we will have here is just a little tick box at the right hand corner.
OK, so at the very right hand side, I want you to have a little tick box here, which is going to
be.
Just here.
All right, so it's going to be this image of you, the one that we have used before.
Right.
So here.
I've selected members, I'm going to call it, and we're going to use the vector.
On this score.
Quite done, I think.
Let's see if it's that one.
Yeah, just a little tick box here.
But actually maybe in a different color, so maybe it should be something blue.
So let's go ahead and create a new vector here.
So new.
Pacta Essid.
And this one was.
I see Victor color accent.
On the score done.
Twenty four deep and the difference is that we use a different color here, so here I want to use the
color that we used for our accent color.
So here, let's go over to.
Colors.
And the accent color is this one here.
All right, so let's go ahead and create a new vector.
Which I'm going to call like so, and it should have the color as we see their zero C nine.
Nine.
Zero F one.
That's just one and created.
OK, so now I want to use this color, right, so here, not Wighton, but Lechter color xanthan.
So now inside of the adaptor, we can talk to this element, so Holder, I tell you, I've selected
member thought visibility.
I said to visibility, dot.
Visible.
Or is it to you, right, its view that visible?
And then alternatively, in the case that.
It's not selected.
It should be invisible.
So here pelt's pretty much this code, but.
It's gone.
And then the whole thing should have an item on Click Listener, so we prepared to click listener interface
here and now I want to use it.
So here, holder dot item view dot set on Click Listener, which is checking if we have another clip
listener.
So on click.
Well we need to create this variable therefore.
So let's go ahead and create an on click listener variable.
At the very top here, so not.
There, but here, private bar on Click Listener, which is an on click listener.
Nullable.
And I'm going to set that to know at first.
Let's see the error disappeared and now I can check if I click listener.
It is not equal, not.
Then.
Let's.
Check if the model of selected.
And if it is selected.
Rhonda.
On event with all of the details, so we need to pass into position the model and then the details about
the action.
So position.
Model, which is the user, and then constant start on select.
And otherwise, do the opposite.
So here pretty much do the same unclick, but with select.
All right, and next, we need to get this dialogue here, so here there's dialogue where you can see
we have solid member and then we have two or a recycled you with two items which are of top member or
which are of a type that we have used before.
Right.
So for this one, see, there's a little challenge.
Tried to build it yourself.
I will just paste the code in here.
I will go over the code and then you can, of course, pause the video now and try to build that yourself,
because we have done that at multiple points, for example.
Here, when we select members, these are the items that we want to use.
So this is how an item looks like, right.
And then when it comes to the dialogue.
This is how you can have a dialogue, so this is the result of you that you see here should just not
use the items as the colors, but the items as those members that we have just seen.
So it's basically combining those two things that you have just seen and to one.
All right.
So this is a little challenge for you to try to do that yourself.
All right, so there it is, a members list dialogue, it's an abstract class, we need the context,
we need a list of users and we need a title and then it inherits from dialogue.
So pretty much the same thing as our other dialogue that we prepared before, which is a label color
list dialogue.
So it's very similar to a lot of stuff is the same.
You can see here.
We also need an adapter.
Well, this time it's a different adapter.
It's our members list items adapter.
Then we have an uncreate method where we inflate the layout that we use, which is our dialogue list
layout.
Then we have the content view that we need to set.
We said cancelable on touch outside to do that, cancelable to true.
And we set up our recycler view, which is this function right here, which needs a view.
Then it can set a title of that view.
And then if the list is not empty, which means if there are entries inside of the list, then we fill
the RV, which stands for our respective you.
Layout manager should be the linear layout manager, so, yeah, by the way.
This is the dialogue list.
That we had used before, right, so we have select then a separator and then the recital of you.
And we reuse it so we don't need to build a separate XML file for that.
Then we set the adapter being a members list items adapter, which was this adapter that we just looked
on at a couple of minutes ago then.
We set the adapter to be the adapter of the respect of you, and then I want to have an unclick listening
for that adapter and therefore I need to implement this function inside of my members list items adapter.
But let's look at what's happening here.
So we're creating an object of the members list items adapter on Click Listener in which we override
the on click function.
So we implement the interface here called Unclick Lisner, which is this interface right here.
And then we have the unclick event which dismisses the.
Dialogue itself, and then it calls on items selected, which is this abstract function of our members
list dialogue.
So this function as we have it here.
Now, let's implement this set and click listener, and we need to do that in the adapter, which means
in our members list item adapter.
So here, let's create this set on Click Listener Function.
And it needs an outlet listener.
Which is the one from our I must list items adapter class, and here we just need to say that this unclick
listener is the unclipped listener that is passed to us, which means the unclick listener that we have
prepared here in our members.
These items adapter class, which we set to now first and now we set it here with this function.
Once it's called, then we can use the home click listener with its own click function.
So that's how everything is connected.
But that's nothing new.
We have done that multiple times before.
And then the error disappears here as well.
All right, and at that point, we, of course, need to go to our car that details activity because
that's where we are at that point.
So this is the cartel's activity.
Right.
And we want to do something once we click on this element here.
So once we click on select members on this TextView and in order to do so, we, of course, need to
have a function for that.
So let's go ahead and create a new function for it, which is going to be private fund members.
A list.
Dialogue.
And it, first of all, needs a variable called Card Assigned Members List, because we need to know
who are the members that are assigned to us.
And that's m more details, that task list.
And what if you have it here, cards and so forth?
All the way up here, Dot.
Assigned to.
OK.
So as the members were assigned to this card and then we can check if there are any members assigned
to this card or not.
So is the size greater zero?
If that's the case, then go through the list of members.
So for I in M member details.
List the indices, so go through all of the members that you have and then for Jason Card Assigned Members
List.
So we have a follow up with a fulu, so we go through all of the indices and in there we go through
all of the members inside of the members detail list and then we check if the members detail list at
the position I thought ID is equal to.
Jake.
So the individual members of this parliament or the member that is assigned to it, and if that's the
case, then.
Activated so members details list.
I got selected.
Is that a true.
OK, so what's happening here?
This is a little complicated, maybe so.
First of all, we check do we even have any members in the wrist?
If that's the case, then go through all of the members in the wrist, then check.
Or then for every single member in the list, check for its ID if it's the same as the member that is.
Assigned to the card because.
We have the people who are assigned to the cart and we have the people who are assigned to the board.
OK, so we check are there people who are inside of the board who are assigned to the cart?
And if they are the same, then make them selected.
All right, and else, which means here also.
Of this block here, we will just say, OK, for all of the members in the indice.
Let's set them to.
False.
So you're false, they are not selected.
So if no one is in the list of people who are assigned to the court, then no one is selected.
So that's basically what this code here says.
All right, and now, of course, our taxpayers, you select members, should be.
Clickable, so how do we make some clickable?
Well, we had an unclick listener to it and the uncreate method, for example.
So here we can just say TV select.
Members said Arncliffe listener.
In which we basically just want to call members list dialogue so dysfunctional, we just prepared.
All right, and now we want to display the dialogue, we, of course, need to add that to our members
list dialogue because we just prepared everything here.
But in order to actually display the dialogue, we need to create an object of it.
So.
Object.
Member.
List dialogue, and when we need to create one of those, we need to look at what we need.
So here we need to context the list of users and a title.
All right.
So let's put this into context, which will be this.
Then the list of members will be members.
Detailed list and then the title.
And there I'm going to use a resource which I'm going to call string select member.
So let's go to our resources, values, string's.
And edit here, so string name astar, select member, and it should be select member.
OK, now going back to our card details activity.
The error should disappear.
All right, there we are.
So this will be the title of our members, this dialogue.
And then, of course, we need to implement its functions, because if we look at it, our members,
this dialogue needs to implement.
The UNCLICK event, so employment numbers on Eitam selectors sartorially unclick, but it's on Eitam
selected because if we look at our members list dialogue, we had this function here, which was an
abstract protected function where we said, OK, it's called on item selected.
And if it's abstract, it doesn't have a body.
But you need to implement the body once you use this placea here members, this dialogue class.
OK, so what do we want to do in their.
Well, that is something that we will need to do later on.
So implement the selected members functionality.
That's what we all need to do later on, but for now, what we want to do is to actually show this dialogue.
So to show this list dialogue.
Or alternatively, list dialogue, but show.
I think that works as well.
OK.
If we now test this and go over to the card and click on select numbers, we can see that this dialogue
opens up, we have baat and we have Holmer.
But of course, nothing will happen as of now.
All right, then there is one last thing that I want to do real quick, and that is to had a recycler
view here to the members.
So once we have selected people, we want to see them inside of this activity here, inside of the select
members TextView.
So instead of displaying a text, you all want to display a recyclable view here with all of the different
members were assigned to this cart.
OK, so in order to do that, I will need to create a new XML file.
I will need to adjust our XML file called activity card details, which is this one here.
So here we had this design.
We can see sort of colors like numbers and so forth, and now select numbers, that's where I want to
make changes.
So just underneath it.
I will add a little.
Recycler of you.
OK, so here on top of due date underneath our select members, that's where I will put this recital
of you that you can see here.
All right, so it's this one here.
Harvey Select Members List made parent and with Web content and hide, use dimensioned card details,
value margined top that we have used before.
And visibility is set to go on and towards visible is set to true, so you can see now this is the result
of you that want then to have and then I wanted to have a specific look.
And therefore, I prepared a prepared to lay out file as well.
You can just download it or you can type it in.
So it's going to be.
The item card selected member XML.
For which we will need a little image called.
I see ad member, and if you want to use the same image as I do, you can go to file new then vector
asset and select this ad icon here.
And then select a color, see 90 of one that I'm using here and basically next and finish and then you
should have this is the member, of course, you will need to call it that way as well.
All right.
And the idea behind this is that we want to display two image views, so a circle image views inside
of our linear layout, one circle image view per user that is assigned to a card and then another circle
view, which is going to be our plus icon, which indicates that we can add more people to this card.
So that's the idea behind this plus icon right here and the journal behind this item cards selected
members, even though just looks like it's this little icon, but it will be two icons next to each
other, or even three or however many members you will have assigned to the.
Card itself.
All right, so that's it for this video, we will, of course, implement the functionality behind those
buttons later on.
So see you in the next one.