public class GPS
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
GPS.AppState
States enum.
|
private static class |
GPS.AppTrigger
Triggers enum.
|
private class |
GPS.FailEntry
Action taken before the state machine enter
GPS.AppState.FAILURE -> destroy_internals()
and dispatches a new GPSEvent.STOP . |
private class |
GPS.SearchEntry
Action taken before the state machine enters
GPS.AppState.SEARCHING -> requests a new
location by using the location_provider_ . |
private class |
GPS.SleepEntry
Action taken before the state machine enter
GPS.AppState.OFF -> destroy_internals()
and dispatches a new GPSEvent.STOP . |
private class |
GPS.StartEntry
Action taken before the state machine enters
GPS.AppState.ON -> dispatches a new GPSEvent.START
event. |
private class |
GPS.StopEntry
Action taken before the state machine enter
GPS.AppState.OFF -> destroy_internals()
and dispatches a new GPSEvent.STOP . |
Modifier and Type | Field and Description |
---|---|
private android.app.Activity |
activity_
MainActivity backref. |
private android.content.Context |
context_
MainActivity 's Context backref. |
private com.github.oxo42.stateless4j.StateMachine<GPS.AppState,GPS.AppTrigger> |
fsm_
The state machine.
|
private android.location.Location |
last_location_
The last know location
|
private com.google.android.gms.location.LocationCallback |
location_callback_
A
LocationCallback instance. |
private com.google.android.gms.location.FusedLocationProviderClient |
location_provider_
A
FusedLocationProviderClient instance. |
private short |
search_duration_
Amount of time (in ms) spent between 2 location updates when searching for an initial (and acceptable) user location.
|
private android.os.Handler |
timeout_handler_
Location timeout thread handler.
|
private java.lang.Runnable |
timeout_runnable_
Location timeout thread runnable.
|
Constructor and Description |
---|
GPS(android.content.Context context,
android.app.Activity activity) |
Modifier and Type | Method and Description |
---|---|
private void |
destroy_internals()
Removes location updates and nullify related holders.
|
void |
search()
search() trigger. |
GPS.AppState |
state()
Returns the current state of the
fsm_ . |
void |
stop()
stop() trigger. |
private final java.lang.Runnable timeout_runnable_
private final android.os.Handler timeout_handler_
private final android.content.Context context_
MainActivity
's Context
backref.private final android.app.Activity activity_
MainActivity
backref.private final com.github.oxo42.stateless4j.StateMachine<GPS.AppState,GPS.AppTrigger> fsm_
@Nullable private com.google.android.gms.location.FusedLocationProviderClient location_provider_
FusedLocationProviderClient
instance.@Nullable private com.google.android.gms.location.LocationCallback location_callback_
LocationCallback
instance.private short search_duration_
@Nullable private android.location.Location last_location_
public GPS(@NonNull android.content.Context context, @NonNull android.app.Activity activity)
private void destroy_internals()
public void search()
search()
trigger.public void stop()
stop()
trigger.public GPS.AppState state()
fsm_
.GPS.AppState
variable.