Welcome back.
We created the location repository interface.
Now let's create a class that implements this interface location repository implementation.
Click okay and this class implements this location repository interface.
Use our friend inject annotation.
Inject the constructor.
And with what we need to inject we need to inject it with context.
So add application context private val context.
It's of type context Alt+ enter to import the inject.
And here we go okay.
So this is our class location repository implementation that extends from Location repository.
Now we need to implement the members two variables and two functions here.
Let's start with you can use like this Alt+ enter to implement the members.
But I don't need this.
I need to go through every parameter step by step.
Let's start with the first variable.
User location.
Private val.
User location.
It's of type immutable state flow of lat long and the default value is null.
Import the mutable state flow and lat long.
Now override val user location type state flow of lat long.
And what we need to do is to get the user location dot as state flow.
Let me explain what we've done here.
The purpose behind creating this is creating a read only or read write backing property.
User location and read only public property called user location.
So this is for read write backing property and this is for read only public property following the unidirectional
data flow principle.
So internally we are going to update the underscore user location.
External component only read via user location.
So this is for public.
And this is for private.
This is read only and this is read.
Write the mutable state flow immutable holder for state that emits updates to collectors and Latlong
type parameter typically contains a latlong nullable when no location available.
Null is the initial value.
No known location.
The state of flow exposed via as state flow function, which converts mutable flow to immutable, preventing
external modification, and still reflects all updates from the source.
So using this we achieve immutability.
Write access.
Read access.
Thread safety and initial value.
Why this is important and why we use this pattern for encapsulation.
Internal implementation can change without affecting clients and external components.
Can't modify the state directly.
Then we need to create the second variable which is has location permission.
You notice that we used this and the color violet is changed and replacing the grey start with override.
Val has location permission which is a mutable state of.
And let me change it to false.
Okay, this is our value.
I am setting it to false as the initial value.
Okay, those are the variables.
Now let's continue with the functions.