All right, so the next thing that we're going to implement is going to be pellet and Pellet is a helper
class to extract prominent colors from an image.
So if you look at it, it's the UI part of a jetpack here at the bottom.
Right.
So we looked at layout's fragments, animations and transitions.
Now we're looking at Pallot.
OK, so let's go ahead and Implementor.
Therefore, we're going to need, of course, to go to our Biltong Grill to activate the pellet.
So to enable our application to be able to use it.
And therefore I'm going to search for built that grill and the app specifically.
And here at the bottom, I'm going to add an implementation.
So these are all of the implementations that we added so far.
And here I'm going to add, Halit, it's this one here, Pellet KTXA.
My guess version is one zero zero.
And then I think this file so that I can use it in my application and then we can go over to Ardeche.
Details fragment because here I would like to make a little change to specifically this try block where
I just glide.
OK, so here we see we used into binding and so forth.
Now the cool thing is we can go ahead and add a listener here so you can see here at the top request
builder.
And I'm going to use this listener to create a new object while you need to pass an object here.
I'm just going to create a new object here, which will be of type A request.
Listener.
This request listener needs to know what it should request, and in this case, we're going to use a
drawable and now in curly brackets, that's where we need to implement the functions that this request
listener needs.
So let's implement the members and it's to unload failed and one resource ready.
Get us at the two.
So what is it that we want to run on load failed?
Well, we're going to.
For now, at a log entry here log, he saying tag and the message will be something like error, loading
image and past error and then return false in this case.
And then what should happen once this worked out?
So if this worked well, that's the part where we're going to implement it.
OK, so here I'm going to spell it.
From resource to bitmap.
I guess to excess resources, which is this drawable, which is a nullable, so we need to I had a question
mark here for this to work and import pellet.
OK, so now there's bitmap.
Is to be generated, so we generate now based on this bit and that we're going to generate something
and what is it that we're going to generate?
Well, I pallette.
So he would get a pellet, as I see it, pellet, and I'm going to use the paint color based on that
pellet.
OK, so you're going to use vibrant swatch.
Okay, so here you can use different kind of settings.
I'm going to use Cribbins Swatch RGV.
If that exists, then take it otherwise.
Take zero as a value and have talked to many.
So this is an if statement basically that we have here.
And at that point we can use our binding property to set the.
How well this detail main and set is background color to be in color.
OK, so there's a lot going on here.
Let's look at that step by step.
And by the way, it seems like this resource is causing trouble, so let's make sure that we use let
here.
So only in case that resource is, in fact going to work out, then we're going to focus on Reppert.
So if resource is not empty, we're going to focus on Reppert and generate that pellet.
OK, so what's going to happen is it's going to take the image, which is this image here, and it's
going to assign the background here accordingly.
OK, so where does this come from?
Well, it comes from Pellet.
OK, so we use Pelletiere and we take the resource, whatever the images, and we generate a new palette.
We get to color based on that palette.
And if palette, vibrant swatch hajib exists, well, basically we get the value here, an integer that
represents the color.
And if it doesn't exist, we're going to do zero, which is going to be white, OK, and then we bind
that to our RL dish detail main, which is this scroll view that we have here, basically this complete
screen.
So it will take it as the background for the complete screen here for the whole scroll view, which
basically is the whole screen, and then we need to return something.
So I'm going to return false here.
All right.
So that's already it, that's how you can use it very quickly, so you take a bitmap, has the resources
that you can generate a pallet, which will then give you an integer color, which you then can use
to set that to whatever element you want.
And the cool thing is we did that directly and the listener of our light.
So that's the power of light again and really helps us out here.
As you can see, we can just add a listener here.
OK, let's run the application and see if this is going to work with our homework.
OK, so there we are.
Let's see, as you saw it directly set up, the image here, according to.
Now, let me select another image, therefore I'm going to download something, so here, let's take
apple pie.
And let's take this image, as you see, for some reason, Emulator is not working correctly, but I'm
just going to take the images.
And let's take this apple pie here.
And just download this image and I'll get back to our application emulator doesn't seem to work correctly.
Let's select an image here.
From the gallery, I'm going to select the apple pie this time.
Let's call this apple pie.
Type will be desert and.
Bakary.
Apple and pie are the ingredients minutes, I have no idea, and directions to cook put into the oven.
That's how simple it is.
And at this case, let's look at apple pie.
And you see now it takes this brownish color just to check.
It's a different one than this yellow.
Yeah, that's correct.
So that's how we can use our palette.
So even though this might not look very good, you just have to decide for yourself if you want to use
it in your application or not.
This was just an example of how to do it.
OK, so that's it for this video.
See you in the next one.