Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

MyLocationView activate/deactivate LocationSource #8255

Merged
Merged
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 @@ -257,9 +257,7 @@ protected void onDraw(Canvas canvas) {

final PointF pointF = screenLocation;
float metersPerPixel = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude());
float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel / 2;
float maxRadius = getWidth() / 2;
accuracyPixels = accuracyPixels <= maxRadius ? accuracyPixels : maxRadius;
float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel;

// reset
matrix.reset();
Expand Down Expand Up @@ -435,10 +433,12 @@ private void toggleGps(boolean enableGps) {
}

locationEngine.addLocationEngineListener(userLocationListener);
locationEngine.activate();
} else {
// Disable location and user dot
location = null;
locationEngine.removeLocationEngineListener(userLocationListener);
locationEngine.deactivate();
}

locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
Expand Down Expand Up @@ -730,7 +730,7 @@ void updateAccuracy(@NonNull Location location) {
accuracyAnimator.end();
}

accuracyAnimator = ValueAnimator.ofFloat(accuracy * 10, location.getAccuracy() * 10);
accuracyAnimator = ValueAnimator.ofFloat(accuracy, location.getAccuracy());
accuracyAnimator.setDuration(750);
accuracyAnimator.start();
accuracy = location.getAccuracy();
Expand Down