So now as you can see here these are the lines of code that I pasted here and now I'm going I try to
explain to you what's going on here.
Exactly.
So now look at the Smurfit here the access modifier of this method is Puplick and this means that this
method is going to be accessible from anywhere inside our project and the return type of this method
is void.
And this means that this method is going to return Nuffield the name of this method is reset.
Annabelle Quince So what's the purpose of this method when this method is going to be called.
Let me show you the emulator.
So now for example let me actually click on back here so as you can see here this is our quiz and now
I want to actually go inside these settings activity and here for example I want to change the background
color of my quiz.
So for example I want to change it to black and now as you can see here a post here appears and it says
new changes are applied.
And this means that are going to actually reset our animal quiz now when the user actually changes the
settings of the application.
You want to reset the animal always.
And we want to start up our quiz from actually knew from start at.
If I click on dispatch button here as you can see now that back uncolored is black and Ahlquist is now
reset.
So for example I can actually change the font for example to wander space them all as you can see here.
Now the format is changed now again our quiz is reset.
So when we actually change the actually the settings of our application we want to reset the quiz.
So we set animal cookies and in line number two hundred and eight we have actually a variable of type
asset manager.
The name of our valuable is assets.
So now let me show you the structure of the project.
So just click on view to Windows and then click on Project.
And now here at the right hand side you can see the structure of the project.
And here as you can see we have a folder called assets.
So if you want to actually access these assets for that because we have this tape underline animals
for there we have this avoid Underland animals for that.
And we have these phones for that right.
If you want to access this assets folder in order to access these folders.
So I actually created a variable of type asset manager and the name is assets.
And then I put an assignment operator here and I called the Smurfette get activity dot get assets.
So my favorite activity is going to give give us the activity and then by calling these get assets on
that activity we can actually get the assets for that that we have inside our project.
So now we have actually access this project to this actually for their assets.
And now by actually getting to these assets are valuable we can actually get access at these assets.
So it's actually a doubleclick undismayed activity fragment out of a file in order to make this area
wider in low numbers.
Two hundred and nine as you can see here are you referred to these all animals names list.
So let's actually scroll to the top here.
As you can see inside our class in line number 41 I actually declared this variable which is a type
place that actually accepts values of types 3.
And the name is all animals.
And these are all animals names list.
So this rally is going to hold all the animals names that we are going to have inside our quiz.
And if you look at our uncreate view Meffert as you can see here in line number sixty eight I actually
initialized this variable all animals all animals names least assignment operator new at a list.
Right.
So remember that I told you that list is actually an interface right.
We cannot directly create an object of typeless.
So because this is an interface and list actually has more Misfit's that other than an array of we actually
created a list in order to actually take advantage of those extra effets that list interface has.
And we actually initialized this list by using aerialist riced new Aurelia's.
So we're going to have an array list of values but the data type is list so that we can actually access
those extra efforts that this list has.
You can actually looked at the documentation of this list interface in say the Java doc.
So all animals names list right.
So let's actually scroll down here inside our Meffert reset animal quiz on here.
All animals names least that clear.
So I call this Meffert that clear on this list.
So what does this mean.
So whenever I asked what I want to actually reset our animal quiz Are you want to actually delete all
the animals names that in say the quiz and then you want to add the new Actually animal names.
So for example here for example the first question is actually peacock.
And now for example I want to change the Paglen color of the application to yellow and now are actually
arccos is reset.
And if I click on dispatch button here as you can see that the first animal is another animal of a sheep.
Right.
So this means that all animals names the list is actually cleared and all there are names that we had
in the previous quiz is actually cleared.
And now we have a new quiz with the new animals names.
So that's really important that you put this method here.
This line of code.
And then if you have a try catch block here.
So let's look at this troika's black and let's see what's going on here.
So try and inside the curly braces of this type like here as you can see here we have some lines of
code here.
So we have actually a for loop.
So for strange animal type and now as you can see here we are actually iterating over the values of
these animal types in Queens.
So let's actually look at inside our class at the top.
Let's scroll to the top here.
As you can see in line number 43 we actually declared this set here.
So remember that I told you that sets are actually again our interfaces as you can see here.
It is actually an interface but because sets can not have duplicated values we actually created a set
in order to take advantage of that extra feature set that actually accepts values of types 3.
Right.
And now the name is animal types in coins.
So now let me show you the emulator as you can see it actually to go inside settings activity and then
here.
Now for example you want to actually change the types of the animal as you can see here we have wild
animals and we have tame animals and for example I want to have only tame animals inside my quiz or
maybe even to have wild animals inside my quiz for example.
Right.
I can I should click on OK here and now as you can see here it says new changes are applied.
And now if I click on this page button here as you can see now you are going to have only wild animals
the images of only wild animals inside our quits.
So that's why I actually created this variable here which is I've typeset.
That actually is going to determine the types of the animal that we're going to have inside our quiz.
So this set is responsible is responsible for actually holding the types of the animals that we have
inside the quiz.
So let's actually go back into Andrex studio and now let's actually scroll down here and let's go inside
our research animalcules Meffert.
So this is our method.
And now I want to iterate over the values that that we have inside these animal types inquiries.
So here let me show you an important point here that inside the uncreate view method we haven't still
initialized these animal types inquiries actually said we are not going to initialize it here.
Later you will see that we're going to initialize that set in another place inside our code.
But for now just know that we haven't initialized these animal types in here yet.
So let's actually go back inside our Reset animalcules here.
So animal type is going to actually go iterate over the values of these animal types inquiries.
So this follow up here is going to be executed for each value that we have inside these animal types
inquiries.
Right.
And then for example for the first time this animal type is going to hold the value of the first value
of the first index that we have inside these animal types inquiries.
So animal type.
And now let's actually go inside it for look and let's see what's going on here in line number two hundred
and fifteen.
We have an array of strength values right.
And here as you can see the name is animal image paths in Queens.
So here let me show you the structure of the project again.
So click on the View tool windows and then click on project as you can see here.
This is this is the structure of the project.
And inside is as its folder as you can see here we have this folders tame underline anemones and we
have also this fall that ovoid underline anemones.
So this is actually our path.
First we need to go inside these assets for there and then if we need to go inside this for example
taint on the line animals animals and then for example I want to actually to access this you came on
the line anemones dash Dolfin that Pinti for example if you want to actually access this image this
image of the Dolfin first I need to go inside the assets folder and that I need to go inside this tape
underlying animals fall there and then I can actually access this value this image on the line.
Animals dash Dolfin that PND.
So that's what I did here.
So I actually created an array of string values and the name is animal image paths inquiries.
So this is actually the path.
Right.
And then I put an assignment operator here and I actually further to these assets here in order to access
the assets for that that we have inside our project.
So assets at least as we can see here assets that list.
So it's going to go inside these assets folder and then it's going to actually look at the folders that
we have inside these assets for that right.
And then I actually passed this value to this list animal type so by passing this value animal type
this is actually the lasting value to this list here.
It's going to actually give us the specific folder that we actually have inside our assets folder.
So for example if the animal type is tame on the line Alamance then it's going to actually give us the
least the images that we have inside this tape on the tent.
Tame underlain animals folder.
Right.
So then it's going to try to assign those values as you can see here.
Here we have an ad right in order to actually hold the paths of these images that we have inside our
four folders.
This on the animals or underlying animals.
So when I call these assets folder I can actually access this assets for that and I call this list folder
excuse me and then I call this list method on these assets in order to access the values that we have
inside our assets folder.
And then I pass the name of the folder that we have inside our assets folder.
So for example the name of the folder or the animal type is tape on the animals right.
Tame animals.
When I pass this value to the Smurfette least then it's going to give us the values that we have inside
our folder.
So for example it's going to give us these images the path of these images that we have inside our project
or for example if I pass the wild animals if that animal type is wild Underland animals then it's going
to keep us the paths of these images right inside our project.
And then it's going to assign those values to this animal image paths increase.
And now as you can see here let me actually double click on this main activity flagmen that have a double
tap here at the top in order to make this area wider.
Again we have another follow up.
We have actually an inner for loop.
So for strange animal image path in Queens is going to actually either rate all of the values of this
animal image paths which is actually this great.
So I want to actually get each and every image path that we have inside our animal folders so for example
now you can see inside the structure of the project.
We have this tame underline anemones and we have also this wild animal or wild underlain animals.
It depends on the use that which type of animals he or she wants to use in say the case.
So for example I can actually choose only tame animals not wild animals right.
In that case if you passed the actually the animal type which is actually tame animal as you can see
here we're going to have only tame animals right.
So it's going to actually give us the least of these images of these tame animals here.
And then it's going to assign that value actually assigning those values to these animal image paths
increase which is actually an array of string values.
And then here we are going to either rate over those paths over those values those image paths that
we have inside these for example tame underline animals and we want to actually execute this follow
up here for each and every value for each and every path that we have inside this list right inside
the same underlying folder.
So strange animal image paff inquiries iterate over the animal image paths the inquiries and as you
can see here all animals names list.
So now let me actually double click on this tab here main activity fragment or Java tab and here I actually
first to the name of this list.
All animals names list.
So as you can see here in line number two on the night I actually cleared all the values first and now
I want to add other values to this actually.
All animals names list.
So all animals names and they start at al-Ahmad image Paphian quis as you can see here dots replace
dot P and G with actually an empty value.
I want to actually start peon Jeevan I want to show this value to the user.
So for example let me ask you to show you the emulator as you can see we have no doubt Pendu here right.
As you can see people Pinguin fish flappy bird and goat.
We don't have paint Pinguin that P and G or fish that be being G or flappy bird.
That means you all go to the TNG you actually deleted the P.A. part of these images of these image names.
I want to show you actually when I want to show these values to the user.
So it is very important that you put this in I've got here.
All animals names start at and it's going I should add all these image paths as you can see here all
these images.
It's going to is going to be added to these animals named list here.
But the piano here is going to be deleted.
Right.
And now and we also created this Smurfette get the exact animal name effect as you can see here in order
to actually delete that part of the image that has for example an underline.
OK.
So we use these methods in order to actually delete the parts of the name of the image that we don't
want to show to the user.
So now it's actually double click on this tab here.
Activity fragment that Java.
And now let's actually go again inside this reset animal quis Mefford.
So as you can see here we have also the church statement.
So this caterpillar here is going to actually catch the exceptions that may occur.
And we want to actually access our image paths inside our project.
Right.
So we may actually access around image or are the Android device may not be able to actually access
the images that we have inside the project.
So in that case we have actually a catch block which is going to a church that exception and we're going
to actually plug our message through that actually Lockart.
So log that eat and that is animal Cooley's and the message is error.
And here we're going to actually output the real error message to they're actually locked.
So here are a list like let's actually look at these other lines of code here.