-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! There are some leftover drawables that were used with MarkerView
s, or even MyLocationView
, maybe we can clean those up as a part of this PR as well?
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_marker_view); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also remove this layout.
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_marker_view_in_rect); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also remove this layout.
@@ -169,22 +164,10 @@ void onDestroy() { | |||
* Called before the OnMapReadyCallback is invoked. | |||
*/ | |||
void onPreMapReady() { | |||
invalidateCameraPosition(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it might be beneficial to keep transform.invalidateCameraPosition()
call here to always have a non-null camera position once the control is handled to the user. I believe we refactored Transform
in the past to always, even internally, use Transform#getCameraPostion
instead of the cameraPosition
field and avoid NPEs (unless core returns a null
camera position), but just to future proof, we can invalidate that position here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use-cases are handled correctly by transform.
@UiThread
public final CameraPosition getCameraPosition() {
if (cameraPosition == null) {
cameraPosition = invalidateCameraPosition();
}
return cameraPosition;
}
but just to future proof, we can invalidate that position here as well.
hardening and thus future proofing is handled in Transform.java, if there is no concrete indication to keep this use-case around. I would prefer not doing any obsolete work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively, I'm ok with keeping that onPreMapReady hook but let's remove the hardened check in Transform#getCameraPosition()
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm referring to a scenario when we would use Transform#cameraPosition
field instead of the Transform#getCameraPosition
method to perform operations on the camera object inside the Transform
class. All of those usages have been refactored to use Transform#getCameraPosition
, but I'm worried they might pop up again.
However, on the second thought, I'm not really sure whether we should perform obsolete calls to harden that, tests should be the way to go. Let's remove the call now, as it's not needed, and try to expnad our test suite to cover for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you concerns are valid. I did a find usages on the Transfrom#cameraPosition
: 3 usages were found accessing this field directly and all where handling the null case. The more I think about it, the more I would prefer rewriting this part of the SDK..
1795a22
to
951b9ed
Compare
if (cameraPosition == null) { | ||
cameraPosition = invalidateCameraPosition(); | ||
if(cameraPosition == null){ | ||
throw new IllegalStateException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this should be the way to go. Since the initial place where we fetch the camera position from the core is on frame fully rendered, the cameraPosition
is still null
when we deliver the onMapReady
, as the frame is typically not fully render yet. I can reproduce this by calling mapboxMap#getCameraPosition
inside of the onMapReady
.
We should either keep this guard, or invalidate the camera before delivering the onMapReady
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capturing from the chat that this is only a test setup, to let the CI catch possible regressions.
f85403e
to
7199d8e
Compare
c567774
to
03671ea
Compare
This PR needs to be retargeted at master |
020966a
to
30e3393
Compare
a53414d
to
9f69c30
Compare
PR has been retargeted at master and is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
d77fc14
to
1b44c18
Compare
1b44c18
to
cc9cb9d
Compare
cc9cb9d
to
6be221d
Compare
Closes #13169