-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
114fb86
commit 5d1e560
Showing
9 changed files
with
87 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'kotlin-android' | ||
id 'kotlin-parcelize' | ||
id 'org.jetbrains.dokka' | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
location-engine/src/main/java/dev/arpan/location/engine/LocationRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dev.arpan.location.engine | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
import com.google.android.gms.location.LocationRequest as GoogleLocationRequest | ||
import com.huawei.hms.location.LocationRequest as HMSLocationRequest | ||
|
||
@Parcelize | ||
data class LocationRequest( | ||
var priority: Int = PRIORITY_HIGH_ACCURACY, | ||
var interval: Long = 10000L, | ||
var fastestInterval: Long = (interval / 6.0).toLong(), | ||
var smallestDisplacement: Float = 0.0f | ||
) : Parcelable { | ||
companion object { | ||
const val PRIORITY_HIGH_ACCURACY = 100 | ||
const val PRIORITY_BALANCED_POWER_ACCURACY = 102 | ||
const val PRIORITY_LOW_POWER = 104 | ||
const val PRIORITY_NO_POWER = 105 | ||
} | ||
|
||
fun toHMSLocationRequest(): HMSLocationRequest { | ||
val request = HMSLocationRequest() | ||
request.priority = priority | ||
request.interval = interval | ||
request.fastestInterval = fastestInterval | ||
request.smallestDisplacement = smallestDisplacement | ||
return request | ||
} | ||
|
||
fun toGoogleLocationRequest(): GoogleLocationRequest { | ||
val request = GoogleLocationRequest.create() | ||
request.priority = priority | ||
request.interval = interval | ||
request.fastestInterval = fastestInterval | ||
request.smallestDisplacement = smallestDisplacement | ||
return request | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters