All righty, welcome back.
In this video, we are going to check out sequel Light or better said in this video, we are going to
check out the preparation for the sequel Light Demo, which will be the next video, because I have
this little application here, which I prepared, and you can see what it does.
So let's have a look at it first and then let's see how it's built from a structural perspective, some
from the UI perspective.
And then we are going to look at the database specifics, because what we are using here is an item
adapter, which is, again, a recycled view adapter.
So we have seen recycled use before and we're also using pop ups here or dialogs custom dialogues which
are going to be created.
So let's look at this.
We have this little application I called the secret demo, but what it really does is it's towards employee
data.
So we have the name and email ID of that employee.
So I'm just going to enter something here.
So my name is done upon Utah and my email address will be test at.
Test to come, and once I click on this add record button, it will be there.
So this entry is here now in order to test whether it's actually permanent, let's close the application.
And let's run it again.
Because that's why that way we can check if the entry is actually permanent and that we are.
So the entry is permanent.
Now you can see this is the line.
Where we see the name, the email address, and then we have two buttons here, so this one is added.
And we can update a record, and this one is delete and we can delete a record.
So first let's update a record.
And here I'm going to change the name to, let's say.
But U.K. and then a press update and let's see, OK, it's updated here and now let's close the application
again just to see if that actually has a permanent effect.
And we are.
So it does have a permanent effect here and we can add more records that cannot be blank.
So let's just enter something in here at this record.
And you can see we are using a very basic functionality here.
We don't check whether the email address is a correct email address from its format, perspective and
so forth.
But we're just entering stuff in there.
OK, so we can see now we have this list of elements and if we enter a bunch of entries in here, it's
going to still work perfectly.
So let me add even more just so that we have enough entries.
Actually, I need to name here.
So just we have enough entries so that we can scroll here.
So you can see this is a list view here at the bottom, which is a recycled of to be more precise.
And we have a bunch of entries now.
We can delete them and this screen pops up.
So you can see.
Are you sure you want to delete it?
I'm going to say yes and it's gone.
So you can see we have two different types of dialogues.
One is for the confirmation when we delete something and the other one is in order to edit a record.
All right.
So update a record updating it.
You could see record updated.
So a bunch of code surrounding the actual fundamentals of CircuLite that I want to teach you.
But I still think that this is a great demo that you can use whenever you need the code, because this
was just plainly the crude operations crew sending for create, read, update and delete.
And these are the things that you are going to require throughout your career, at least if you want
to be a developer.
Right.
Because you will need to do these things regularly.
That's why this demo will be amazing for your purposes.
You will just be able to reuse the code from here and apply it for your examples.
So let's look at the surrounding things first before we look into the database handler and into how
the database stuff itself works.
Therefore, we need to look at the layout first so we can see the layout is generally a toolbar and
then include so include as content main and in the content main, that's where we do all of this name
roll.
So then the actual text for the name a text.
View and an added text to text, you had a text text with just the visible, visible text, so to speak,
and to add a Texas textual field, which you can edit the text, and then we have an add record button
or just a button which says add record.
And once we click that, well, we'll add something to the list, which then will be updating the list
to you that we have here at the bottom, which is a recital of you.
All right.
So next thing is the items from let's look at the individual items that we have here.
So we have a TV name, so text you name then just to text you, then give it a proper name.
It's just an empty space in between then the next year, which is just a colon, very basic.
Then TV email, which is the email address.
And then we have this I've added which since for image to view, edit and image view, delete.
So if I want to see it in Caudwell you can download it, but you can see we have three text views,
then we have an image for you and another image for you which contain these beautiful little buttons.
And they have ID so that we can talk to them by a code.
Then we have this dialogue update, which is our custom dialogue, which we use in order to update the
record there, we have submitted the update, regular text.
Then again, a text view and a text field or an edited text, so to speak.
And then here we have a linear layout where update and cancel are all the way up to the right.
You could see it's TV.
So text views and that's code while you can download the code anyways.
Right.
But what's interesting here is that we are using linear layout and the gravity is towards end.
And as far as I know, we have not used and yet, which just means that we position stuff towards the
right.
OK.
And of course, this is not this field here, but it's actually when we added these two textfield,
which are positioned towards the right, that's what happens via gravity and.
All right, the next thing that we should look at.
Is the item adapter, so here we are using an item adapter and you should check out the adapter or in
general the recycler view video, the result of your demo, if you want to understand better what's
going on here.
But basically, we are inheriting from as a recycled adapter and we're creating an item adapter, which
requires a context and an array list of a class, which I called MPLX model plus.
We're going to look at that later on.
And then we have the uncreate view holder, which we overwrite and here we just inflate the individual
item wrote.
Then we have the unbind view holder, where we bind every individual line with the correct name and
email, which means every single entry that we have here will be updated, at least to name and email
will be updated.
And you can also see that the colors are.
Changing, so every second one is great.
Every second one is white.
That's what happens with these two lines of code.
Then we have this holder with said on a click listener.
So we have inside of our holder, which is this one here, the view holder.
Now, if you want to know more about the holder, you can check out the class.
Maybe we should do that first.
So we have this view Holder, which inherits from the holder of recycle of you.
And in there I have five properties or thereabouts, so to speak.
And one of them is the linear layout in the text, your name, text, your email, text you added and
I've delete.
So linear layout.
Maine is going to be the whole row here.
All of that is a linear layout with the whole row.
And as you can see, we have a text you name takes you email, text, you edit button and text, you
delete button.
And all of them are inside of this view holder.
And, well, we need them in order to access those, so if I want to, for example, change the text
of one of the items, well, I can see and read the item name and actually change our view there.
Our text, you name text.
The same goes for the email address, then for the color.
Well, the changing them.
And then we have the Ivy edit, which is our image of edit once we click on that.
Which just means this button here, once we click on this button, we want to call the context of that
record dialog item and inside of context.
Well, what is context?
Context is main activity.
So inside of main activity, we have this method called update records dialog.
And we will look at that later on, because here a bunch of stuff is going on, so that's why I want
to do it in the next video, then we have I've Delete, which simply calls to delete record alert dialogue
and then delete it.
And of course, as always, we overwrite the get item count.
So that's the general approach that we have seen in the demo as well.
There's not much difference except for that.
We're talking to multiple items now instead of just one item within our list element.
So within an individual list item.
But other than that, this of is pretty much the same.
All right.
So this was the preparation and I would say and the next video, we are going to check out our main
activity, our MP model class, which is very basic, and our database handler, which is not so basic.
That's why I'd say we cut it down into multiple videos.
So see you in the next video and make sure that you understand the stuff that I explained in this video,
because this is really just repeating what we have learned so far, because it will make things easier
once we actually go to the next video.
So see that?