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

AnnotationOptions.alpha Needs To Return SuperType #2631

Closed

Description

@bleege

Currently AnnotationOptions.alpha() returns an AnnotationsOptions object. While this is functional, it requires casting to be applied in common Builder patterns which isn't good. For example:

MapView map = ...;

// works
map.addPolygon(new PolygonOptions().add(latLngs));

// currently doesn't work due to typing, but is ideal
map.addPolygon(new PolygonOptions().add(latLngs).alpha(0.5f));

// casting needed to make work, but not something that should be used 
map.addPolygon((PolygonOptions) new PolygonOptions().add(latLngs).alpha(0.5f));

/cc @tobrun @ljbade

Activity

  1. added
    Android
    on Oct 15, 2015
  2. added this to the android-v2.1.0 milestone on Oct 15, 2015
  3. ljbade commented on Oct 15, 2015

    @ljbade
    Contributor

    Interesting, the other options support this. Also core GL marker don't support alpha, so only needed for lines and polygons.

  4. added a commit that references this issue on Oct 16, 2015
    93c0953
  5. self-assigned this
    on Oct 16, 2015
  6. tobrun commented on Oct 16, 2015

    @tobrun
    Member

    @bleege didn't the generic builder pattern solve this?

  7. assigned and unassigned on Oct 16, 2015
  8. bleege commented on Oct 16, 2015

    @bleege
    ContributorAuthor

    @tobrun I didn't have time to finish yesterday afternoon so I just created this issue to make sure this was known. Hoping to get it to today.

  9. bleege commented on Oct 16, 2015

    @bleege
    ContributorAuthor

    Looking at Google's implementation they avoided this problem all together by keeping PolygonOptions, PolyLineOptions, and MarkerOptions all independent. In other words, they don't use DRY and each one of these Option classes extends from java.lang.Object and implements android.os.Parcelable.

  10. bleege commented on Oct 16, 2015

    @bleege
    ContributorAuthor

    Doing some R&D on this shows that the AnnotationsOptions abstract class came as part of clean up / refactoring in #1716. In other words this was introduced in Mapbox and not needed as part of the Google API (confirms previous statement on API).

  11. ljbade commented on Oct 16, 2015

    @ljbade
    Contributor

    @bleege Does the same apply to the Marker, Polyline, Polygon classes? If we split these up we will need to do a bit of re-factoring in MapView.

    Also should point out this was an easy fix in my large PR, I just pushed .alpha to the concrete classes.

  12. added 2 commits that reference this issue on Oct 16, 2015
  13. 1 remaining item

  14. added 2 commits that reference this issue on Oct 16, 2015
  15. bleege commented on Oct 16, 2015

    @bleege
    ContributorAuthor

    Rebased and merged.

  16. added 4 commits that reference this issue on Oct 20, 2015
  17. added 3 commits that reference this issue on Nov 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Android

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions