So here inside this article Mefford Let's actually create an if statement so if and then say The Apprentice
is just typing.
Here is storage.
Permission granted.
OK.
I actually referred to the name of the Smurfette and then let's actually open and closed this if statement
by using these curly braces and opening curly brace followed by our closing curly brace.
So as you can see here I just created an if statement and here I'm saying that if it's stored it's permission
Grant Granted if the user has access actually if the user is allowed to access the storage then we can
actually execute the lines of code that are going to be inside this if statement.
OK.
So I told you that it is very important that you specify whether the user is actually allowed to access
the storage or not.
Right.
So here we are actually asking that permission.
So now inside this if statement I'm going to paste in some lines of code and then I'm going to explain
to you what's going on here.
So as you can see here these are the lines of code that I pasted here.
So let's actually look at this line of code here in line number one hundred and fifty six.
So here I actually referred to the name of this at a least file pathnames.
Right.
And then I put an assignment operator here and then I put the new keyword and an endless in here.
So here I am actually creating an empty arii that actually that can actually hold values of types 3.
Right.
So I actually initialized this at a file pathnames.
OK.
These are a list and then as you can see inside the angle brackets I specified that the values that
are going to be assigned to this flight path names here can only be of types 3.
And then in line number of 157 as you can see I created actually a variable of type fight.
Right.
So remember that I told you variabilis are placeholders that can actually hold the values of a specific
type.
So here when I actually just put this Q-Bot here filed with capital F here I am specifying that the
values that are going to be assigned to this variable are going to be of type file.
So file file path.
So the name of this variable is flightpath which is actually like Foyt right.
And then I put an assignment operator here and then I put this new keyboard.
So here I want to actually create an object of type find and I want to assign that object to this file
path.
So new file here I want to create an object of type find and an inside the apprentice's as you can see
here.
First of all I need to specify a directory environment that get external storage public directories
so here we need to specify that up which path you want to access able to access the external storage
public directory.
OK the public directed that can be accessed by the user.
So and that inside the apprentice is here first of all I specified that I'm on to access the pictures
directory so environment that directs to the underlying pictures.
Now let me show you the Android device monitor as you can see here.
This is our Android device monitor and inside this emulated there inside this fall there is zero.
As you can see we have these pictures here pictures folder.
So here I am accessing these pictures there.
And then here as you can see for this second argument here I am actually specifying the name of the
folder that are able to access.
So as you can see here inside this is the directory we have this for all their animal images.
Right.
So I want I need to actually specify the exact name of that folder.
So as you can see the exact name is animal images.
So I just put this value here.
Animal images are right inside the goats.
And now with this foil Pamphila have now actually contains the address of these animal images they're
inside the directory say the pictures directory.
Right.
And then here as you can see we have another IIF statement.
So if file path.
So here I am referring to is a variable that holds the the address of these animal images folder.
So a file path that is directory.
So it is if it is actually a directory.
So as you can see here inside this Android device monitor here we are accessing the pictures directory
right.
So it is actually a directory.
Here we are checking that.
It is actually a directory or not.
Right.
If flightpath that is directory at as you can see here you can see these and logical operator.
And if these file path is not equal to null.
OK.
If this file path is not equal to or not and if it is actually our real directory that we can access
in that case we're going to go ahead inside the curly braces of this if statement and we're going to
execute the lines of code here.
First of all inside this statement as you can see I actually referred to these files right here.
So as you can see I actually created these files are a.
Here there's actually the scroll to the top.
I actually created this at a file here in line number 62.
I just declare this.
I looked at a here and there is.
Let's actually go inside our Smurfette on click here.
I am actually initializing these arii.
So fi's assignment operator flightpath.
So here I am actually failing to find power here which is of type file.
Right.
That list files.
So here I am actually getting the images that are inside of these that are inside of this folder.
Animal images.
These are actually files as you can see here right with the P.A. format.
So now I actually created a file is great and here are going to actually get at least FAE's least files
means.
These are actually images these files that are inside these animal images by actually calling the Smurf
at least Foyles we can access these files that are inside of this folder and we can actually assigned
these files to these files.
Great.
So now these are a files actually holds these files here that are inside of these animal images.
And then here we actually created a for loop here.
So for each index is actually equal to zero.
So here initially I actually created a body of type integer and then I assigned the value zero to the
index.
And here I am specifying that if that does follow up here is going to be executed until the value of
this index is less than the value of the length of these flights.
Right.
And then here I am specifying that if after each execution of this for loop we're going to actually
add one value to the index variable.
So let's actually go inside this for a loop here and let's see what's going on here.
As you can see in line number of sixty five I actually referred to the name of this at a here file path
names as you can see this is actually an alias right file path names dot at.
So here I want to add some files to this file pathnames which is actually an Aurelia's.
And as you can see here I just referred to the name of this at a Foy's sub index.
So I want to get the specific value that is inside of the specific index of this tree that gets absolute
path and in this way we can actually get the absolute path of these files that are inside of these animal
images.
Right.
So here because we want to actually show these images through the user it is very important that we
actually access the absolute path of these files.
Right.
So that's why we actually created this for loop in order to access or in order to get the absolute path
and then to actually assign that absolute path to this file pathnames Aurelia's.
So file pathnames that add.
And then I refer to the name of this Aure sub index dot get absolute path.
So for example initially the value of this index variable is zero.
So Foyle's sub zero as you can see here is when I try to go inside of this at a Foyle's and it's going
to actually get the first value that is inside of the index zero of this era.
And it's going to call this method and that's why you get absolute path.
So for example the absolute path of these imit image bear.
So this bear is inside of the index zero of this at a.
And then it's going to actually add that value to this Aurelia's file pathnames.
And it's going to continue executing this for loop until it reaches to the last image right Tiger that
PAGG.
So now as you can see after the end uncurl curly brace of this if statement.
Now I'm going to actually pasting some more lines of code here inside this if statement is stored is
Permission granted and when actually pasting some lines of code here and then I'm going to explain to
you what's going on here.
So as you can see here these are the lines of code that I pasted here and now I'm going to explain to
you what's going on here.
Exactly.
So here we have a for loop right.
And initially as you can see we created a variable of type integer and the name of this variable is
index.
And then I assigned the values zero to this variable right index.
And then here we actually created a condition that determines how many times this for loop is going
to be executed.
So this for a loop here is going to be executed until the value of this index is actually less than
the value of the size of this file path names are a list.
Right.
So here we as you can see this is actually an Aurelie slight file pathnames that size and this for loop
here is going to be executed until the value of this index is actually less than the size of this Aurelia's
file pathnames.
And then here if you are saying that after each execution of this for loop it's going to actually execute
this is going to actually add one value to the value of this index variable.
So now let's actually go inside the curly braces of this for a loop and let's see what's going on here
in line number 172 as you can see we have actually a final variable which is of type image view.
Right.
So here we have a final which is actually a constant right image view and the name of this rowdier bill
is in his view.
And then I put an assignment operator here and as you can see I am actually creating a new object of
type image view here.
And I want to actually assign that object to this variable which is a fine image view right.
So assignment operator new image view.
And here for the for the argument of these constructor as you can see here we need to pass this context
main activity that this and then here I referred to the name of this object image view that said E-Myth
you are.
OK.
Image view that set image you are.
And inside Apprentice's as you can see I refered to the name of this class.
You are.
That parts I want to actually parse something right.
So inside Apprentice's I need to specify the value that I want to parse.
Right.
So you or I that parse file pathnames Slahi it as you can see it is this Aurelia's the file pathnames
actually contains these files these images.
So now let me show you the.
The Android device monitor.
So just click on Tools Android Android device monitor.
So now let's actually wait and let's see our Android device monitor here.
So inside these thought this folder inside is emulated.
And inside is a folder zero as you can see if you have these pictures directory right inside these pictures
directory as you can see we have these animal images folder and inside this animal images folder we
have these images.
Right.
So these are the files that are actually inside of this file path names are a list.
So I want to actually parse these addresses these Foy's and I want to actually assign them.
I want to actually set that image that specific image to image view as you can see after each execution
of this for loop you are actually creating our actually an image view.
Right.
Every time this fall here is actually is executed an image is actually created.
And as you can see here these lines of code here is going to be executed every time this full loop is
executed.
Right.
So for the first time that this is executed the value of this index is zero.
Right.
And it's going to actually look at this line of code here.
You are either parce file pathnames So this is an early release that actually contains these images.
Right.
That's good.
So if you want to get some value and we need to pass the index of that specific value so index the index
is zero initially right.
So it's going to actually get the beer as you can see here the beer here and it's going to actually
set that beer image to this image here.
So in order to actually parse that specific image that we have inside the SD card we need to actually
use the image you or I used this method in order to access the images that are inside of your SD card.
So that image you or I.
You are either part file pathnames that get index right an image view.
Let's look at this line of code here 174 image view that sets labeled products.
And here you are specifying the layout problems that and the height of our image.
OK so image view that certainly out perhaps new linearly out.
So remember that I told you when you are specifying the layout problems inside the pantheists you must
specify the parent of your image view.
So our image view is going to be inside our linear layout.
Right so that's why this linearly out here is the palette.
So new linearly out that lay out plot arms and for the width I assign the value of five hundred and
for the height I assigned to the value 500.
Right.
So it is going to be there width and the height of our image view.
So here it is very important that you specify the parent of your image view.
Right.
So now let me show you the emulator as you me I actually opened the app for free.
Now let me actually click on this button here.
Allow access pictures in the cart as you can see.
You can see these images right.
So these images are actually inside a horizontal linearly out right.
So because these images are actually inside the horizontal linear layout it is very important that you
know that the parent of these image views as you can see here are actually inside or actually are linearly
out like a linearly or horizontally.
So that's why I said linear out that lay out perhaps.
And I specified the beach at the height of my image view and now as you can see in line number 176 I
created another constant which is of that integer.
So final point and here I actually named this valuable as actually.
And then I assigned to this index to this already.
So here we actually get this index from this for loop.
Right.
So I actually assigned this index to this I.
So now because I want to actually use these index inside are anonymous in a class.
I need to I actually must provide an order constant in order to actually get the value of this index
because I cannot access the value of this index in inside this anonymous class.
So let's just actually look at these lines of code here and then it will make sense.
So here as you can see I am actually referring to the name of this variable image view right which is
of image view image view that said Uncle Clisson or so I am actually providing a lesson there for these
images in his views.
So for example when the user clicks and is cow here as he can see an image is appearing here right.
So I am actually creating a listener for this image we use here so that something happens when the user
clicks on these images.
So now let's actually go back to our Android studio.
So here as you can see image view that said Uncle listener new view that unclick listening.
And as you can see here I am actually creating an anonymous inner class that actually is implant is
implementing this uncle because an interface.
And as a result this anonymous class must actually provide an implementation for this uncle Merfeld
that we have inside this uncle class in an interface.
So that's why you can see we're actually overwriting this method here.
So Pablito void unclick view.
And then inside the Smurfette as you can see I actually fear to this image to each other object.
Right.
So if I actually scroll to the top here as you can see we actually declared this variable which is of
type image switcher as you can see here and the name of this variable is image creature and it inside
these uncreate Smurfette you actually initialized this image.
So each hour here in line number one hundred fifty six.
So Image Sutor.
Assignment operator and then here I am casting this image so we show to our imagery to object find view
ID or ID that image switcher and that he and as you can see I am setting up a factory image suture that
says back to the main activity that this and we must do this in order to create an animation as you
can see here.
So Image Tsui shirt that said animation.
And here I am setting the animation as you can see here Art.
And in that slide in lift and here set in animation right and then he in line number 143 here I am sitting
there set out animation.
So this happens when the image is going to be disappeared from the front the screen.
Right.
Image switcher that set out animation animation.
That looked animation.
And for the first argument I passed this human activity that this and for the second argument I passed
this value Android that are that.
And in that light out.
Right.
And then here inside our undercarriage method as you can see let's actually scroll to the top here.
Inside our uncle Meffert inside this uncreate Smurfette as you can see here.
As you can see here I am actually said the image you are on to this image switcher because you want
to put the image we use inside.
I want to actually put I want to show the imagery inside our image through it.
So when the user clicks on this for example image or cat as you can see a cat appears here.
Here we have an image switcher.
Right.
And here we have a horizontal linearly out that actually contains images image views of these animals.
As you can see here.
So image that set image you are right.
So whenever the user clicks on these images as you can see here for example this appeared this unclear
if it here is going to be executed image through it.
That said as you are again we are parsing this image from the from the SD card.
So we need to use the image set image you RMF it.
So you are either to parse file pathnames.
Here I am referring to the name of.
These are a list file pathnames that get the image that it is that is inside of the index.
So now you understand why we actually created this constant here which is of type Integer.
I created this constant here because of that integer.
And then I assigned this index here to this.
Because we cannot actually access a variable outside of this uncle if it is Uncle method here needs
to actually access a constant not valuable.
So that's why we created a constant here and then we actually assigned this index to this.
And here inside is anonymous in a class we can actually get the value of this ID right.
As you can see file pathnames that gets by.
And that's why you can see that when I click on this image image views as you can see here the specific
image is actually appearing here.
And finally after the ending curly brace or after the end in practice of this satanically listen and
Minford as you can see here I am actually I think that image is linearly held horizontally that view
image view right here we are saying that if that image is actually clicked then it's going to put that
image inside this image through each other.
But we must actually put this line of code here before the end in curly brace of this for a loop so
that when ever that this fall if he's executed our image views are actually appearing here right on
the image views are appeared here.
One by one you can see these images one by one here.
So I am actually we must actually put this line of code here linearly and horizontal.
Here I am referring to the linearly are horizontal.
That is the parent of these image views as you can see here.
And then here I am adding this image to this linearly or horizontal.
So that's why you can see that these image views are inside of this linearly horizontally.
We must add them in here to this linearly outhaul is on.
Right.
So I think that's actually did on our project here.
And let's see what happens.
As you can see here at the port at the bottom we have this error.
So we must close the Android device monitor first.
Let's run our project again.
So as you can see here our application is actually to restarted.
And now let's actually close this application let's run our project again.
So now as you can see here our application is running on the simulator.
Now let me make this virtual keyboard keyboard he had disappeared.
Let me scroll down here.
Let's actually click on the spot and allow access pictures in SD card.
And now you can I see this you can actually see that we have this image we use Enceladus linearly out
horizontal.
And if I actually click on one of these image views here as you can see we can see this image view inside
this image suture.
Right.
You can see the actually the animation slide in and slide out.
So I think that's enough for this application.
And if you have any question as regards these concepts that I taught you in this in these tutorials
please post the discussion in the course and then I do my best to answer all of your questions.
Thank you very much for watching and I'll see you in the next few Tauriel.