[WIP]Count number of good locations before showing Start button. #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a demo to show how we can count good locations before allowing user to track their locations.
Here is the step
1.
Add a varibale
goodGpsCount
to count the number of initial good locations.goodGpsCount
2.
In onLocationUpdate, after filtering the new location, if it passes the filter, count up
goodGpsCount
.If
goodGpsCount
becomes more than or equal to 3, send broadcast to MainActivity.https://github.com/mizutori/AndroidLocationStarterKitInKotlin/compare/secure-accuracy?expand=1#diff-73ccae8d1b2c89ef24ff25f60549f85125dc67d46c73e466ed9e0c19e2109129R66
3.
In MainActivity, make the
startButton
invisible in the beginning.https://github.com/mizutori/AndroidLocationStarterKitInKotlin/compare/secure-accuracy?expand=1#diff-e4363ca693431b2287ffc5ce969d0abac1ee05f8729ff2d3a4efda2db4ca9df3R174
4.
When receiving the broadcast of goodGpsCount, make
startButton
visible.https://github.com/mizutori/AndroidLocationStarterKitInKotlin/compare/secure-accuracy?expand=1#diff-e4363ca693431b2287ffc5ce969d0abac1ee05f8729ff2d3a4efda2db4ca9df3R144
Other Note
filterAndAddLocation
tofilterLocation
to return null (if location doesn't pass the filter) or location (if the location passes the filter). This is because I want to use this function even before the user pressesstartButton
.