So now let me talk about this ELSE IF statement here again because I think it is necessary for you to
understand exactly what's going on here.
So here we are saying that as if the key equals animals type and this means that if they use it has
actually interacted with the animals type.
So let me actually show you the emulator.
So now as I said this is our emulator and our application is running on this emulator and here as you
can see the key is actually animals typewrite.
Here we are saying that if the key equals animal type and if the user actually interacted with the animals
type then it's going to execute this LCF statement here.
Right.
So now let's actually look at this LCF statement.
So inside this ELSE IF statement a block of code as you can see if you have actually a string set light
and in Him is animal types so if you have a set of string values and the name is animal types assignment
operator.
So I referred to the name of this shirt the preferences object that we actually receive as an argument
from this on shows preference changed Mefford so shared preferences that gets things set.
So by calling this method gets things said we can actually get our set of string values from these shirt
preferences.
And we passed the key Alamance thought in order to specify that from which component we want to get
these values from these animals type if you want to actually get these actually values.
So now if I actually go inside these quotes underline preferences that makes them a file as you can
see we have this multi-select list preference here.
And we actually do pro-white that are key attributes for this multi-select preference in order to interact
with this multi-select at least prevents it from Florida of course.
And now let's actually go back into our main activity the java file here so Chaudry for analysis that
gets said the plastic animals underlying tarp type come on and for the first value we passed the value.
And that it's going to actually assign our animal the value of the animals type to these animal types.
String set.
So if so here we actually created an if statement.
So if the animals type is not equal to all and animal animals type animal types that size is actually
greater than zero if for example they use it at least selected one of these checkboxes as you can see
here if you use that actually to check out one of these checkboxes.
Then as you can see here if I click on OK here now it's going to execute this statement and it's going
actually just.
You are referring to this my animal Quest fragment that the type of animals inquiries and we passed
this shirt preferences in order to get those values.
And then we actually reset the quiz.
So my only quiz AFFREIGHTMENT that really said animal quiz.
And here we have actually an else statement as you can see here.
So if the user has actually if use a do not does not want to actually have these wild animals or tame
animals but inside the quiz OK if they use it does not want to actually select either of these options
and then click on OK here then it's going to actually execute this Else statement.
So now let me click on OK here.
As you can see and notice one type must be selected right and divide elements is the default values
Top Chef preferences that editor.
So as you can see here you are actually creating an editor object shared preferences that editor editor
assignment operator and and here we are actually referring to these shows.
Preferences are objects that we receive as an argument from dismiss it as you can see here.
Right.
So Sheft references that edit.
Right.
So now that we actually are.
Now we want to actually create an editor object in order to put our default value into our quiz.
Right.
So now as you can see animal types that at.
So you want to add value to these animal types set.
And here we call the Smurfette get strange and we passed this value or that string that default underline
animal underline type.
So if I actually hold the comment here on my keyboard and click on this value here as you can see disvalue
is this right here right.
Default underline animal underline type wide underline animals.
So this value is going to be the default value of the type of the animals that you want to have inside
the quiz.
So now let me go back inside RMI an activity that have a file.
And here again refers to the name of this editor object.
So editor that put strings set and we passed the key and then we passed these animal types set.
Right.
And then we called editors that apply.
So in this way we can actually put the animal types into are actually what cookies.
And then we went to use that actually do not doesn't actually check these checkboxes.
And and when he or she clicks on the OK here then it can actually provide a default animal type if it
is actually wild animals for our quiz.
Right.
And the editors that apply and then we actually should host a message to the users show so toast that
taste and we pass the context.
Main activity that this.
And then we pass this message art drink a toast message.
And now let's actually let's actually hold the comments on a keyboard.
And if you are using I mean machine just hold the control on your keyboard and then click on this value
here.
As you can see it was the message.
One type of animals must be selected.
The default value is wild animals.
And now let's actually go back into our main activity that java file.
And here we are specifying the duration of this message.
And then we call the show my feet on this object.
So now as you can see here.
Let's actually look at this ELSE IF statement as you can see here.
We checked this if statement for the keys that are equal to guesses.
We actually take these as if statements for the keys that are equal to an animal type animal type as
you can see here.
After the curly brace of this key as you can see here after the end in calibers of this ELSE IF statement
right we actually created another Else statement here.
So else if that equals.
Underline it.
So here we are taking that up whenever the user for example is changing they're actually the front of
the application as you can see here.
So whenever the user clicks on these forms for queries and when he or she changes one of these or when
he or she changes they quit the front of the quiz.
So for example chant 5 and now it says new changes are applied.
And now if I go back as you can see here the phone is changed right.
So else if that equals cuius underlined font then we call this object my animalcules fragment that modified
cuius font shirt preferences and then we refer to this object my animalcules phone that reset animal
quits right.
And then as you can see here you are actually creating another as if statement.
So this LCP statement is full of and the user actually changes the baculum color of the quiz.
So elf if cheap that equals Q is underlined by going on Underland color.
Then again we refer to the name of this fragment object as you can see my animal quest for argument
that modified by going on colored shed fences as you can see here this object is an object that he created
from this classman activity fragments right.
And by creating an object from this class we can actually access the methods that are inside of this
main activity fragment class.
And that's why you can see that we can call these methods here right.
So you already know about this stuff.
I actually talked about these are classes and object oriented programming.
And when I actually taught you the Java programming language.
So my quest for argument that modified by Canonical of shirt preferences and my animal cuius for that
the recent animal is right.
And here finally we are actually showing our Toastmaster the user Sotos that make just make text the
main activity that these are that string that TOSed message as I can see here we are actually referring
to this text message.
So now let's get you to change this toaster message to actually change change message bright and then
as you can see we are actually specifying the duration of these Toastmasters and then we are calling
this Shoma if an undisclosed object.
So now as you can see here we haven't still provided us an Austrian resource for this change message.
So now let's actually just copy disvalue here and now let's actually go inside our strings that exemplified.
And here let's create a string of stores and for the name just paste that value here change underline
message and enclose this tag.
And for the value just type in here it changes and new changes
are applied.
Right.
And now let's actually go back into the main activity that double file.
And now as you can see here the error is gone.
Right.
So hopefully that makes sense.
As you can see here let's look at this here again unshelled friends change Meffert.
We actually assign the value true for settings changed boolean variable.
We are checking that if the user actually interacted with these guesses here with a number of guesses
options as you can see here then we are going to execute this line of.
These lines of code here first we can actually modify animal rules based on the users actually choose
based off based on the users number of guesses options as you can see here for example the user wants
to actually have a Fargus options or maybe the user wants to have sex gives options.
So based on these decisions based on these values we're going to actually change the number of options
that we have inside our quiz.
Right.
And now as you can see here we are here we have this statement and we are checking that if that user
has actually interacted with the animals type as you can see here.
So if you have two checkboxes here and we have also these at if and if else statement here Enceladus
LCF statement that you can see in order to check that the user has actually checked at least one of
these checkboxes or when you went to use that.
For example did not text actually of one of these checkboxes as you can see here.
So if are actually controlling these decisions here as you can see here and here we have this.
Else.
Else if statement for them and they use that actually changes the format of the of the taste of the
patents that we have inside our coolies as you can see here.
So if we call my animalcules for arguments that modify cuius font shirt and says My animalcules for
argument that reset animalcules and then we have this Ellis statement that equals It is underlined by
an underlined color as you can see here.
So it does Elsy statement.
Here is what I actually when the it changes the background color of this application.
As you can see here the back uncolored of this quis and we actually calling that we are actually calling
these methods.
And this my animal Ahlquist Fleischman object.
And we are finally set the reset in the quiz my animal quiz fragments that roosted animal quiz.
And finally we are actually showing this message to the user to toast the toast that makes toast main
activity that these are that string that change underlying message tostada letter short that shock.
And now let's you to go inside our uncreate Smurfette here.
As you can see.
So now let's actually I'm going to get need to actually to paste in some more lines of code here.
Because when the application is started up Vinita and when the uncreate Meffert is actually called we
need to actually get some of those changes that we actually saved to the shared preferences and we need
to actually apply them to our quiz.
So for example now back in uncolored is yellow.
Right.
And if I click on this by here as you can see we have six Yes options right.
And if we actually close this application here.
Now let me close these applications and if you want to actually open this application here again as
you can see we need to actually get those changes from the shared preferences here because at this time
the uncreate method is going to be called and we need to actually get those changes that is saved to
the shared preferences.
So now I'm going to paste in some lines of code here.
Inside is uncreate Smurfette inside the main activity class and then I'm going to explain to you of
what's going on here.