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

Update DefaultLocationProvider.java #37

Closed
wants to merge 5 commits into from
Closed

Update DefaultLocationProvider.java #37

wants to merge 5 commits into from

Conversation

sheddar
Copy link

@sheddar sheddar commented Mar 25, 2017

Handle situation when user decide to activate location through status bar while the gps dialog is displayed. Gps provider is checked in every scenario to prevent application from performing unnecessary actions.

Handle situation when user decide to activate location through status bar while the gps dialog is displayed. Gps provider is checked in every scenario to prevent application from performing unnecessary actions.
Added SourceListener to determine when GooglePlayServiceProvider failed
Passed SourceListener to constructor
Creating fallback when onConnectionSuspended() or onConnectionFailed() happens, firing DefaultProvider
@yayaa
Copy link
Owner

yayaa commented Mar 26, 2017

1- You are violating separation of concerns by adding SourceListener to DispatcherLocationProvider and sending GooglePlayServices information back. That shouldn't know about those stuff, nor care.
2- Getting GPS enabled actually not something that you'd get response as immediately, it might working on your device, but i'd suggest you to test on more devices or maybe even emulator just to see down sides.

Not that i don't wanna do this, but it's quite not easy :) There is also this issue asking for same thing, but even though i tried a few stuff couldn't get a really working solution.

With 1 point above, i cannot accept this PR for sure, please take a look at that part again, and remove or modify somehow.

@@ -271,19 +271,29 @@ public void runScheduledTask(@NonNull String taskId) {
}
}

@Override
@Override
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no :) Remove unnecessary space here.

if (!activityStarted) {
onLocationFailed(FailType.VIEW_NOT_REQUIRED_TYPE);
if (isGPSProviderEnabled()) {
LogUtils.logI("User didn't activate GPS through the dialog, but using status bar");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the text here and below, it doesn't actually necessary to do it via status bar, user can also directly go to settings and enabled it. Just mention as 'but activated manually'

@Override
public void onConnectionSuspended(int i) {
if(activeProvider instanceof GooglePlayServicesLocationProvider){
activeProvider.cancel();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also you don't need to do this stuff manually, it will be done via scheduled task when waiting time is up.

Of course, this would mean quick fallback, agree on that one. But in that case, this is not a concern of GooglePlayServices so using SourceListener which belongs to GooglePlayServicesProvider is not a right tool.

You could create another interface just to notify back when it would fail. And i would do that within another PR, because those 2 different topics now you're trying to cover.

LogUtils.logI("GoogleApiClient connection is suspended, calling fail...");
failed(FailType.GOOGLE_PLAY_SERVICES_CONNECTION_FAIL);
LogUtils.logI("GoogleApiClient connection is suspended, start DefaultLocation ");
sourceListener.onConnectionSuspended(i);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here now, you are also violating the configuration. See the if block above, it checks whether configuration says it should fail or not, and in this case it should but you're switching back to defaultProviders.
Maybe you can even create another configuration part called "switchToDefaultsOnFail" in GooglePlayServicesConfiguration and implement that way further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants