All righty, welcome back.
And this video, we are going to start implementing the due date functionality, so let's get started
with what you can see here.
So when we click on it, we can select the date and then we can see that the date is there.
And once we update, the date will also be put into the database.
All right.
So let's get started.
Therefore, first of all, we should go to our cart model because now we also want to store the data
out or the due date here as well.
So let's add a new entry, which will be vital due date, which will be a long that I'm going to assign
zero to.
OK, so I'm going to store the date as a long Pellew because it's easier that way.
You just get a loan value and then you can transfer that back into a readable date, so to speak.
All right.
If you do that, we, of course, need to add a line here as well where we say source thawed, read
long and.
That will allow us to read the due date and then also we need to write it so here right along with the
due date.
OK, then we can go to the details activity, and here I will create a new global variable which will
store the date so private var m selected due date merely.
Seconds.
We'll be along.
So I'm going to store it in milliseconds, so this will be huge value, but that's why we use long here,
but we don't really need to take care of that too much.
We all just transferred or converted accordingly.
Next, we will need a data picker, and I'm not going to create a new function down here to display
or show to date Picker and by the way, you can just simply use the date picker functionality that we
have used an earlier project.
All right, let me show you what the day picture will look like, so we need a calendar instance first.
So I'm going to call this one, see, then I get the year from the calendar.
So calendar year, the month with calendar that month and today with day of month.
And then we can create a date, bigger dialogue, which will have an on date set listener.
So that will wait for us to set the date.
And when you set the date, you will get a view the year, month of year and day of month.
And we then used to the information to store the day of month.
If day of month is less than 10, we say zero day of month.
And otherwise we just used the day of month because we don't want to display one, two, three, four
or something that that we want to display to date with zero one zero two zero three and so forth.
All right.
Then we get the month of the year and they will do the same thing.
Right.
And then we get the select date and put away.
If you were wondering what the code looks like here.
Then we get the select date, which is day of month, day of year and year, so basically those things
that we prepared here, which were just another way of preparing the or displaying the data, and then
we just used that as the selected date.
And that will be a string, of course.
Then we select that to be the TV select due date text.
So and the activity card details, we have this text you called TV Select Due Date, and that's the
one here.
This one will then be populated with the.
Select data date that happens when the date that listener is called, right?
So once we set the date and then we need a simple date formatter in order to formatted, we used to
asdf then we create a date based on the idea of the past.
So we parse our string into a date and then we can set that date to be the one for our selected to date
in milliseconds because time will return a long value, which is the number of milliseconds since the
1st of January.
Nineteen seventy had zero clock.
Zero minutes.
Zero seconds.
All right.
And then.
We pass in the year to month and today day, all right, so this is what the day picture dialogue will
do all of the code up to here and then we say, OK, let's show the date picture dialog.
OK, so that's what this show date picture function does.
It's nothing new.
We have seen that before.
We have used it before.
This was just a quick refresher.
All right, and when do we want to display this take picture or when do we want to call this function
here?
Well, once we click on the text, you OK?
So let's go all the way up to our own creative function here and in there.
I'm going to add an all click listener for our text view on the scores select.
To date, this one here.
And let's set in on a listener here.
Which will then call the show date, pick her function.
OK, so it's this element right here, select to date.
Once we click on it, we want this.
They pick her to appear.
And, of course, in our card details activity, we have this function called update.
Card details, this one here and there currently we are creating a card, but we are not passing the
date as well.
So that's what we need to add here as well.
And that will be our team selected due date milliseconds.
OK, so now our card will get this additional information, because if you look at the card, that's
what we added this due date for.
And then, of course, we want to display the due date if it was already set before.
So if it is in the database, we want to set a due date, OK, and that should be done in our own create
method.
So I'm just going to put that up here where I'm just going to say I'm selected.
Due date milliseconds should be M board details DOT task list at the M task this position.
Add to cart.
At the guard position.
And Dot Tudorza.
OK, so pretty long statement here, you see they don't get shorter.
Luckily, we don't have any objects underneath carts that would make it even longer, but that's the
due date in milliseconds.
And then what we can check is if the value is not null or zero, better said.
So this case, it's actually the zero.
So I'm selected due date in milliseconds.
If it's greater than zero.
We know that there was a value in the database.
OK, if it's zero, then it's the default value for the card.
So there was no due date set ever.
OK, it's just going to be zero here.
All right.
But if it was created in zero, we know that there was a value set and then we want to display this
value as the text.
So here we want to, first of all, get a simple date format object, which will be.
Simple date format with a specific pattern that we want to use, and I'm just going to use this pattern
here and day, day, month, month, year, year.
Of course, you have different patterns that you can use if you want.
I'm going to use the local.
English.
So here it's with a capital L. Lacayo thought English.
And then I can use this simple date format in order to format my unselected due date in milliseconds
to a readable format, so to a format that fits this pattern.
OK, so selected date will be our simple date format, that format.
So we use that simple date format object that we just created to format our variable and selected due
date in many seconds.
But of course we need to make a data out of it.
So let's create a date object from it just like that.
And then that will now give us the date in a readable format that we can then use to use it for our
selected to date dot text is equal to selected date.
OK, so this code here will take care of assigning the date to this text field if it was in the database
before.
So if we had stored the due date beforehand.
All right, and at that point, we should be able to test this and see if it actually works.
OK, so there we are.
Let's check out our board with image.
Let's go to our card one.
Let's select due date.
OK, so the dialogue opens up.
This is very good.
That's great.
So let's select a date.
Here.
Due date is the 11th of March.
It's updated.
All right, great.
We are back in our cart here or the cart lists, and here you can see when we get back to the cart to
date is in fact, collared here.
So we can, in fact, see the date here.
Now, let's check out our boards here to see.
If the date is in fact there, so we have the cart.
And we can see the due date is there, so it's this value here.
And you can use a long to date online converter Époque converter in order to.
Calculated, sometimes timed to human date, and we can see it's Wednesday 11th.
All right, so that seems to work.
That's awesome.
So let's go over to the next video where we can then drag and drop Cartes.
So see you in the next one.