Skip to content

adds location layer options class - #267

Merged
cammace merged 10 commits into
stale-statefrom
location-layer-options-class
Feb 13, 2018
Merged

cammace merged 10 commits into
stale-statefrom
location-layer-options-class

Conversation

@cammace

@cammace cammace commented Jan 31, 2018 •

Copy link
Copy Markdown

Closes #183

Allows you to set style dynamically using the LocationLayerOptions class. Also adds all the necessary attributes that were settable in the now deprecated MyLocationViewSettings.

@cammace cammace added this to the location-layer-0.4.0 milestone Jan 31, 2018
@cammace cammace self-assigned this Jan 31, 2018
@cammace
cammace requested a review from tobrun January 31, 2018 22:00

@tobrun tobrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Starting to shape up nicely, just a couple of nits

onLocationStaleListeners.clear();
return;
}
onLocationStaleListeners.remove(onLocationStaleListener);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this method doesn't do what is expected from its name when a null is passed.

*/
@SuppressWarnings( {"MissingPermission"})
private void setLastLocation() {
private void setLastLocation(int locationLayerMode) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why does the end developer need to pass in the mode? isn't this part of the state managed by the plugin itself?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This method isn't exposed to the end dev, it's purpose is to attempt at getting a location value immediately when a mode is set.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for clarifying, I'm still a bit confused why you aren't moving this line to the top of the method and just checking against this.locationLayerMode instead. Would this break any business logic?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point, initially testing and not seeing any issues with this approach.

@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onStop() {
StaleStateRunnable.getInstance().removeOnLocationStaleListener(null);
StaleStateRunnable.getInstance().onStop();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Calling getInstance twice while one time is sufficient, either assign result/reuse or refactor StateStateRunnable to encapsulate behaviour into one method. If removeOnLocationStaleListener is only used in this code path the latter suggestion would make most sense.

import com.google.auto.value.AutoValue;

@AutoValue
public abstract class LocationLayerOptions implements Parcelable {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

missing javadoc on public API from this class.

}
}

static Bitmap setShadow(Drawable drawable, float elevation) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

setShadow is not a setter

@Test
public void whenModeChanged_remainsUsingStaleIcons() throws Exception {

}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

empty tests

private MapboxMap mapboxMap;
private LocationLayerPlugin locationLayerPlugin;

Location location;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

make private?

@cammace
cammace force-pushed the location-layer-options-class branch from fd805ce to 7899442 Compare February 8, 2018 02:32
@cammace

cammace commented Feb 8, 2018

Copy link
Copy Markdown
Author

Thanks for the notes @tobrun, I've fixed up the issues and am ready for a second pass. I also forgot to mention that this PR branched from #264, it might be easier if I merge this into that branch for the final review. Let me know what works for you.

*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
public void setLocationLayerEnabled(@LocationLayerMode.Mode int locationLayerMode) {
this.locationLayerMode = locationLayerMode;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this change allows to also remove the param in toggleCameraListener?

@cammace
cammace merged commit 1914d22 into stale-state Feb 13, 2018
@cammace
cammace deleted the location-layer-options-class branch February 13, 2018 17:34
cammace pushed a commit that referenced this pull request Feb 13, 2018
* Initial stale logic added

* adds location layer options class (#267)

* adds location layer options class

* Fixed memory leak in manual location update activity

* Remove stale state listener in onStop

* add elevation attribute

* fix accuracy showing during nav mode

* added documentation to location options

* added some test for the class

* fixed test

* set locationlayermode at beginning of method

* remove toggleCameraListener param

* remove stale state singleton

* resolved timber planting itself 3 times
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