Welcome back and this video, we are going to add something to the task list, so let's have a look
at what Simpson's here.
So I if this board watch Simpsons and you can see I have a bunch of lists here.
Well, in our case, just to season one and season two.
So what I have to watch is season one and season two.
OK, so I didn't card doesn't work at editing.
Doesn't work, it doesn't work yet.
But what works is to create a new list.
So you can see I can click on add list and that will open up this.
Cart here and there, I can, for example, now add season three as another list, so let me add that
here real quick.
And you will see we have season three here, season two and season one, all of them directly here.
All right.
So this is what we're going to implement in this video.
So you can see the data is in the database.
Well, you can see by me going back and then opening it again, you will see that it's still there.
So this means that we actually use data in the database and let's go ahead and build that.
Therefore, what we need to do is we have some stuff in the fire class or fire or class.
Then we will need to adjust our task list activity, of course, because that's where all of that magic
happens.
And we will also need to make some changes to the adapter that we have created.
So this task list items adapter, then the Firestone class and of course, our.
Task list activity.
Let's start with a fire storm class, so what I want to have here is I want to assign the document ID
to the board, so we haven't done that yet.
And that has to be done in the get bored detail.
So here what we currently get is the details and we say, OK, let's pass in the document that we loaded
to a board object.
But I would also like to have the idea of the document or to be precise, of the board itself.
So what we can do is we can create a board here, which will be a document to object and pretty much
the same thing that we have here.
So what equals?
The document to object and then we can assign the document ID to the board, so, you know, the board
has this particular document ID and the document has an ID.
OK, so when we create a new board, it has a unique identifier.
Which is this identifier here?
OK, so I want to get this unique identifier here.
And then instead of doing the cold here, we can just pass and the boards now.
OK, so that's step number one in the four Firestar class.
Now let's go over to the task list activity, because what we will need here are the board details.
So let's create a variable here and because we will initialize it later on, it's going to be late in
it.
I'm bored details of how I'm going to call it and it will be a board.
So our board class here needs to be imported.
Now, where would we initialize that?
Well, let's look at our class here.
We have this board details function where we get a board pass.
So that's a good idea.
At that point, we have a board so we can use that board as the one that we are actually working with.
So let's go ahead and do that here.
Let's just say and board details is going to be the board that is passed to us.
Now, at that point, we don't need to pass it to our set up action bar anymore, and accordingly,
our set up action bar doesn't need to get the title anymore.
What we can directly get it from our board.
So board.
That name.
Or actually is the action barn title will be bought, dog name like that.
And of course, it's our board details that has the name, which is this broad object, which, of course
has a string called name.
All right.
So now we can go to the task, this item adapter, because we have this element that we want to be able
to click on.
OK, so here when we have this unbind view holder where we say what we want to hide and what we want
to display and in here after the else block and not inside of this, if else statement in either way,
what we want to have is we want to have a text for the task list title.
So here Holder item view TV task list title should have a text and that will be model title.
So the title of the model, which is basically the title of the model that is passed to us, which is
the task.
OK, so we have a title for the task.
And then.
We said that, OK, so we get the title and then we set that as the TV task list title, which is this
element here and the design, if we look at it, this title here where we have the two buttons next
to it.
OK, so we're loading this title here.
OK, that's what we do here.
We assign that title and then what we also do is we give it an unclick listener.
OK, so Holder item view.
TV ad.
Task list, so not the task list title itself, but the actual task list we want to give the listener
so that if we click it, that something will happen.
Of course.
OK, set on Click Listener.
And what do we want to execute there?
Well, we want to make the hard task list invisible.
So Holder and actually.
The same that we have here to be at least visibility to view gone, and we want to make the.
It's not exactly the same the want to make the CV at Paschalis name.
Visibility too visible, so when we click on this ad task list item.
What we want to happen is we want to make this had a text here or the text, you actually want it to
disappear and we want this element to appear OK.
You can see it's the one that is called Cevat Task List name, which is this part here.
So we want this to appear.
Now, of course, once we click the icon button here on the right hand side, which is this checkbox
or this check here, once we click that we want to create a new element.
So we want to give this one a.
Unclick event, so here, when I say something like Season four now and I click this button, then I
want this element that we have here to be invisible, to disappear, and instead this part here to appear
OK, and also the ADCA to appear.
So I want to again, make the one that is currently visible, invisible.
And now instead of displaying this here and instead of displaying all the other stuff, I wanted to
split this title here.
With the buttons and I want to display this at card.
OK, so let's just do that real quick just here so I give the Holder item, you thought I.B. close call
list.
Name this one here.
I want to give it an unclick listener, so set on Click Listener and by the way, this is this image
button to close and then we have an image button to add.
So we need to implement both of them.
Let's first do the close one, which is the easiest one, because then we just reverse what we've done
before pretty much.
So now we just do what we have done here only the other way around.
So now this one will be visible again and this one will be gone.
OK, now we can, of course, go ahead and do the I.B. done so Holder I can view.
Thought I'd be done at list or done list, name this one here, done list name you can add on click
listener here as well.
And here for now, we will say, to do create entry and DBI and display the.
Task list.
OK, so we need, of course, to add that later on, but a lot is going on here, so we need to prepare
that by doing some other stuff.
First case of the stuff that we need to do first is to create a function that adds or updates a task
list.
And where would that be?
Well, I think in the task, this activity would be a good spot.
So let's create a new function here, which I'm going to call fun.
Ed, update task list success.
This one will be called if it's successful.
Right.
And then we want to get the details, so.
Fire store clerks get bored details.
And here we need to pass and the activity as well as to document Edem so yea and board details that
document idy, that's what we will pass here.
And then we might also need to close the.
Dialogued, We are opening so the progress, dialogue and everything, but that's something that we
will see in the near future.
Now that we are going to work with the task list, I think it makes sense to create a new entry in our
constants here for our task lists.
So you can see each time that we have a new name that we use for any element in our document, which
means any element in our database, we create a new constant so that we always used to write your URL
here or the right name for it.
So this one will be a string, which I'm going to call task list.
Now, let's go ahead to our Firestar class, because that's where the magic is, where we actually create
something, right?
We create a board here, we create the user, we get the board list and so forth.
So all of that magic is happening here, all of the database magic.
And now I'm going to do the same thing here for our task list.
So I'm going to create this function and update the task list.
So I'm going to call it and then need an activity this time the task list activity.
And I also need the board.
So let's pass that in here as well, and then here comes the firebase magic.
So first of all, we need to think, OK, how is the task map or task list going to be?
I guess if we look at the board, we can see that a task list is a task and it's actually an array of
tasks.
So an array list of tasks, multiple tasks that are in there.
And the task itself has a title.
And created by so this can be displayed as a Hashmat.
OK, so we have a string and then we have any kind of information or even though in this case it's string
string, but maybe we want to adjust the task later on.
We also want to store the date or where we also want to add some more information that we want to store
about the task.
So it makes sense from the beginning to use a hash list, which is going to accept both our hash map,
which is going to accept both.
So let's create one task list.
Hash map is how I'm going to call it.
And it will be a hash map, which is a dictionary and other programming languages, as you know.
Or maybe no.
So this is how we create a Hashmat, we just say, OK, the key will be a string and the value will
be any and then I can go ahead and assign values to it.
So does this Hashmat at the position constants DOT task list, and that's exactly why we created this.
Right, so that we can now access it.
And we say at this position, I want to storyboard that task list.
So now any makes a lot more sense, because if you look at it, Batarseh list is in any type, it's
not a string, it's an actual array list of tasks.
OK, so now it really makes sense that they are going to be of that type.
OK, I know at this point we can go ahead and create the entry in the database, so here we're just
going to use and Firestar again create a new collection called OR in Constance Bords.
Which is going to be document and here for the document we pass in the board to document it, so this
time you can see we are passing a document ID instead of just using nothing.
So if we use nothing, then it creates a new ID for us.
But if we're passing an ID, it will just check the one idea that exists and override whatever is in
there.
So it's going to update updated.
That's exactly what I want to do.
So I'm just going to say update and then update the task list.
Hashmat.
So now at that one here.
To the document, and then we want to see if it was successful with an ad on success listener.
So here I'm going to add a blog entry saying that it was successful.
So it has this updated successfully.
And then I want to call activity thought I add update task list success, which is dysfunctional.
We created in which we get the details from the fire store class for debt document ID, which is get
more details, will get us the whole document, which means the whole board pretty much OK.
So here I get a document which will be the board, which we be then.
Pass over to board details, which then goes ahead and displays the board and so forth, but at the
same time we will have to board them.
OK, so that is how we can get the board and how we can update the task list and now we also need to
add a on failure listener.
So here we have an exception that we will get if we have a failure.
What do you want to do if we have the exception?
Well, I'll definitely highlight the progress dialogue and then have a little blog entry telling us
about the error that we get so error while creating a board.
And here we will pass in the exception that was given to us.
OK, so it will contain some more info.
OK, so at that point, we can.
Call this function, but where would it make sense?
Well, I think it makes sense to update the task list once we click on this create button here on this
ad list and then on this button here on this side.
But, of course, we need to prepare it, right.
So let's prepare a function which will take care of all of that.