And this video, we're going to add a dialogue custom progress bar, which will appear once we press
this button.
So that's at least the idea.
And in order to make this a little shorter, let's just put it in here.
So instead of a layout here, let's had this so you can just download it from.
The project, it's the dialogue, custom progress, and if you want to know more about it, you should
check out the video on customer progress bars.
And you can see here that I'm using a constraint layout in there.
I have a progress bar and it text you and that's how they are looking.
So progress bar and text you next to each other, OK?
So that's just basically the courtroom using here.
Progress Bar has an idea and as a with a 50 50 and it's and to start of text you so it's left to the
text to you which is this text you hear which perhaps the content has little margin says please wait
with black text color and text size of sixteen speed.
So everything on parent except for that it's left to or left of it is the progress bar.
So I'll start the end of progress.
OK, so that's the dialogue, custom progress and we are going to use that in our project now.
And a good spot for it will be in our bitmap async task.
OK, so here private late in it vare.
So I'm going to use a late initializing variable which will not initialize straight away, but later
on.
And I still don't want this to be a nullable.
So that's why I am using this approach here late in it for progress dialogue.
Now, of course, once I use it, I need to make sure that it's not empty.
Otherwise I cause I know pointer exception here.
So that's something that we have to be wary about.
So the next thing we need to do is to use this and progress dialogue.
But I'm going to create a little function which will allow me to show such a dialogue and that will
be inside of my bitmap async task.
So let's create this method and I'm going to create it at the bottom just underneath unposed execute
private fun show progress dialogue.
OK, in here, I'm going to set the progress dialogue.
It's going to be a dialogue with this as it's context.
And here you can see this doesn't work because this would be the class itself in which we are, which
would be the bitmap async task, but I actually want to have the main activity.
So but I need to add here is that main activity.
Now we can set the content view of our progress bar.
So and progress dialogue, set counterview.
To be harder to lay out that dialogue, custom progress, that's the XML file that I imported, this
one here.
OK, so I'm setting it as the content view and then I'm displaying the progress dialogue by calling
the show method here.
While we're at it, let's also create a little function which will cancel the progress dialogue so private
fun can slow progress dialogue and in here is just going to say.
And progress dialogue, Dismas.
OK, so now we can use those two and when would we use it, so when we use this show progress dialogue,
well, I want to use it in the.
Moment, just before doing background, they started so pre execute, so on, pre execute is where I
want to show the progress dialogue and where do I want to cancel it.
Well, on post execute.
So once we are done.
And it will be just here.
I was just going to say.
Can slow progress dialogue in here.
All right, now let's test it.
Let's see if it's actually going to display correctly.
All right, so let's draw something.
A little smiley, let's save it.
And we saw the progress dialogue, OK, so that was already it.
In the next video, we are going to add the feature where we can then also share our image so we can
share it with our friends, for example, in WhatsApp or Facebook or wherever we want.
So see you there.