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

Activate LocationEngine in onCreate #321

Merged
merged 3 commits into from
Oct 6, 2017
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 @@ -32,6 +32,14 @@ public LocationViewModel(Application application) {
initLocation(application);
}

@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
public void onCreate() {
if (locationEngine.getValue() != null) {
locationEngine.getValue().addLocationEngineListener(this);
locationEngine.getValue().activate();
}
}

@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroy() {
deactivateLocationEngine();
Expand Down Expand Up @@ -85,10 +93,8 @@ private void initLocation(Application application) {
if (!shouldSimulateRoute()) {
modelLocationEngine = new LocationSource(application.getApplicationContext());
modelLocationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
modelLocationEngine.addLocationEngineListener(this);
modelLocationEngine.setFastestInterval(1000);
modelLocationEngine.setInterval(0);
modelLocationEngine.activate();
this.locationEngine.setValue(modelLocationEngine);

if (modelLocationEngine.getLastLocation() != null) {
Expand Down