Welcome back.
Now it's time to add the added feature and add the lead feature so we can create a new list, but how
about deleting or editing it?
Well, that's what we will look at in this video.
So we will need to add those two buttons or give those two buttons functionality.
OK, so this button is to add a text button.
Let's look at how it's actually called.
So an item task.
We can see it's this one here and it has the name I.B. added list name and then the other one is the
IBT list.
So we need to add unclick listeners to those in the task list items adapter where we are in the on bind
view holder.
OK, so here we gave all of those items, use some unclick listeners already, but now we need to add
another one which will be holder item view dot ib edit.
Underscore listening.
And that should get an on click listener and now instead of the listener, what I'm going to do is I'm
going to give my item view et edit task list, name the text that we get from model name.
Or actually was title right model the title?
So the idea is that this added text here, which will then be displayed, so this whole Kaavya view
will be displayed and we can now add it to task name.
So as you can see, we have the one where we create a new task and we have the one that we open up when
we added the task.
So we want to use all of those different cases.
So here we just give it the name that we currently had.
So we populate it into this added text field and then we can go ahead and get the L.L. Title view visibility
to visible or view dot com.
So we want to make it invisible or make it disappear completely.
And then we set the CV edit task list name to be visible.
So you thought visible.
Then we have something very similar to what we had with I.B. close last name, so if we look at it again,
we see that this one here also has this button, which is I.B. close, editable.
OK, so now we're displaying this linear, um, layout, which also contains this button here, this
I.B. close editable.
And that's the one that we want to also give some functionality.
So if we click that, we cancel the process.
Right.
And that is very similar to what we've done here.
So basically, let's just copy that code here and put it underneath here.
So the only difference is it's not Ivy close view, but our close listening, but it's I.B. close editable
view.
And what we do here is we say item, you know, title view should now be visible and the KVI editors
should now be gone.
OK, so the one that we just prepared or we just set the text to, we now want to make it invisible.
So once we canceled it, once we pressed on this cancel button, we don't see it in here.
We only see it here so far once we click on that button.
OK, and now we can actually give the darn editing button, which is this one here, which is I've done
added list name.
We want to give it the functionality to actually make changes, so to update something.
So here again, Holder, item view, I.B. done list name or actually it's done edit listing this one
here.
Done added listening set on Click Listener.
And here we need to add some code first, so to do the editing, implementing.
Or implement it.
OK, not a good sentence, but it's clear what has to be done, so in order to do that, I will go to
the task list activity, because here we need to create a new function which allows us not to only create
tasks, but actually to update it as well.
So fun update task list.
We need to know at which position.
We need to update something.
We need to know the current list name and we need to know the task that we want to update.
OK, so when we want to update something, we need to know all of those things.
So position, which is an integer then the list name, which is a string and then the model, which
is a task.
OK, so we need all of those in order to then make changes.
So let's first of all get the task based on the list name and the model that created by.
OK, so we need to create a task and we need to know who created it then.
We go to our more details and check out the task list, and it's actually more details here.
We check out the task list at the position given.
OK, and this will be our task here, so the task that we just created here will be the task at this
task, this position, and then we can remove the old one.
So task list.
Remove at.
And more details.
Dot.
Personalist.
That size, minus one.
Let's then show the progress dialogue and do the same thing as we've done here.
So basically the same thing as we have created the board.
So first show the progress dialogue and then we pass in or call this and update task list and we pass
into more detail.
So you can see add an update task.
This so this function as both.
OK, at this point, we can go back and we can implement that code here.
So what we need is the list name and we get that from Holder item view.
And it's not the yodeller, but it's the holder item you thought added.
Or eat at a text.
Added task list name.
The text.
To a strict.
OK, so we get it from the bottom view from this one here.
This element here.
And we need to check, is it empty or not?
So we do the same thing as we've done here, by the way, so you can see down list names said Unclipped
Mesner.
It's pretty much the same thing that we do now so we can check the list name not empty.
If it's not empty, then.
Don't create a task, but update the task with the position and the list name.
And of course, we also need to pass in the model, which is our model that we created at the very beginning
of this unbind view holder.
So here, follow model list position.
So you see we get the position from the online viewer holder.
We get the model based on the position, and now we can pass those things here when updating the task
list.
OK, so we needed the position we needed to model.
And of course we also need the list name, but we get that from the edited text that we use here.
OK, and otherwise we say please enter a list name.
OK.
So that is if we want to edit something.
Let's actually give it a try before we implemented the lead functionality, which will be very similar,
but still slightly different.
So let's test that first.
OK, so bored with image here, let's edit this, let's call it list one to.
And you can see the change was made.
Let's go back and see if the change is persisting.
We could see the change is still there, all this changes, little list here list.
Pay oos of the.
And that worked as well.
All right, so everything seems to work.
Now let's look at deleting.
Therefore, we need to go back to our task list, because here we created create task lists, the update
task list and now to delete task lists.
So fun, the lead task list.
And here we use position and so we need to know at what position we want to delete something and we
just go ahead and say more details.
Task list, remove at.
Position.
And now we also need to make sure that the.
I'm bored, details, task list, remove, and I'm bored actually this line here and it's just.
Run all of those, so the same thing, we run this code, then we show the progress dialogue again and
we call the update task list with an updated and bore details.
So just update the whole board with this Tulita task list.
So a very similar function to the update task list, but still one minor change.
So here we only remove it.
OK, and now we can go back here and we can go to the delete process.
Which.
Can be easily achieved, but before we do that, I want to just add in a little cold part in here.
Let me show you, OK, so I'm posting this in here because it's just an alert dialog and it's not really
necessary.
And actually, I need to put it outside here.
So this is something that you can do, but you don't have to.
So I want to display an alert dialog for delete lists or when I delete a list, I need to get the position
and the title and then I want to use the alert dialog builder in order to create an alert.
OK, so the user should get an alert dialog.
The message should be, are you sure you want to delete?
And then the title then I said this.
I want to be this danger.
I can I give the positive button the text.
Yes.
And then.
If I say let's go, then I'm going to call the task list.
Which is the function that we get from the task list itself, which we just created, right.
So this function here.
And then.
I have the negative button, so if that is the case, the dialogue interface will just dismiss.
So we will just get rid of the alert dialogue and then we, of course, need to create that alert dialog.
We make it cancelable and we show the alert dialog.
OK, so this is something that we have done multiple, multiple times, so I think it's OK that I just
pasted the code in here.
If you want to know more about that, check out the videos on other dialogues that we have who have
a full demo here in this course.
OK, so then we can now implement the actual code for deleting something.
And which button shall we call for this?
Well, let's look at that.
We can see we have this delete button here that is used and the delete button has the name Ebe Delete
list, so let's implement that.
So if the holder of that item view, that I.B. delete list set on Click Listener is called, then I
want to call alert dialog for the littlest at the position.
And the model.
That title.
All right, and then inside of this alert dialogue, we do the actual deleting, right, so we call
this the task list, which then calls this task list activity function, which is the task list, which
then in turn deleted.
Right.
Removes it at the position and then updates the entry.
So now let's test it again and see if we can actually delete lists now as well.
So that we are approaching Menasche.
And let's wait for the boards to load the we are bought with image.
That's the latest one.
I actually want to read the littlest one, too.
Yes.
And it's gone.
It's like the South Park episode and it's gone.
So not a suit again, alert bam, all are gone and we can see only our list is there.
OK, so now you see how you can edit and the littlest so you can add new lists.
But what's even more important, of course, is to have cards here as well.
So here, let's see how we can add cards to this and we will still have a bunch of cool new features
in the next few videos.
So be prepared.
Thanks a lot for still being with me.
See you in the next one.