Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fastestInterval for googlePlayServicesProvider #209

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@
*/
public class LocationParams {
// Defaults
public static final LocationParams NAVIGATION = new Builder().setAccuracy(LocationAccuracy.HIGH).setDistance(0).setInterval(500).build();
public static final LocationParams BEST_EFFORT = new Builder().setAccuracy(LocationAccuracy.MEDIUM).setDistance(150).setInterval(2500).build();
public static final LocationParams LAZY = new Builder().setAccuracy(LocationAccuracy.LOW).setDistance(500).setInterval(5000).build();
public static final LocationParams NAVIGATION = new Builder()
.setAccuracy(LocationAccuracy.HIGH).setDistance(0)
.setInterval(500).setFastestInterval(500).build();
public static final LocationParams BEST_EFFORT = new Builder()
.setAccuracy(LocationAccuracy.MEDIUM).setDistance(150)
.setInterval(2500).setFastestInterval(2500).build();
public static final LocationParams LAZY = new Builder()
.setAccuracy(LocationAccuracy.LOW).setDistance(500)
.setInterval(5000).setFastestInterval(5000).build();

private long interval;
private long fastestInterval;
private float distance;
private LocationAccuracy accuracy;

LocationParams(LocationAccuracy accuracy, long interval, float distance) {
public LocationParams(LocationAccuracy accuracy, long interval, long fastestInterval, float distance) {
this.interval = interval;
this.fastestInterval = fastestInterval;
this.distance = distance;
this.accuracy = accuracy;
}
Expand All @@ -23,6 +31,10 @@ public long getInterval() {
return interval;
}

public long getFastestInterval() {
return fastestInterval;
}

public float getDistance() {
return distance;
}
Expand All @@ -34,17 +46,20 @@ public LocationAccuracy getAccuracy() {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof LocationParams)) return false;
if (o == null || getClass() != o.getClass()) return false;

LocationParams that = (LocationParams) o;

return Float.compare(that.distance, distance) == 0 && interval == that.interval && accuracy == that.accuracy;
if (interval != that.interval) return false;
if (fastestInterval != that.fastestInterval) return false;
if (Float.compare(that.distance, distance) != 0) return false;
return accuracy == that.accuracy;

}

@Override
public int hashCode() {
int result = (int) (interval ^ (interval >>> 32));
result = 31 * result + (int) (fastestInterval ^ (fastestInterval >>> 32));
result = 31 * result + (distance != +0.0f ? Float.floatToIntBits(distance) : 0);
result = 31 * result + accuracy.hashCode();
return result;
Expand All @@ -53,6 +68,7 @@ public int hashCode() {
public static class Builder {
private LocationAccuracy accuracy;
private long interval;
private long fastestInterval;
private float distance;

public Builder setAccuracy(LocationAccuracy accuracy) {
Expand All @@ -65,13 +81,18 @@ public Builder setInterval(long interval) {
return this;
}

public Builder setFastestInterval(long fastestInterval) {
this.fastestInterval = fastestInterval;
return this;
}

public Builder setDistance(float distance) {
this.distance = distance;
return this;
}

public LocationParams build() {
return new LocationParams(accuracy, interval, distance);
return new LocationParams(accuracy, interval, fastestInterval, distance);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void init(Context context, Logger logger) {

private LocationRequest createRequest(LocationParams params, boolean singleUpdate) {
LocationRequest request = LocationRequest.create()
.setFastestInterval(params.getInterval())
.setFastestInterval(params.getFastestInterval())
.setInterval(params.getInterval())
.setSmallestDisplacement(params.getDistance());

Expand Down