Skip to content

Commit

Permalink
Make isAvailable a regular fun (#105)
Browse files Browse the repository at this point in the history
Solves #101
  • Loading branch information
cristan authored Dec 19, 2024
1 parent 53cd303 commit 0b45d81
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compass-geolocation/api/android/compass-geolocation.api
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract interface class dev/jordond/compass/geolocation/Geolocator {
public abstract fun current (Ldev/jordond/compass/Priority;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun getLocationUpdates ()Lkotlinx/coroutines/flow/Flow;
public abstract fun getTrackingStatus ()Lkotlinx/coroutines/flow/Flow;
public abstract fun isAvailable (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun isAvailable ()Z
public abstract fun startTracking (Ldev/jordond/compass/geolocation/LocationRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun stopTracking ()V
public abstract fun track (Ldev/jordond/compass/geolocation/LocationRequest;)Lkotlinx/coroutines/flow/Flow;
Expand Down
2 changes: 1 addition & 1 deletion compass-geolocation/api/jvm/compass-geolocation.api
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract interface class dev/jordond/compass/geolocation/Geolocator {
public abstract fun current (Ldev/jordond/compass/Priority;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun getLocationUpdates ()Lkotlinx/coroutines/flow/Flow;
public abstract fun getTrackingStatus ()Lkotlinx/coroutines/flow/Flow;
public abstract fun isAvailable (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun isAvailable ()Z
public abstract fun startTracking (Ldev/jordond/compass/geolocation/LocationRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun stopTracking ()V
public abstract fun track (Ldev/jordond/compass/geolocation/LocationRequest;)Lkotlinx/coroutines/flow/Flow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface Geolocator {
*
* @return `true` if location services are available, `false` otherwise.
*/
public suspend fun isAvailable(): Boolean
public fun isAvailable(): Boolean

/**
* Get the current location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ internal class DefaultGeolocator(

override val trackingStatus: Flow<TrackingStatus> = status

override suspend fun isAvailable(): Boolean = withContext(dispatcher) {
locator.isAvailable()
}
override fun isAvailable(): Boolean = locator.isAvailable()

override suspend fun current(priority: Priority): GeolocatorResult {
return handleResult { locator.current(priority) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import kotlinx.coroutines.launch
class GeolocationModel(private val geolocator: Geolocator) : StateScreenModel<State>(State()) {

init {
screenModelScope.launch {
val isAvailable = geolocator.isAvailable()
updateState { it.copy(locationServiceAvailable = isAvailable) }
}
val isAvailable = geolocator.isAvailable()
updateState { it.copy(locationServiceAvailable = isAvailable) }

geolocator.trackingStatus
.onEach { status ->
Expand Down

0 comments on commit 0b45d81

Please sign in to comment.